function ReflectionFactoryTest::testGetInstanceArguments
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Component/Plugin/Factory/ReflectionFactoryTest.php \Drupal\Tests\Component\Plugin\Factory\ReflectionFactoryTest::testGetInstanceArguments()
- 10 core/tests/Drupal/Tests/Component/Plugin/Factory/ReflectionFactoryTest.php \Drupal\Tests\Component\Plugin\Factory\ReflectionFactoryTest::testGetInstanceArguments()
- 11.x 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
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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.