function AttributeBridgeDecoratorTest::testOtherMethod

Same name and namespace in other branches
  1. 10 core/tests/Drupal/Tests/Component/Plugin/Discovery/AttributeBridgeDecoratorTest.php \Drupal\Tests\Component\Plugin\Discovery\AttributeBridgeDecoratorTest::testOtherMethod()

Tests that the decorator of other methods works.

@covers ::__call

File

core/tests/Drupal/Tests/Component/Plugin/Discovery/AttributeBridgeDecoratorTest.php, line 52

Class

AttributeBridgeDecoratorTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Component%21Annotation%21Plugin%21Discovery%21AnnotationBridgeDecorator.php/class/AnnotationBridgeDecorator/11.x" title="Ensures that all definitions are run through the annotation process." class="local">\Drupal\Component\Annotation\Plugin\Discovery\AnnotationBridgeDecorator</a> @group Plugin

Namespace

Drupal\Tests\Component\Plugin\Discovery

Code

public function testOtherMethod() : void {
    // Normally the attribute classes would be autoloaded.
    include_once __DIR__ . '/../Attribute/Fixtures/CustomPlugin.php';
    include_once __DIR__ . '/../Attribute/Fixtures/Plugins/PluginNamespace/AttributeDiscoveryTest1.php';
    $discovery = $this->createMock(ExtendedDiscoveryInterface::class);
    $discovery->expects($this->exactly(2))
        ->method('otherMethod')
        ->willReturnCallback(fn($id) => $id === 'foo');
    $decorator = new AttributeBridgeDecorator($discovery, TestAttribute::class);
    $this->assertTrue($decorator->otherMethod('foo'));
    $this->assertFalse($decorator->otherMethod('bar'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.