function ModuleTest::testViewsPluginList

Same name in other branches
  1. 9 core/modules/views/tests/src/Kernel/ModuleTest.php \Drupal\Tests\views\Kernel\ModuleTest::testViewsPluginList()
  2. 8.9.x core/modules/views/tests/src/Kernel/ModuleTest.php \Drupal\Tests\views\Kernel\ModuleTest::testViewsPluginList()
  3. 11.x 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() : void {
    $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]), "The expected {$key} plugin list key was found.");
        $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.');
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.