function PageContextTest::testNoValidBadge

Tests the behavior of a plugin with no valid badge present.

File

core/modules/navigation/tests/src/Unit/PageContextTest.php, line 262

Class

PageContextTest
Tests the PageContext Top Bar item build output.

Namespace

Drupal\Tests\navigation\Unit

Code

public function testNoValidBadge() : void {
  $entity = $this->prophesize(ContentEntityInterface::class);
  $entity->label()
    ->willReturn('Simple Title');
  $route_helper = $this->prophesize(EntityRouteHelper::class);
  $route_helper->getContentEntityFromRoute()
    ->willReturn($entity->reveal());
  $entity_repository = $this->prophesize(EntityRepositoryInterface::class)
    ->reveal();
  $plugin = new PageContext([], 'page_context', [], $route_helper->reveal(), $entity_repository, NULL);
  $build = $plugin->build();
  $this->assertSame('Simple Title', $build[0]['#slots']['content']);
  // Only one component (title) should be present.
  $this->assertArrayNotHasKey(1, $build);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.