You are here

public function ModuleTest::testViewsPluginList in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Kernel/ModuleTest.php \Drupal\Tests\views\Kernel\ModuleTest::testViewsPluginList()
  2. 9 core/modules/views/tests/src/Kernel/ModuleTest.php \Drupal\Tests\views\Kernel\ModuleTest::testViewsPluginList()

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

File

core/modules/views/tests/src/Kernel/ModuleTest.php, line 229

Class

ModuleTest
Tests basic functions from the Views module.

Namespace

Drupal\Tests\views\Kernel

Code

public function testViewsPluginList() {
  $plugin_list = Views::pluginList();

  // Only plugins used by 'test_view' should be in the plugin list.
  foreach ([
    'display:default',
    'pager:none',
  ] as $key) {
    [
      $plugin_type,
      $plugin_id,
    ] = explode(':', $key);
    $plugin_def = $this->container
      ->get("plugin.manager.views.{$plugin_type}")
      ->getDefinition($plugin_id);
    $this
      ->assertTrue(isset($plugin_list[$key]), new FormattableMarkup('The expected @key plugin list key was found.', [
      '@key' => $key,
    ]));
    $plugin_details = $plugin_list[$key];
    $this
      ->assertEquals($plugin_type, $plugin_details['type'], 'The expected plugin type was found.');
    $this
      ->assertEquals($plugin_def['title'], $plugin_details['title'], 'The expected plugin title was found.');
    $this
      ->assertEquals($plugin_def['provider'], $plugin_details['provider'], 'The expected plugin provider was found.');
    $this
      ->assertContains('test_view', $plugin_details['views'], 'The test_view View was found in the list of views using this plugin.');
  }
}