class StaticDiscoveryTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Plugin/Discovery/StaticDiscoveryTest.php \Drupal\KernelTests\Core\Plugin\Discovery\StaticDiscoveryTest
- 10 core/tests/Drupal/KernelTests/Core/Plugin/Discovery/StaticDiscoveryTest.php \Drupal\KernelTests\Core\Plugin\Discovery\StaticDiscoveryTest
- 8.9.x core/tests/Drupal/KernelTests/Core/Plugin/Discovery/StaticDiscoveryTest.php \Drupal\KernelTests\Core\Plugin\Discovery\StaticDiscoveryTest
Tests that plugins using static discovery are correctly discovered.
@group Plugin
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\Core\Plugin\Discovery\DiscoveryTestBase extends \Drupal\KernelTests\KernelTestBase
- class \Drupal\KernelTests\Core\Plugin\Discovery\StaticDiscoveryTest extends \Drupal\KernelTests\Core\Plugin\Discovery\DiscoveryTestBase
- class \Drupal\KernelTests\Core\Plugin\Discovery\DiscoveryTestBase extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of StaticDiscoveryTest
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Plugin/ Discovery/ StaticDiscoveryTest.php, line 12
Namespace
Drupal\KernelTests\Core\Plugin\DiscoveryView source
class StaticDiscoveryTest extends DiscoveryTestBase {
/**
* {@inheritdoc}
*/
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;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.