
| Current Path : /var/www/html1/rrr/web/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : //var/www/html1/rrr/web/core/tests/Drupal/KernelTests/Core/Plugin/Discovery/StaticDiscoveryTest.php |
<?php
namespace Drupal\KernelTests\Core\Plugin\Discovery;
use Drupal\Component\Plugin\Discovery\StaticDiscovery;
/**
* Tests that plugins using static discovery are correctly discovered.
*
* @group Plugin
*/
class StaticDiscoveryTest extends DiscoveryTestBase {
protected function setUp(): void {
parent::setUp();
$this->expectedDefinitions = [
'apple' => [
'label' => 'Apple',
'color' => 'green',
],
'cherry' => [
'label' => 'Cherry',
'color' => 'red',
],
'orange' => [
'label' => 'Orange',
'color' => 'orange',
],
];
// Instead of registering the empty discovery component first and then
// setting the plugin definitions, we set them first and then delete them
// again. This implicitly tests StaticDiscovery::deleteDefinition() (in
// addition to StaticDiscovery::setDefinition() which we need to use
// anyway).
$discovery = new StaticDiscovery();
foreach ($this->expectedDefinitions as $plugin_id => $definition) {
$discovery->setDefinition($plugin_id, $definition);
}
$this->discovery = clone $discovery;
foreach ($this->expectedDefinitions as $plugin_id => $definition) {
$discovery->deleteDefinition($plugin_id);
}
$this->emptyDiscovery = $discovery;
}
}