function ControllerResolverTest::testGetArgumentsWithRouteMatchAndPsr7Request

Tests getArguments with a route match and a PSR-7 request.

@covers ::doGetArguments

@group legacy

File

core/tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php, line 254

Class

ControllerResolverTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Controller%21ControllerResolver.php/class/ControllerResolver/8.9.x" title="ControllerResolver to enhance controllers beyond Symfony&#039;s basic handling." class="local">\Drupal\Core\Controller\ControllerResolver</a> @group Controller

Namespace

Drupal\Tests\Core\Controller

Code

public function testGetArgumentsWithRouteMatchAndPsr7Request() {
    if (!in_array('Symfony\\Component\\HttpKernel\\Controller\\ArgumentResolverInterface', class_implements('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolver'))) {
        $this->markTestSkipped("Do not test ::getArguments() method when it is not implemented by Symfony's ControllerResolver.");
    }
    $request = Request::create('/test');
    $mock_controller = new MockControllerPsr7();
    $arguments = $this->controllerResolver
        ->getArguments($request, [
        $mock_controller,
        'getControllerWithRequestAndRouteMatch',
    ]);
    $this->assertEquals(RouteMatch::createFromRequest($request), $arguments[0], 'Ensure that the route match object is passed along as well');
    $this->assertInstanceOf('Psr\\Http\\Message\\ServerRequestInterface', $arguments[1], 'Ensure that the PSR-7 object is passed along as well');
}

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