function ViewExecutableTest::testValidate
Same name in other branches
- 9 core/modules/views/tests/src/Kernel/ViewExecutableTest.php \Drupal\Tests\views\Kernel\ViewExecutableTest::testValidate()
- 8.9.x core/modules/views/tests/src/Kernel/ViewExecutableTest.php \Drupal\Tests\views\Kernel\ViewExecutableTest::testValidate()
- 10 core/modules/views/tests/src/Kernel/ViewExecutableTest.php \Drupal\Tests\views\Kernel\ViewExecutableTest::testValidate()
Tests the validation of display handlers.
File
-
core/
modules/ views/ tests/ src/ Kernel/ ViewExecutableTest.php, line 448
Class
- ViewExecutableTest
- Tests the ViewExecutable class.
Namespace
Drupal\Tests\views\KernelCode
public function testValidate() : void {
$view = Views::getView('test_executable_displays');
$view->setDisplay('page_1');
$validate = $view->validate();
// Validating a view shouldn't change the active display.
$this->assertEquals('page_1', $view->current_display, "The display should be constant while validating");
$count = 0;
foreach ($view->displayHandlers as $id => $display) {
$match = function ($value) use ($display) {
return str_contains((string) $value, $display->display['display_title']);
};
$this->assertNotEmpty(array_filter($validate[$id], $match), "Error message found for {$id} display");
$count++;
}
$this->assertCount($count, $view->displayHandlers, 'Error messages from all handlers merged.');
// Test that a deleted display is not included.
$display =& $view->storage
->getDisplay('default');
$display['deleted'] = TRUE;
$validate_deleted = $view->validate();
$this->assertNotSame($validate, $validate_deleted);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.