You are here

public function ModerationDashboardPermissionTest::testCanNotViewOwnDashboard in Moderation Dashboard 8

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

Tests that a user can't view their dashboard without permission.

File

tests/src/Functional/ModerationDashboardPermissionTest.php, line 89

Class

ModerationDashboardPermissionTest
Tests moderation dashboard permissions.

Namespace

Drupal\Tests\moderation_dashboard\Functional

Code

public function testCanNotViewOwnDashboard() {
  foreach ($this->canNotViewOwnDashboardCases as $i => $testCase) {
    $user = $this
      ->createUser($testCase['permissions']);
    $this
      ->drupalLogin($user);
    $this
      ->drupalGet("/user/{$user->id()}/moderation/dashboard");
    $status_code = $this
      ->getSession()
      ->getStatusCode();
    $message = "#{$i}: expected 403, got {$status_code}.";
    $this
      ->assertEquals(403, $status_code, $message);
  }
}