public function ReflectionFactoryTest::testGetInstanceArguments in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Component/Plugin/Factory/ReflectionFactoryTest.php \Drupal\Tests\Component\Plugin\Factory\ReflectionFactoryTest::testGetInstanceArguments()
@covers ::getInstanceArguments @dataProvider providerGetInstanceArguments
File
- core/
tests/ Drupal/ Tests/ Component/ Plugin/ Factory/ ReflectionFactoryTest.php, line 113 - Contains \Drupal\Tests\Component\Plugin\Factory\ReflectionFactoryTest.
Class
- ReflectionFactoryTest
- @group Plugin @coversDefaultClass \Drupal\Component\Plugin\Factory\ReflectionFactory
Namespace
Drupal\Tests\Component\Plugin\FactoryCode
public function testGetInstanceArguments($expected, $reflector_name, $plugin_id, $plugin_definition, $configuration) {
$reflection_factory = $this
->getMockBuilder('Drupal\\Component\\Plugin\\Factory\\ReflectionFactory')
->disableOriginalConstructor()
->getMock();
$get_instance_arguments_ref = new \ReflectionMethod($reflection_factory, 'getInstanceArguments');
$get_instance_arguments_ref
->setAccessible(TRUE);
// Special case for plugin class without a constructor.
// getInstanceArguments() throws an exception if there's no constructor.
// This is not a documented behavior of getInstanceArguments(), but allows
// us to use one data set for this test method as well as
// testCreateInstance().
if ($plugin_id == 'arguments_no_constructor') {
$this
->expectException('\\ReflectionException');
}
// Finally invoke getInstanceArguments() on our mocked factory.
$ref = new \ReflectionClass($reflector_name);
$result = $get_instance_arguments_ref
->invoke($reflection_factory, $ref, $plugin_id, $plugin_definition, $configuration);
$this
->assertEquals($expected, $result);
}