function ArgumentsResolverTest::testGetArgumentRouteNoTypehintAndValue

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Component/Utility/ArgumentsResolverTest.php \Drupal\Tests\Component\Utility\ArgumentsResolverTest::testGetArgumentRouteNoTypehintAndValue()
  2. 10 core/tests/Drupal/Tests/Component/Utility/ArgumentsResolverTest.php \Drupal\Tests\Component\Utility\ArgumentsResolverTest::testGetArgumentRouteNoTypeHintAndValue()
  3. 11.x core/tests/Drupal/Tests/Component/Utility/ArgumentsResolverTest.php \Drupal\Tests\Component\Utility\ArgumentsResolverTest::testGetArgumentRouteNoTypeHintAndValue()

Tests getArgument() with a named parameter with no typehint and a value.

Without the typehint, passing a value to a named parameter will still receive the provided value.

File

core/tests/Drupal/Tests/Component/Utility/ArgumentsResolverTest.php, line 142

Class

ArgumentsResolverTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Component%21Utility%21ArgumentsResolver.php/class/ArgumentsResolver/8.9.x" title="Resolves the arguments to pass to a callable." class="local">\Drupal\Component\Utility\ArgumentsResolver</a> @group Access

Namespace

Drupal\Tests\Component\Utility

Code

public function testGetArgumentRouteNoTypehintAndValue() {
    $scalars = [
        'route' => 'foo',
    ];
    $resolver = new ArgumentsResolver($scalars, [], []);
    $callable = function ($route) {
    };
    $arguments = $resolver->getArguments($callable);
    $this->assertSame([
        'foo',
    ], $arguments);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.