You are here

public function ArgumentsResolverTest::testGetArgumentOrder in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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
Contains \Drupal\Tests\Component\Utility\ArgumentsResolverTest.

Class

ArgumentsResolverTest
@coversDefaultClass \Drupal\Component\Utility\ArgumentsResolver @group Access

Namespace

Drupal\Tests\Component\Utility

Code

public function testGetArgumentOrder() {
  $a1 = $this
    ->getMock('\\Drupal\\Tests\\Component\\Utility\\TestInterface1');
  $a2 = $this
    ->getMock('\\Drupal\\Tests\\Component\\Utility\\TestClass');
  $a3 = $this
    ->getMock('\\Drupal\\Tests\\Component\\Utility\\TestInterface2');
  $objects = [
    't1' => $a1,
    'tc' => $a2,
  ];
  $wildcards = [
    $a3,
  ];
  $resolver = new ArgumentsResolver([], $objects, $wildcards);
  $callable = function (TestInterface1 $t1, TestClass $tc, TestInterface2 $t2) {
  };
  $arguments = $resolver
    ->getArguments($callable);
  $this
    ->assertSame([
    $a1,
    $a2,
    $a3,
  ], $arguments);

  // Test again, but with the arguments in a different order.
  $callable = function (TestInterface2 $t2, TestClass $tc, TestInterface1 $t1) {
  };
  $arguments = $resolver
    ->getArguments($callable);
  $this
    ->assertSame([
    $a3,
    $a2,
    $a1,
  ], $arguments);
}