PluginTypeManagerTest.php in Plugin 8.2
File
tests/src/Kernel/PluginType/PluginTypeManagerTest.php
View source
<?php
namespace Drupal\Tests\plugin\Kernel\PluginType;
use Drupal\KernelTests\KernelTestBase;
use Drupal\plugin\PluginType\PluginTypeInterface;
class PluginTypeManagerTest extends KernelTestBase {
public static $modules = [
'system',
'plugin',
];
protected function setUp() : void {
$class_reflector = new \ReflectionClass(KernelTestBase::class);
$directory = $class_reflector
->getFileName();
while ($directory = dirname($directory)) {
$core_module_directory = $directory . '/core/modules';
if (file_exists($core_module_directory)) {
break;
}
}
$module_directories = array_keys(iterator_to_array(new \FilesystemIterator($core_module_directory)));
$module_names = array_map(function ($module_directory) {
return basename($module_directory);
}, $module_directories);
static::$modules = array_merge(static::$modules, $module_names);
parent::setUp();
}
public function testGetPluginTypes() {
$plugin_type_manager = $this->container
->get('plugin.plugin_type_manager');
$plugin_types = $plugin_type_manager
->getPluginTypes();
$this
->assertNotEmpty($plugin_types);
foreach ($plugin_types as $plugin_type) {
$this
->assertInstanceOf(PluginTypeInterface::class, $plugin_type);
}
}
}