public function DisplayKernelTest::testGetPlugin in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/src/Tests/Plugin/DisplayKernelTest.php \Drupal\views\Tests\Plugin\DisplayKernelTest::testGetPlugin()
Tests the \Drupal\views\Plugin\views\display\DisplayPluginBase::getPlugin() method.
File
- core/
modules/ views/ src/ Tests/ Plugin/ DisplayKernelTest.php, line 96 - Contains \Drupal\views\Tests\Plugin\DisplayKernelTest.
Class
- DisplayKernelTest
- Drupal unit tests for the DisplayPluginBase class.
Namespace
Drupal\views\Tests\PluginCode
public function testGetPlugin() {
$view = Views::getView('test_display_defaults');
$view
->initDisplay();
$display_handler = $view->display_handler;
$this
->assertTrue($display_handler
->getPlugin('access') instanceof AccessPluginBase, 'An access plugin instance was returned.');
$this
->assertTrue($display_handler
->getPlugin('cache') instanceof CachePluginBase, 'A cache plugin instance was returned.');
$this
->assertTrue($display_handler
->getPlugin('exposed_form') instanceof ExposedFormPluginBase, 'An exposed_form plugin instance was returned.');
$this
->assertTrue($display_handler
->getPlugin('pager') instanceof PagerPluginBase, 'A pager plugin instance was returned.');
$this
->assertTrue($display_handler
->getPlugin('query') instanceof QueryPluginBase, 'A query plugin instance was returned.');
$this
->assertTrue($display_handler
->getPlugin('row') instanceof RowPluginBase, 'A row plugin instance was returned.');
$this
->assertTrue($display_handler
->getPlugin('style') instanceof StylePluginBase, 'A style plugin instance was returned.');
// 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
->assertIdentical($first, $second, 'The same plugin instance was returned.');
}