public function StaticDiscoveryDecoratorTest::testCall in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Component/Plugin/Discovery/StaticDiscoveryDecoratorTest.php \Drupal\Tests\Component\Plugin\Discovery\StaticDiscoveryDecoratorTest::testCall()
@covers ::__call @dataProvider providerCall
File
- core/
tests/ Drupal/ Tests/ Component/ Plugin/ Discovery/ StaticDiscoveryDecoratorTest.php, line 204 - Contains \Drupal\Tests\Component\Plugin\Discovery\StaticDiscoveryDecoratorTest.
Class
- StaticDiscoveryDecoratorTest
- @group Plugin @coversDefaultClass Drupal\Component\Plugin\Discovery\StaticDiscoveryDecorator
Namespace
Drupal\Tests\Component\Plugin\DiscoveryCode
public function testCall($method, $args) {
// Mock a decorated object.
$mock_decorated = $this
->getMockBuilder('Drupal\\Component\\Plugin\\Discovery\\DiscoveryInterface')
->setMethods(array(
$method,
))
->getMockForAbstractClass();
// Our mocked method will return any arguments sent to it.
$mock_decorated
->expects($this
->once())
->method($method)
->willReturnCallback(function () {
return \func_get_args();
});
// Create a mock decorator.
$mock_decorator = $this
->getMockBuilder('Drupal\\Component\\Plugin\\Discovery\\StaticDiscoveryDecorator')
->disableOriginalConstructor()
->getMock();
// Poke the decorated object into our decorator.
$ref_decorated = new \ReflectionProperty($mock_decorator, 'decorated');
$ref_decorated
->setAccessible(TRUE);
$ref_decorated
->setValue($mock_decorator, $mock_decorated);
// Exercise __call.
$this
->assertArrayEquals($args, \call_user_func_array(array(
$mock_decorated,
$method,
), $args));
}