PluginManagerTest.php in Purge 8.3
File
tests/src/Kernel/Purger/PluginManagerTest.php
View source
<?php
namespace Drupal\Tests\purge\Kernel\Purger;
use Drupal\purge\Plugin\Purge\Purger\PluginManager;
use Drupal\Tests\purge\Kernel\KernelPluginManagerTestBase;
class PluginManagerTest extends KernelPluginManagerTestBase {
protected $pluginManagerClass = PluginManager::class;
public static $modules = [
'purge_purger_test',
];
protected $annotationFields = [
'class',
'provider',
'id',
'label',
'configform',
'cooldown_time',
'description',
'multi_instance',
'types',
];
protected $plugins = [
'a',
'b',
'c',
'good',
'withform',
];
public function testDefinitions() : void {
$definitions = $this->pluginManager
->getDefinitions();
foreach ($this->plugins as $plugin_id) {
$this
->assertTrue(isset($definitions[$plugin_id]));
}
foreach ($definitions as $plugin_id => $md) {
$this
->assertTrue(in_array($plugin_id, $this->plugins));
}
foreach ($definitions as $plugin_id => $md) {
foreach ($md as $field => $value) {
$this
->assertTrue(in_array($field, $this->annotationFields));
}
foreach ($this->annotationFields as $field) {
$this
->assertTrue(isset($md[$field]));
}
}
}
}