You are here

public function PluginInstanceTest::testPluginData in Drupal 8

Same name and namespace in other branches
  1. 9 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.');
}