function DisplayExtenderTest::testDisplayExtenders
Same name in other branches
- 9 core/modules/views/tests/src/Kernel/Plugin/DisplayExtenderTest.php \Drupal\Tests\views\Kernel\Plugin\DisplayExtenderTest::testDisplayExtenders()
- 8.9.x core/modules/views/tests/src/Kernel/Plugin/DisplayExtenderTest.php \Drupal\Tests\views\Kernel\Plugin\DisplayExtenderTest::testDisplayExtenders()
- 11.x core/modules/views/tests/src/Kernel/Plugin/DisplayExtenderTest.php \Drupal\Tests\views\Kernel\Plugin\DisplayExtenderTest::testDisplayExtenders()
Tests display extenders.
File
-
core/
modules/ views/ tests/ src/ Kernel/ Plugin/ DisplayExtenderTest.php, line 29
Class
- DisplayExtenderTest
- Tests the display extender plugins.
Namespace
Drupal\Tests\views\Kernel\PluginCode
public function testDisplayExtenders() : void {
$this->config('views.settings')
->set('display_extenders', [
'display_extender_test',
])
->save();
$this->assertCount(1, Views::getEnabledDisplayExtenders(), 'Make sure that there is only one enabled display extender.');
$view = Views::getView('test_view');
$view->initDisplay();
$this->assertCount(1, $view->display_handler
->getExtenders(), 'Make sure that only one extender is initialized.');
$display_extender = $view->display_handler
->getExtenders()['display_extender_test'];
$this->assertInstanceOf(DisplayExtenderTestData::class, $display_extender);
$view->preExecute();
$this->assertTrue($display_extender->testState['preExecute'], 'Make sure the display extender was able to react on preExecute.');
$view->execute();
$this->assertTrue($display_extender->testState['query'], 'Make sure the display extender was able to react on query.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.