function PluginInstanceTest::testPluginData

Same name and namespace in other branches
  1. 9 core/modules/views/tests/src/Kernel/PluginInstanceTest.php \Drupal\Tests\views\Kernel\PluginInstanceTest::testPluginData()
  2. 10 core/modules/views/tests/src/Kernel/PluginInstanceTest.php \Drupal\Tests\views\Kernel\PluginInstanceTest::testPluginData()
  3. 11.x core/modules/views/tests/src/Kernel/PluginInstanceTest.php \Drupal\Tests\views\Kernel\PluginInstanceTest::testPluginData()

Confirms that there is plugin data for all views plugin types.

File

core/modules/views/tests/src/Kernel/PluginInstanceTest.php, line 67

Class

PluginInstanceTest
Tests that an instance of all views plugins can be created.

Namespace

Drupal\Tests\views\Kernel

Code

public function testPluginData() {
    // Check that we have an array of data.
    $this->assertIsArray($this->definitions);
    // Check all plugin types.
    foreach ($this->pluginTypes as $type) {
        $this->assertArrayHasKey($type, $this->definitions);
        $this->assertIsArray($this->definitions[$type]);
        $this->assertNotEmpty($this->definitions[$type], "Plugin type '{$type}' should contain plugins.");
    }
    // Tests that the plugin list has not missed any types.
    $diff = array_diff(array_keys($this->definitions), $this->pluginTypes);
    $this->assertTrue(empty($diff), 'All plugins were found and matched.');
}

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