function RefinableCalculatedPermissionsTest::testAddItemOverwrite

Same name in other branches
  1. 10 core/tests/Drupal/Tests/Core/Session/RefinableCalculatedPermissionsTest.php \Drupal\Tests\Core\Session\RefinableCalculatedPermissionsTest::testAddItemOverwrite()

Tests the overwriting of a calculated permissions item.

@depends testAddItem

File

core/tests/Drupal/Tests/Core/Session/RefinableCalculatedPermissionsTest.php, line 49

Class

RefinableCalculatedPermissionsTest
Tests the RefinableCalculatedPermissions class.

Namespace

Drupal\Tests\Core\Session

Code

public function testAddItemOverwrite() : void {
    $calculated_permissions = new RefinableCalculatedPermissions();
    $scope = 'some_scope';
    $item = new CalculatedPermissionsItem([
        'bar',
    ], FALSE, $scope, 'foo');
    $calculated_permissions->addItem($item);
    $item = new CalculatedPermissionsItem([
        'baz',
    ], FALSE, $scope, 'foo');
    $calculated_permissions->addItem($item, TRUE);
    $this->assertEquals([
        'baz',
    ], $calculated_permissions->getItem($scope, 'foo')
        ->getPermissions(), 'Successfully overwrote an item that was already in the list.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.