function ReflectionFactoryTest::testGetInstanceArguments
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Component/Plugin/Factory/ReflectionFactoryTest.php \Drupal\Tests\Component\Plugin\Factory\ReflectionFactoryTest::testGetInstanceArguments()
- 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()
@covers ::getInstanceArguments @dataProvider providerGetInstanceArguments
File
-
core/
tests/ Drupal/ Tests/ Component/ Plugin/ Factory/ ReflectionFactoryTest.php, line 108
Class
- ReflectionFactoryTest
- @group Plugin @coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Component%21Plugin%21Factory%21ReflectionFactory.php/class/ReflectionFactory/11.x" title="A plugin factory that maps instance configuration to constructor arguments." class="local">\Drupal\Component\Plugin\Factory\ReflectionFactory</a>
Namespace
Drupal\Tests\Component\Plugin\FactoryCode
public function testGetInstanceArguments($expected, $reflector_name, $plugin_id, $plugin_definition, $configuration) : void {
$reflection_factory = $this->getMockBuilder('Drupal\\Component\\Plugin\\Factory\\ReflectionFactory')
->disableOriginalConstructor()
->getMock();
$get_instance_arguments_ref = new \ReflectionMethod($reflection_factory, 'getInstanceArguments');
// 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.