function ViewExecutableTest::testSetDisplayWithInvalidDisplay
Same name in other branches
- 9 core/modules/views/tests/src/Kernel/ViewExecutableTest.php \Drupal\Tests\views\Kernel\ViewExecutableTest::testSetDisplayWithInvalidDisplay()
- 8.9.x core/modules/views/tests/src/Kernel/ViewExecutableTest.php \Drupal\Tests\views\Kernel\ViewExecutableTest::testSetDisplayWithInvalidDisplay()
- 11.x core/modules/views/tests/src/Kernel/ViewExecutableTest.php \Drupal\Tests\views\Kernel\ViewExecutableTest::testSetDisplayWithInvalidDisplay()
File
-
core/
modules/ views/ tests/ src/ Kernel/ ViewExecutableTest.php, line 210
Class
- ViewExecutableTest
- Tests the ViewExecutable class.
Namespace
Drupal\Tests\views\KernelCode
public function testSetDisplayWithInvalidDisplay() : void {
\Drupal::service('module_installer')->install([
'dblog',
]);
$view = Views::getView('test_executable_displays');
$view->initDisplay();
// Error is logged while calling the wrong display.
$view->setDisplay('invalid');
$arguments = [
'@display_id' => 'invalid',
];
$logged = Database::getConnection()->select('watchdog')
->fields('watchdog', [
'variables',
])
->condition('type', 'views')
->condition('message', 'setDisplay() called with invalid display ID "@display_id".')
->execute()
->fetchField();
$this->assertEquals(serialize($arguments), $logged);
$this->assertEquals('default', $view->current_display, 'If setDisplay is called with an invalid display id the default display should be used.');
$this->assertEquals(spl_object_hash($view->displayHandlers
->get('default')), spl_object_hash($view->display_handler));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.