function ArgumentsResolverTest::testGetArgumentOrder
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Component/Utility/ArgumentsResolverTest.php \Drupal\Tests\Component\Utility\ArgumentsResolverTest::testGetArgumentOrder()
- 10 core/tests/Drupal/Tests/Component/Utility/ArgumentsResolverTest.php \Drupal\Tests\Component\Utility\ArgumentsResolverTest::testGetArgumentOrder()
- 11.x core/tests/Drupal/Tests/Component/Utility/ArgumentsResolverTest.php \Drupal\Tests\Component\Utility\ArgumentsResolverTest::testGetArgumentOrder()
Tests getArgument() with a Route, Request, and Account object.
File
-
core/
tests/ Drupal/ Tests/ Component/ Utility/ ArgumentsResolverTest.php, line 98
Class
- ArgumentsResolverTest
- @coversDefaultClass \Drupal\Component\Utility\ArgumentsResolver @group Access
Namespace
Drupal\Tests\Component\UtilityCode
public function testGetArgumentOrder() {
$a1 = $this->getMockBuilder('\\Drupal\\Tests\\Component\\Utility\\Test1Interface')
->getMock();
$a2 = $this->getMockBuilder('\\Drupal\\Tests\\Component\\Utility\\TestClass')
->getMock();
$a3 = $this->getMockBuilder('\\Drupal\\Tests\\Component\\Utility\\Test2Interface')
->getMock();
$objects = [
't1' => $a1,
'tc' => $a2,
];
$wildcards = [
$a3,
];
$resolver = new ArgumentsResolver([], $objects, $wildcards);
$callable = function (Test1Interface $t1, TestClass $tc, Test2Interface $t2) {
};
$arguments = $resolver->getArguments($callable);
$this->assertSame([
$a1,
$a2,
$a3,
], $arguments);
// Test again, but with the arguments in a different order.
$callable = function (Test2Interface $t2, TestClass $tc, Test1Interface $t1) {
};
$arguments = $resolver->getArguments($callable);
$this->assertSame([
$a3,
$a2,
$a1,
], $arguments);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.