You are here

public function IngredientAccessTest::assertIngredientAccess in Recipe 8.2

Asserts that Ingredient access correctly grants or denies access.

Parameters

array $ops: An associative array of the expected Ingredient access grants for the ingredient and account, with each key as the name of an operation (e.g. 'view', 'delete') and each value a Boolean indicating whether access to that operation should be granted.

\Drupal\ingredient\IngredientInterface $ingredient: The ingredient object to check.

\Drupal\Core\Session\AccountInterface $account: The user account for which to check access.

1 call to IngredientAccessTest::assertIngredientAccess()
IngredientAccessTest::testIngredientAccess in modules/ingredient/tests/src/Kernel/IngredientAccessTest.php
Test Ingredient access by permission.

File

modules/ingredient/tests/src/Kernel/IngredientAccessTest.php, line 108

Class

IngredientAccessTest
@coversDefaultClass \Drupal\ingredient\IngredientAccessControlHandler

Namespace

Drupal\Tests\ingredient\Kernel

Code

public function assertIngredientAccess(array $ops, IngredientInterface $ingredient, AccountInterface $account) {
  foreach ($ops as $op => $result) {
    $this
      ->assertEquals($result, $this->accessHandler
      ->access($ingredient, $op, $account), $this
      ->accessAssertMessage($op, $result, $ingredient
      ->language()
      ->getId()));
  }
}