You are here

public function ModerationDashboardPermissionTest::testCanNotViewOtherDashboard 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::testCanNotViewOtherDashboard()

Tests that a user can't view other dashboards without permission.

File

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

Class

ModerationDashboardPermissionTest
Tests moderation dashboard permissions.

Namespace

Drupal\Tests\moderation_dashboard\Functional

Code

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