function AttributeBridgeDecoratorTest::testGetDefinitions
Same name in other branches
- 11.x core/tests/Drupal/Tests/Component/Plugin/Discovery/AttributeBridgeDecoratorTest.php \Drupal\Tests\Component\Plugin\Discovery\AttributeBridgeDecoratorTest::testGetDefinitions()
@covers ::getDefinitions
File
-
core/
tests/ Drupal/ Tests/ Component/ Plugin/ Discovery/ AttributeBridgeDecoratorTest.php, line 22
Class
- AttributeBridgeDecoratorTest
- @coversDefaultClass \Drupal\Component\Annotation\Plugin\Discovery\AnnotationBridgeDecorator @group Plugin
Namespace
Drupal\Tests\Component\Plugin\DiscoveryCode
public function testGetDefinitions() : void {
// Normally the attribute classes would be autoloaded.
include_once __DIR__ . '/../../../../../fixtures/plugins/CustomPlugin.php';
include_once __DIR__ . '/../../../../../fixtures/plugins/Plugin/PluginNamespace/AttributeDiscoveryTest1.php';
$definitions = [];
$definitions['object'] = new ObjectDefinition([
'id' => 'foo',
]);
$definitions['array'] = [
'id' => 'bar',
'class' => 'com\\example\\PluginNamespace\\AttributeDiscoveryTest1',
];
$discovery = $this->createMock(DiscoveryInterface::class);
$discovery->expects($this->any())
->method('getDefinitions')
->willReturn($definitions);
$decorator = new AttributeBridgeDecorator($discovery, TestAttribute::class);
$expected = [
'object' => new ObjectDefinition([
'id' => 'foo',
]),
'array' => (new ObjectDefinition([
'id' => 'bar',
]))->setClass('com\\example\\PluginNamespace\\AttributeDiscoveryTest1'),
];
$this->assertEquals($expected, $decorator->getDefinitions());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.