function DefaultViewsTest::testDefaultViews
Same name in this branch
- 9 core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php \Drupal\Tests\views_ui\Functional\DefaultViewsTest::testDefaultViews()
Same name in other branches
- 8.9.x core/modules/views/tests/src/Functional/DefaultViewsTest.php \Drupal\Tests\views\Functional\DefaultViewsTest::testDefaultViews()
- 8.9.x core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php \Drupal\Tests\views_ui\Functional\DefaultViewsTest::testDefaultViews()
- 10 core/modules/views/tests/src/Functional/DefaultViewsTest.php \Drupal\Tests\views\Functional\DefaultViewsTest::testDefaultViews()
- 10 core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php \Drupal\Tests\views_ui\Functional\DefaultViewsTest::testDefaultViews()
- 11.x core/modules/views/tests/src/Functional/DefaultViewsTest.php \Drupal\Tests\views\Functional\DefaultViewsTest::testDefaultViews()
- 11.x core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php \Drupal\Tests\views_ui\Functional\DefaultViewsTest::testDefaultViews()
Tests that all Default views work as expected.
File
-
core/
modules/ views/ tests/ src/ Functional/ DefaultViewsTest.php, line 140
Class
- DefaultViewsTest
- Tests the default views provided by views.
Namespace
Drupal\Tests\views\FunctionalCode
public function testDefaultViews() {
// Get all default views.
$controller = $this->container
->get('entity_type.manager')
->getStorage('view');
$views = $controller->loadMultiple();
foreach ($views as $name => $view_storage) {
$view = $view_storage->getExecutable();
$view->initDisplay();
foreach ($view->storage
->get('display') as $display_id => $display) {
$view->setDisplay($display_id);
// Add any args if needed.
if (array_key_exists($name, $this->viewArgMap)) {
$view->preExecute($this->viewArgMap[$name]);
}
$view->execute();
$tokens = [
'@name' => $name,
'@display_id' => $display_id,
];
$this->assertTrue($view->executed, new FormattableMarkup('@name:@display_id has been executed.', $tokens));
$this->assertNotEmpty($view->result);
$view->destroy();
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.