You are here

protected function TeamApiProductAccessTest::checkEntityAccess in Apigee Edge 8

Checks entity operation access on all API products.

Parameters

array $should_have_access: Associative array where keys are API product visibilities and values are entity operations that the given user should have access.

\Drupal\Core\Session\AccountInterface $account: The user account whose access should be checked.

1 call to TeamApiProductAccessTest::checkEntityAccess()
TeamApiProductAccessTest::testTeamApiProductAccess in modules/apigee_edge_teams/tests/src/Functional/TeamApiProductAccessTest.php
Tests team API product access.

File

modules/apigee_edge_teams/tests/src/Functional/TeamApiProductAccessTest.php, line 288

Class

TeamApiProductAccessTest
Team-level API product access test.

Namespace

Drupal\Tests\apigee_edge_teams\Functional

Code

protected function checkEntityAccess(array $should_have_access, AccountInterface $account) {
  foreach (self::SUPPORTED_OPERATIONS as $operation) {
    foreach (self::VISIBILITIES as $visibility) {
      $expected_to_be_true = $should_have_access[$visibility] ?? [];
      $has_access = $this->apiProducts[$visibility]
        ->access($operation, $account);
      if (in_array($operation, $expected_to_be_true)) {
        $this
          ->assertTrue($has_access, "{$account->getDisplayName()} should have {$operation} operation access to {$this->apiProducts[$visibility]->label()} API product.");
      }
      else {
        $this
          ->assertFalse($has_access, "{$account->getDisplayName()} should not have {$operation} operation access to {$this->apiProducts[$visibility]->label()} API product.");
      }
    }
  }
}