public function PanelsEverywhereRouteSubscriberTest::testSubscriberDoesNothingForNoPanelsEveryWhereVariantOnPageEntity in Panels Everywhere 8.4
Tests onAlterRoutes.
Specifically that PanelsEverywhereRouteSubscriber does nothing if there are no variants of plugin-id 'panels_everywhere_variant' on page entity.
File
- tests/
src/ Unit/ Routing/ PanelsEverywhereRouteSubscriberTest.php, line 121
Class
- PanelsEverywhereRouteSubscriberTest
- @coversDefaultClass \Drupal\panels_everywhere\Routing\PanelsEverywhereRouteSubscriber @group panels_everywhere
Namespace
Drupal\Tests\panels_everywhere\Unit\RoutingCode
public function testSubscriberDoesNothingForNoPanelsEveryWhereVariantOnPageEntity() {
$pageVariant = $this
->prophesize(PageVariantInterface::class);
$pageVariant
->getVariantPluginId()
->willReturn('not_panels_everywhere_variant');
$pageEntity = $this
->prophesize(PageInterface::class);
$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());
}