function DisplayKernelTest::testGetPlugin
Same name in other branches
- 9 core/modules/views/tests/src/Kernel/Plugin/DisplayKernelTest.php \Drupal\Tests\views\Kernel\Plugin\DisplayKernelTest::testGetPlugin()
- 8.9.x core/modules/views/tests/src/Kernel/Plugin/DisplayKernelTest.php \Drupal\Tests\views\Kernel\Plugin\DisplayKernelTest::testGetPlugin()
- 10 core/modules/views/tests/src/Kernel/Plugin/DisplayKernelTest.php \Drupal\Tests\views\Kernel\Plugin\DisplayKernelTest::testGetPlugin()
Tests the \Drupal\views\Plugin\views\display\DisplayPluginBase::getPlugin() method.
File
-
core/
modules/ views/ tests/ src/ Kernel/ Plugin/ DisplayKernelTest.php, line 92
Class
- DisplayKernelTest
- Drupal unit tests for the DisplayPluginBase class.
Namespace
Drupal\Tests\views\Kernel\PluginCode
public function testGetPlugin() : void {
$view = Views::getView('test_display_defaults');
$view->initDisplay();
$display_handler = $view->display_handler;
$this->assertInstanceOf(AccessPluginBase::class, $display_handler->getPlugin('access'));
$this->assertInstanceOf(CachePluginBase::class, $display_handler->getPlugin('cache'));
$this->assertInstanceOf(ExposedFormPluginInterface::class, $display_handler->getPlugin('exposed_form'));
$this->assertInstanceOf(PagerPluginBase::class, $display_handler->getPlugin('pager'));
$this->assertInstanceOf(QueryPluginBase::class, $display_handler->getPlugin('query'));
$this->assertInstanceOf(RowPluginBase::class, $display_handler->getPlugin('row'));
$this->assertInstanceOf(StylePluginBase::class, $display_handler->getPlugin('style'));
// Test that nothing is returned when an invalid type is requested.
$this->assertNull($display_handler->getPlugin('invalid'), 'NULL was returned for an invalid instance');
// Test that nothing was returned for an instance with no 'type' in options.
unset($display_handler->options['access']);
$this->assertNull($display_handler->getPlugin('access'), 'NULL was returned for a plugin type with no "type" option');
// Get a plugin twice, and make sure the same instance is returned.
$view->destroy();
$view->initDisplay();
$first = spl_object_hash($display_handler->getPlugin('style'));
$second = spl_object_hash($display_handler->getPlugin('style'));
$this->assertSame($first, $second, 'The same plugin instance was returned.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.