You are here

public function VariantRouteFilterTest::testFilterContextException in Page Manager 8

Same name and namespace in other branches
  1. 8.4 tests/src/Unit/VariantRouteFilterTest.php \Drupal\Tests\page_manager\Unit\VariantRouteFilterTest::testFilterContextException()

@covers ::filter @covers ::getVariantRouteName @covers ::checkPageVariantAccess

File

tests/src/Unit/VariantRouteFilterTest.php, line 108
Contains \Drupal\Tests\page_manager\Unit\VariantRouteFilterTest.

Class

VariantRouteFilterTest
@coversDefaultClass \Drupal\page_manager\Routing\VariantRouteFilter @group PageManager

Namespace

Drupal\Tests\page_manager\Unit

Code

public function testFilterContextException() {
  $route_collection = new RouteCollection();
  $request = new Request();
  $route = new Route('/path/with/{slug}', [
    'page_manager_page_variant' => 'a_variant',
  ]);
  $route_collection
    ->add('a_route', $route);
  $page_variant = $this
    ->prophesize(PageVariantInterface::class);
  $page_variant
    ->access('view')
    ->willThrow(new ContextException());
  $this->currentPath
    ->getPath($request)
    ->willReturn('');
  $this->pageVariantStorage
    ->load('a_variant')
    ->willReturn($page_variant
    ->reveal());
  $result = $this->routeFilter
    ->filter($route_collection, $request);
  $expected = [];
  $this
    ->assertSame($expected, $result
    ->all());
  $this
    ->assertSame([], $request->attributes
    ->all());
}