class CustomDirectoryAnnotatedClassDiscoveryTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Plugin/Discovery/CustomDirectoryAnnotatedClassDiscoveryTest.php \Drupal\KernelTests\Core\Plugin\Discovery\CustomDirectoryAnnotatedClassDiscoveryTest
- 10 core/tests/Drupal/KernelTests/Core/Plugin/Discovery/CustomDirectoryAnnotatedClassDiscoveryTest.php \Drupal\KernelTests\Core\Plugin\Discovery\CustomDirectoryAnnotatedClassDiscoveryTest
- 8.9.x core/tests/Drupal/KernelTests/Core/Plugin/Discovery/CustomDirectoryAnnotatedClassDiscoveryTest.php \Drupal\KernelTests\Core\Plugin\Discovery\CustomDirectoryAnnotatedClassDiscoveryTest
Tests discovery of annotated plugins in a custom directory.
@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\CustomDirectoryAnnotatedClassDiscoveryTest extends \Drupal\KernelTests\Core\Plugin\Discovery\DiscoveryTestBase
- class \Drupal\KernelTests\Core\Plugin\Discovery\DiscoveryTestBase extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of CustomDirectoryAnnotatedClassDiscoveryTest
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Plugin/ Discovery/ CustomDirectoryAnnotatedClassDiscoveryTest.php, line 13
Namespace
Drupal\KernelTests\Core\Plugin\DiscoveryView source
class CustomDirectoryAnnotatedClassDiscoveryTest extends DiscoveryTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->expectedDefinitions = [
'custom_example_1' => [
'id' => 'custom_example_1',
'custom' => 'Tim',
'class' => 'Drupal\\plugin_test\\CustomDirectoryExample1',
'provider' => 'plugin_test',
],
'custom_example_2' => [
'id' => 'custom_example_2',
'custom' => 'Meghan',
'class' => 'Drupal\\plugin_test\\CustomDirectoryExample2',
'provider' => 'plugin_test',
],
'apple' => [
'id' => 'apple',
'label' => 'Apple',
'color' => 'green',
'class' => 'Drupal\\plugin_test\\Plugin\\plugin_test\\fruit\\Apple',
'provider' => 'plugin_test',
],
'banana' => [
'id' => 'banana',
'label' => 'Banana',
'color' => 'yellow',
'uses' => [
'bread' => new TranslatableMarkup('Banana bread'),
'loaf' => [
'singular' => '@count loaf',
'plural' => '@count loaves',
'context' => NULL,
],
],
'class' => 'Drupal\\plugin_test\\Plugin\\plugin_test\\fruit\\Banana',
'provider' => 'plugin_test',
],
'cherry' => [
'id' => 'cherry',
'label' => 'Cherry',
'color' => 'red',
'class' => 'Drupal\\plugin_test\\Plugin\\plugin_test\\fruit\\Cherry',
'provider' => 'plugin_test',
],
'kale' => [
'id' => 'kale',
'label' => 'Kale',
'color' => 'green',
'class' => 'Drupal\\plugin_test\\Plugin\\plugin_test\\fruit\\Kale',
'provider' => 'plugin_test',
],
'orange' => [
'id' => 'orange',
'label' => 'Orange',
'color' => 'orange',
'class' => 'Drupal\\plugin_test\\Plugin\\plugin_test\\fruit\\Orange',
'provider' => 'plugin_test',
],
'extending_non_installed_class' => [
'id' => 'extending_non_installed_class',
'label' => 'A plugin whose class is extending from a non-installed module class',
'color' => 'pink',
'class' => 'Drupal\\plugin_test\\Plugin\\plugin_test\\fruit\\ExtendingNonInstalledClass',
'provider' => 'plugin_test',
],
];
$base_directory = $this->root . '/core/modules/system/tests/modules/plugin_test/src';
$namespaces = new \ArrayObject([
'Drupal\\plugin_test' => $base_directory,
]);
$this->discovery = new AnnotatedClassDiscovery('', $namespaces);
$empty_namespaces = new \ArrayObject();
$this->emptyDiscovery = new AnnotatedClassDiscovery('', $empty_namespaces);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.