function ViewExecutableTest::testValidate
Same name in other branches
- 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()
- 11.x 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 437
Class
- ViewExecutableTest
- Tests the ViewExecutable class.
Namespace
Drupal\Tests\views\KernelCode
public function testValidate() {
$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 strpos($value, $display->display['display_title']) !== FALSE;
};
$this->assertNotEmpty(array_filter($validate[$id], $match), new FormattableMarkup('Error message found for @id display', [
'@id' => $id,
]));
$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.