public function ViewExecutableTest::testValidate in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/src/Tests/ViewExecutableTest.php \Drupal\views\Tests\ViewExecutableTest::testValidate()
Tests the validation of display handlers.
File
- core/
modules/ views/ src/ Tests/ ViewExecutableTest.php, line 413 - Contains \Drupal\views\Tests\ViewExecutableTest.
Class
- ViewExecutableTest
- Tests the ViewExecutable class.
Namespace
Drupal\views\TestsCode
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
->assertEqual('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
->assertTrue(array_filter($validate[$id], $match), format_string('Error message found for @id display', array(
'@id' => $id,
)));
$count++;
}
$this
->assertEqual(count($view->displayHandlers), $count, '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
->assertNotIdentical($validate, $validate_deleted, 'Master display has not been validated.');
}