You are here

protected function ProtectionRuleBypassTest::doRoleProtectionBypassTest in User protect 8

Tests if bypassing a certain role protection is respected.

Parameters

string $plugin: The name of the UserProtection plugin.

string $operation: The access operation to check.

5 calls to ProtectionRuleBypassTest::doRoleProtectionBypassTest()
ProtectionRuleBypassTest::testRoleDeleteProtectionBypass in tests/src/Kernel/ProtectionRuleBypassTest.php
Tests if bypassing role delete protection is respected.
ProtectionRuleBypassTest::testRoleEditProtectionBypass in tests/src/Kernel/ProtectionRuleBypassTest.php
Tests if bypassing role edit protection is respected.
ProtectionRuleBypassTest::testRoleMailEditProtectionBypass in tests/src/Kernel/ProtectionRuleBypassTest.php
Tests if bypassing role mail edit protection is respected.
ProtectionRuleBypassTest::testRoleNameEditProtectionBypass in tests/src/Kernel/ProtectionRuleBypassTest.php
Tests if bypassing role name edit protection is respected.
ProtectionRuleBypassTest::testRolePassEditProtectionBypass in tests/src/Kernel/ProtectionRuleBypassTest.php
Tests if bypassing role password edit protection is respected.

File

tests/src/Kernel/ProtectionRuleBypassTest.php, line 72

Class

ProtectionRuleBypassTest
Tests bypassing protection rules.

Namespace

Drupal\Tests\userprotect\Kernel

Code

protected function doRoleProtectionBypassTest($plugin, $operation) {

  // Create a protected role.
  $rid = $this
    ->createProtectedRole([
    $plugin,
  ]);

  // Create an account with this protected role.
  $protected_account = $this
    ->drupalCreateUser();
  $protected_account
    ->addRole($rid);

  // Create operating account.
  $account = $this
    ->drupalCreateUser([
    'administer users',
    'userprotect.dummy.bypass',
  ]);

  // Test if account has the expected access.
  $this
    ->assertTrue($this->accessController
    ->access($protected_account, $operation, $account));
}