You are here

public function ModerationDashboardTest::testModerationDashboardLoads in Moderation Dashboard 8

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

Tests that the Moderation Dashboard loads as expected.

File

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

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');
  $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(403);

  // 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);
}