class AnnotatedClassDiscoveryTest
Same name in this branch
- 11.x core/tests/Drupal/KernelTests/Core/Plugin/Discovery/AnnotatedClassDiscoveryTest.php \Drupal\KernelTests\Core\Plugin\Discovery\AnnotatedClassDiscoveryTest
- 11.x core/tests/Drupal/Tests/Component/Plugin/Discovery/AnnotatedClassDiscoveryTest.php \Drupal\Tests\Component\Plugin\Discovery\AnnotatedClassDiscoveryTest
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Plugin/Discovery/AnnotatedClassDiscoveryTest.php \Drupal\KernelTests\Core\Plugin\Discovery\AnnotatedClassDiscoveryTest
- 9 core/tests/Drupal/Tests/Component/Annotation/AnnotatedClassDiscoveryTest.php \Drupal\Tests\Component\Annotation\AnnotatedClassDiscoveryTest
- 9 core/tests/Drupal/Tests/Component/Plugin/Discovery/AnnotatedClassDiscoveryTest.php \Drupal\Tests\Component\Plugin\Discovery\AnnotatedClassDiscoveryTest
- 8.9.x core/tests/Drupal/KernelTests/Core/Plugin/Discovery/AnnotatedClassDiscoveryTest.php \Drupal\KernelTests\Core\Plugin\Discovery\AnnotatedClassDiscoveryTest
- 8.9.x core/tests/Drupal/Tests/Component/Annotation/AnnotatedClassDiscoveryTest.php \Drupal\Tests\Component\Annotation\AnnotatedClassDiscoveryTest
- 8.9.x core/tests/Drupal/Tests/Component/Plugin/Discovery/AnnotatedClassDiscoveryTest.php \Drupal\Tests\Component\Plugin\Discovery\AnnotatedClassDiscoveryTest
- 10 core/tests/Drupal/KernelTests/Core/Plugin/Discovery/AnnotatedClassDiscoveryTest.php \Drupal\KernelTests\Core\Plugin\Discovery\AnnotatedClassDiscoveryTest
- 10 core/tests/Drupal/Tests/Component/Annotation/AnnotatedClassDiscoveryTest.php \Drupal\Tests\Component\Annotation\AnnotatedClassDiscoveryTest
- 10 core/tests/Drupal/Tests/Component/Plugin/Discovery/AnnotatedClassDiscoveryTest.php \Drupal\Tests\Component\Plugin\Discovery\AnnotatedClassDiscoveryTest
@coversDefaultClass \Drupal\Component\Annotation\Plugin\Discovery\AnnotatedClassDiscovery @group Annotation @runTestsInSeparateProcesses
Hierarchy
- class \Drupal\Tests\Component\Annotation\AnnotatedClassDiscoveryTest extends \PHPUnit\Framework\TestCase
Expanded class hierarchy of AnnotatedClassDiscoveryTest
File
-
core/
tests/ Drupal/ Tests/ Component/ Annotation/ AnnotatedClassDiscoveryTest.php, line 17
Namespace
Drupal\Tests\Component\AnnotationView source
class AnnotatedClassDiscoveryTest extends TestCase {
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
// Ensure the file cache is disabled.
FileCacheFactory::setConfiguration([
FileCacheFactory::DISABLE_CACHE => TRUE,
]);
// Ensure that FileCacheFactory has a prefix.
FileCacheFactory::setPrefix('prefix');
}
/**
* @covers ::__construct
* @covers ::getPluginNamespaces
*/
public function testGetPluginNamespaces() : void {
$discovery = new AnnotatedClassDiscovery([
'com/example' => [
__DIR__,
],
]);
$reflection = new \ReflectionMethod($discovery, 'getPluginNamespaces');
$result = $reflection->invoke($discovery);
$this->assertEquals([
'com/example' => [
__DIR__,
],
], $result);
}
/**
* @covers ::getDefinitions
* @covers ::prepareAnnotationDefinition
* @covers ::getAnnotationReader
*/
public function testGetDefinitions() : void {
$discovery = new AnnotatedClassDiscovery([
'com\\example' => [
__DIR__ . '/Fixtures',
],
]);
$this->assertEquals([
'discovery_test_1' => [
'id' => 'discovery_test_1',
'class' => 'com\\example\\PluginNamespace\\DiscoveryTest1',
],
], $discovery->getDefinitions());
$custom_annotation_discovery = new AnnotatedClassDiscovery([
'com\\example' => [
__DIR__ . '/Fixtures',
],
], CustomPlugin::class, [
'Drupal\\Tests\\Component\\Annotation',
]);
$this->assertEquals([
'discovery_test_1' => [
'id' => 'discovery_test_1',
'class' => 'com\\example\\PluginNamespace\\DiscoveryTest1',
'title' => 'Discovery test plugin',
],
], $custom_annotation_discovery->getDefinitions());
$empty_discovery = new AnnotatedClassDiscovery([
'com\\example' => [
__DIR__ . '/Fixtures',
],
], CustomPlugin2::class, [
'Drupal\\Tests\\Component\\Annotation',
]);
$this->assertEquals([], $empty_discovery->getDefinitions());
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
AnnotatedClassDiscoveryTest::setUp | protected | function | |
AnnotatedClassDiscoveryTest::testGetDefinitions | public | function | @covers ::getDefinitions @covers ::prepareAnnotationDefinition @covers ::getAnnotationReader |
AnnotatedClassDiscoveryTest::testGetPluginNamespaces | public | function | @covers ::__construct @covers ::getPluginNamespaces |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.