You are here

public function ModerationSidebarTest::testToolbarItem in Moderation Sidebar 8

Test toolbar item appears.

File

tests/src/Functional/ModerationSidebarTest.php, line 57

Class

ModerationSidebarTest
Tests basic behaviour of Moderation Sidebar using a test entity.

Namespace

Drupal\Tests\moderation_sidebar\Functional

Code

public function testToolbarItem() {
  $entity = EntityTestMulRevPub::create([
    'name' => $this
      ->randomMachineName(),
  ]);
  $entity
    ->save();
  $this
    ->drupalGet($entity
    ->toUrl());

  // Make sure the button is where we expect it.
  $toolbarItem = $this
    ->assertSession()
    ->elementExists('css', '.moderation-sidebar-toolbar-tab a');

  // Make sure the button has the right attributes.
  $url = Url::fromRoute('moderation_sidebar.sidebar_latest', [
    'entity_type' => $entity
      ->getEntityTypeId(),
    'entity' => $entity
      ->id(),
  ]);
  $this
    ->assertEquals($url
    ->toString(), $toolbarItem
    ->getAttribute('href'));
  $this
    ->assertEquals('Tasks', $toolbarItem
    ->getText());
}