You are here

public function PageManagerRoutingTest::testRouteFilter in Page Manager 8

Same name and namespace in other branches
  1. 8.4 tests/src/Kernel/PageManagerRoutingTest.php \Drupal\Tests\page_manager\Kernel\PageManagerRoutingTest::testRouteFilter()

@covers \Drupal\page_manager\Routing\VariantRouteFilter

@dataProvider providerTestRouteFilter

File

tests/src/Kernel/PageManagerRoutingTest.php, line 103

Class

PageManagerRoutingTest
Integration test for Page Manager routing.

Namespace

Drupal\Tests\page_manager\Kernel

Code

public function testRouteFilter($path, $expected) {
  $request = Request::create($path);
  try {
    $parameters = $this->container
      ->get('router')
      ->matchRequest($request);
  } catch (\Exception $e) {
    $parameters = [];
  }
  if ($expected) {
    $this
      ->assertArrayHasKey(RouteObjectInterface::ROUTE_NAME, $parameters);
    $this
      ->assertSame($expected, $parameters[RouteObjectInterface::ROUTE_NAME]);
  }
  else {
    $this
      ->assertEmpty($parameters);
  }
}