You are here

public function RefinableCalculatedGroupPermissionsTest::testRemoveItemsByScope in Group 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Unit/RefinableCalculatedGroupPermissionsTest.php \Drupal\Tests\group\Unit\RefinableCalculatedGroupPermissionsTest::testRemoveItemsByScope()

Tests the removal of calculated permissions items by scope.

@covers ::removeItemsByScope @depends testAddItem

File

tests/src/Unit/RefinableCalculatedGroupPermissionsTest.php, line 82

Class

RefinableCalculatedGroupPermissionsTest
Tests the RefinableCalculatedGroupPermissions class.

Namespace

Drupal\Tests\group\Unit

Code

public function testRemoveItemsByScope() {
  $item_a = new CalculatedGroupPermissionsItem(CGPII::SCOPE_GROUP_TYPE, 'foo', [
    'bar',
  ]);
  $item_b = new CalculatedGroupPermissionsItem(CGPII::SCOPE_GROUP, 1, [
    'baz',
  ]);
  $calculated_permissions = new RefinableCalculatedGroupPermissions();
  $calculated_permissions
    ->addItem($item_a)
    ->addItem($item_b)
    ->removeItemsByScope(CGPII::SCOPE_GROUP_TYPE);
  $this
    ->assertFalse($calculated_permissions
    ->getItem(CGPII::SCOPE_GROUP_TYPE, 'foo'), 'Could not retrieve a removed item.');
  $this
    ->assertNotFalse($calculated_permissions
    ->getItem(CGPII::SCOPE_GROUP, 1), 'Group scope item was left untouched.');
}