function PluginInstanceTest::assertPluginInstances
Asserts that instances of every views plugin can be created.
@internal
Parameters
bool $test_deprecated: Indicates if deprecated plugins should be tested or skipped.
1 call to PluginInstanceTest::assertPluginInstances()
- PluginInstanceTest::testPluginInstances in core/
modules/ views/ tests/ src/ Kernel/ PluginInstanceTest.php  - Tests creating instances of every views plugin.
 
File
- 
              core/
modules/ views/ tests/ src/ Kernel/ PluginInstanceTest.php, line 111  
Class
- PluginInstanceTest
 - Tests that an instance of all views plugins can be created.
 
Namespace
Drupal\Tests\views\KernelCode
protected function assertPluginInstances(bool $test_deprecated) : void {
  foreach ($this->definitions as $type => $plugins) {
    // Get a plugin manager for this type.
    $manager = $this->container
      ->get("plugin.manager.views.{$type}");
    foreach ($plugins as $id => $definition) {
      if ($test_deprecated !== in_array($definition['class'], $this->deprecatedPlugins)) {
        continue;
      }
      // Get a reflection class for this plugin.
      // We only want to test true plugins, i.e. They extend PluginBase.
      $reflection = new \ReflectionClass($definition['class']);
      if ($reflection->isSubclassOf(PluginBase::class)) {
        // Create a plugin instance and check what it is. This is not just
        // good to check they can be created but for throwing any notices for
        // method signatures etc. too.
        $instance = $manager->createInstance($id);
        $this->assertInstanceOf($definition['class'], $instance);
      }
    }
  }
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.