function AttributeBridgeDecoratorTest::testOtherMethod

Same name and namespace in other branches
  1. 11.x 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 \Drupal\Component\Annotation\Plugin\Discovery\AnnotationBridgeDecorator[[api-linebreak]] @group Plugin

Namespace

Drupal\Tests\Component\Plugin\Discovery

Code

public function testOtherMethod() : void {
  // Normally the attribute classes would be autoloaded.
  include_once __DIR__ . '/../../../../../fixtures/plugins/CustomPlugin.php';
  include_once __DIR__ . '/../../../../../fixtures/plugins/Plugin/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.