You are here

public function ControllerResolverTest::testGetArgumentsWithRouteMatchAndPsr7Request in Drupal 8

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
Contains \Drupal\Tests\Core\Controller\ControllerResolverTest.

Class

ControllerResolverTest
@coversDefaultClass \Drupal\Core\Controller\ControllerResolver @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');
}