public function ModerationDashboardPermissionTest::testCanNotViewOtherDashboard in Moderation Dashboard 2.0.x
Same name and namespace in other branches
- 8 tests/src/Functional/ModerationDashboardPermissionTest.php \Drupal\Tests\moderation_dashboard\Functional\ModerationDashboardPermissionTest::testCanNotViewOtherDashboard()
Tests that a user can't view other dashboards without permission.
Throws
\Drupal\Core\Entity\EntityStorageException
File
- tests/
src/ Functional/ ModerationDashboardPermissionTest.php, line 245
Class
- ModerationDashboardPermissionTest
- Tests moderation dashboard permissions.
Namespace
Drupal\Tests\moderation_dashboard\FunctionalCode
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();
// @todo this was 403 but if the user has permission to view
// any moderation dashboard doesn't that include your own?
if ($user_a
->hasPermission('view any moderation dashboard')) {
$message = "#{$i}: expected 200, got {$status_code}.";
$this
->assertEquals(200, $status_code, $message);
}
else {
$message = "#{$i}: expected 403, got {$status_code}.";
$this
->assertEquals(403, $status_code, $message);
}
}
}