public function PanelsEverywhereRouteSubscriberTest::testSubscriberDoesNothingForNoVariantRouteInCollection in Panels Everywhere 8.4
Tests onAlterRoutes.
Specifically that PanelsEverywhereRouteSubscriber does nothing if the corresponding route for the 'panels_everywhere_variant' is not in the route collection.
File
- tests/
src/ Unit/ Routing/ PanelsEverywhereRouteSubscriberTest.php, line 156
Class
- PanelsEverywhereRouteSubscriberTest
- @coversDefaultClass \Drupal\panels_everywhere\Routing\PanelsEverywhereRouteSubscriber @group panels_everywhere
Namespace
Drupal\Tests\panels_everywhere\Unit\RoutingCode
public function testSubscriberDoesNothingForNoVariantRouteInCollection() {
$page_id = 'some_page_id';
$variant_id = 'some_variant_id';
$pageVariant = $this
->prophesize(PageVariantInterface::class);
$pageVariant
->id()
->willReturn($variant_id);
$pageVariant
->getVariantPluginId()
->willReturn('panels_everywhere_variant');
$pageEntity = $this
->prophesize(PageInterface::class);
$pageEntity
->id()
->willReturn($page_id);
$pageEntity
->status()
->willReturn(TRUE);
$pageEntity
->getVariants()
->willReturn([
'some_variant_id' => $pageVariant
->reveal(),
]);
$pageStorage = $this
->prophesize(EntityStorageInterface::class);
$pageStorage
->loadMultiple()
->willReturn([
$pageEntity
->reveal(),
]);
$entityTypeManager = $this
->prophesize(EntityTypeManagerInterface::class);
$entityTypeManager
->getStorage('page')
->willReturn($pageStorage
->reveal());
$cacheTagsInvalidator = $this
->prophesize(CacheTagsInvalidatorInterface::class);
$routeCollection = new RouteCollection();
$event = new RouteBuildEvent($routeCollection);
// When.
$subscriber = new PanelsEverywhereRouteSubscriber($entityTypeManager
->reveal(), $cacheTagsInvalidator
->reveal());
$subscriber
->onAlterRoutes($event);
// Then.
self::assertEmpty($routeCollection
->all());
}