You are here

protected function DeveloperAppPermissionTest::visitPage in Apigee Edge 8

Visits a single page.

Parameters

string $url: URL of the page to visit.

bool $access: True if there is access to the page.

string $rel: Entity route.

string $permission: Permission.

1 call to DeveloperAppPermissionTest::visitPage()
DeveloperAppPermissionTest::visitPages in tests/src/Functional/DeveloperAppPermissionTest.php
Visits pages as both "my" user and the other user.

File

tests/src/Functional/DeveloperAppPermissionTest.php, line 296

Class

DeveloperAppPermissionTest
Developer app entity permission test.

Namespace

Drupal\Tests\apigee_edge\Functional

Code

protected function visitPage(string $url, bool $access, string $rel, string $permission) {
  $this
    ->drupalGet($url);
  $code = $this
    ->getSession()
    ->getStatusCode();
  $username = 'unknown';
  if ($this->loggedInUser
    ->id() === $this->myAccount
    ->id()) {
    $username = 'my user';
  }
  elseif ($this->loggedInUser
    ->id() === $this->otherAccount
    ->id()) {
    $username = 'other user';
  }
  $debug = "{$url} ({$rel}) with \"{$permission}\" as {$username}";
  if ($access) {
    $this
      ->assertEquals(200, $code, "Couldn't access {$debug} when it should have. Got HTTP {$code}, expected HTTP 200.");
  }
  else {
    $this
      ->assertEquals(403, $code, "Could access {$debug} when it should not have. Got HTTP {$code}, expected HTTP 403.");
  }
}