public function ModuleTest::testViewsFetchPluginNames in Drupal 8
Same name and namespace in other branches
- 9 core/modules/views/tests/src/Kernel/ModuleTest.php \Drupal\Tests\views\Kernel\ModuleTest::testViewsFetchPluginNames()
- 10 core/modules/views/tests/src/Kernel/ModuleTest.php \Drupal\Tests\views\Kernel\ModuleTest::testViewsFetchPluginNames()
Tests the \Drupal\views\Views::fetchPluginNames() method.
File
- core/
modules/ views/ tests/ src/ Kernel/ ModuleTest.php, line 204
Class
- ModuleTest
- Tests basic functions from the Views module.
Namespace
Drupal\Tests\views\KernelCode
public function testViewsFetchPluginNames() {
// All style plugins should be returned, as we have not specified a type.
$plugins = Views::fetchPluginNames('style');
$definitions = $this->container
->get('plugin.manager.views.style')
->getDefinitions();
$expected = [];
foreach ($definitions as $id => $definition) {
$expected[$id] = $definition['title'];
}
asort($expected);
$this
->assertIdentical(array_keys($plugins), array_keys($expected));
// Test using the 'test' style plugin type only returns the test_style and
// mapping_test plugins.
$plugins = Views::fetchPluginNames('style', 'test');
$this
->assertIdentical(array_keys($plugins), [
'mapping_test',
'test_style',
'test_template_style',
]);
// Test a non existent style plugin type returns no plugins.
$plugins = Views::fetchPluginNames('style', $this
->randomString());
$this
->assertIdentical($plugins, []);
}