public function ViewElementTest::testInvalidView in Drupal 10
Same name and namespace in other branches
- 9 core/modules/views/tests/src/Kernel/ViewElementTest.php \Drupal\Tests\views\Kernel\ViewElementTest::testInvalidView()
Tests that an exception is thrown when an invalid View is passed.
File
- core/
modules/ views/ tests/ src/ Kernel/ ViewElementTest.php, line 136
Class
- ViewElementTest
- Tests the view render element.
Namespace
Drupal\Tests\views\KernelCode
public function testInvalidView() {
$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);
}