function ViewElementTest::testInvalidView
Tests that an exception is thrown when an invalid View is passed.
File
- 
              core/modules/ views/ tests/ src/ Kernel/ ViewElementTest.php, line 137 
Class
- ViewElementTest
- Tests the view render element.
Namespace
Drupal\Tests\views\KernelCode
public function testInvalidView() : void {
  $renderer = $this->container
    ->get('renderer');
  $render_element = [
    '#type' => 'view',
    '#name' => 'invalid_view_name',
    '#embed' => FALSE,
  ];
  $this->expectException(ViewRenderElementException::class);
  $this->expectExceptionMessage("Invalid View name ({$render_element['#name']}) given.");
  $renderer->renderRoot($render_element);
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
