You are here

public function ModuleTest::testViewsFetchPluginNames in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Tests/ModuleTest.php \Drupal\views\Tests\ModuleTest::testViewsFetchPluginNames()

Tests the \Drupal\views\Views::fetchPluginNames() method.

File

core/modules/views/src/Tests/ModuleTest.php, line 230
Contains \Drupal\views\Tests\ModuleTest.

Class

ModuleTest

Namespace

Drupal\views\Tests

Code

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 = array();
  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), array(
    '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, array());
}