View source
<?php
namespace Drupal\Tests\purge\Kernel\DiagnosticCheck;
use Drupal\purge\Plugin\Purge\DiagnosticCheck\PluginManager;
use Drupal\Tests\purge\Kernel\KernelPluginManagerTestBase;
class PluginManagerTest extends KernelPluginManagerTestBase {
protected $pluginManagerClass = PluginManager::class;
public static $modules = [
'purge_check_test',
'purge_check_error_test',
'purge_check_warning_test',
];
protected $annotationFields = [
'provider',
'class',
'id',
'title',
'description',
'dependent_purger_plugins',
'dependent_queue_plugins',
];
protected $plugins = [
'capacity',
'maxage',
'memoryqueuewarning',
'page_cache',
'processorsavailable',
'purgersavailable',
'queuersavailable',
'alwayswarning',
'alwayserror',
'alwaysinfo',
'alwaysok',
'purgerwarning',
'queuewarning',
'queue_size',
];
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]));
}
}
}
}