You are here

public function ModerationDashboardTest::testModerationDashboardLoads in Moderation Dashboard 2.0.x

Same name and namespace in other branches
  1. 8 tests/src/Functional/ModerationDashboardTest.php \Drupal\Tests\moderation_dashboard\Functional\ModerationDashboardTest::testModerationDashboardLoads()

Tests that the Moderation Dashboard loads as expected.

Throws

\Behat\Mink\Exception\ExpectationException

\Drupal\Core\Entity\EntityStorageException

File

tests/src/Functional/ModerationDashboardTest.php, line 28

Class

ModerationDashboardTest
Contains tests for the Moderation Dashboard module.

Namespace

Drupal\Tests\moderation_dashboard\Functional

Code

public function testModerationDashboardLoads() {

  // Deny access for Anonymous users.
  $this
    ->drupalGet('/user/' . $this->user
    ->id() . '/moderation-dashboard');
  $this
    ->assertSession()
    ->statusCodeEquals(403);

  // Deny access if no Content Type has moderation enabled.
  $this
    ->drupalLogin($this->user);
  $this
    ->drupalGet('/user/' . $this->user
    ->id() . '/moderation-dashboard');

  // @todo not sure if this test is needed for layout builder.
  //   $this->assertSession()->statusCodeEquals(403);
  // Deny access if no moderated Node has been created (fresh install).
  $this
    ->drupalCreateContentType([
    'type' => 'page',
  ]);
  $this
    ->drupalGet('/user/' . $this->user
    ->id() . '/moderation-dashboard');
  $this
    ->assertSession()
    ->statusCodeEquals(200);

  // Allow access if everything looks good.
  $this->editorialWorkflow
    ->getTypePlugin()
    ->addEntityTypeAndBundle('node', 'page');
  $this->editorialWorkflow
    ->save();
  $this
    ->drupalCreateNode([
    'type' => 'page',
    'title' => 'Test title first revision',
    'moderation_state' => 'published',
  ]);
  $this
    ->drupalGet('/user/' . $this->user
    ->id() . '/moderation-dashboard');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
}