protected function PluginInstanceTest::assertPluginInstances in Drupal 9
Same name and namespace in other branches
- 8 core/modules/views/tests/src/Kernel/PluginInstanceTest.php \Drupal\Tests\views\Kernel\PluginInstanceTest::assertPluginInstances()
Asserts that instances of every views plugin can be created.
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 97
Class
- PluginInstanceTest
- Tests that an instance of all views plugins can be created.
Namespace
Drupal\Tests\views\KernelCode
protected function assertPluginInstances($test_deprecated) {
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);
}
}
}
}