function CalculatedPermissionsItemTest::testConstructor
Same name in other branches
- 11.x core/tests/Drupal/Tests/Core/Session/CalculatedPermissionsItemTest.php \Drupal\Tests\Core\Session\CalculatedPermissionsItemTest::testConstructor()
Tests that the object values were set in the constructor.
@covers ::__construct @covers ::getIdentifier @covers ::getScope @covers ::getPermissions @covers ::isAdmin
File
-
core/
tests/ Drupal/ Tests/ Core/ Session/ CalculatedPermissionsItemTest.php, line 27
Class
- CalculatedPermissionsItemTest
- Tests the CalculatedPermissionsItem value object.
Namespace
Drupal\Tests\Core\SessionCode
public function testConstructor() : void {
$scope = 'some_scope';
$item = new CalculatedPermissionsItem([
'bar',
'baz',
'bar',
], FALSE, $scope, 'foo');
$this->assertEquals($scope, $item->getScope(), 'Scope name was set correctly.');
$this->assertEquals('foo', $item->getIdentifier(), 'Scope identifier was set correctly.');
$this->assertEquals([
'bar',
'baz',
], $item->getPermissions(), 'Permissions were made unique and set correctly.');
$this->assertFalse($item->isAdmin(), 'Admin flag was set correctly');
$item = new CalculatedPermissionsItem([
'bar',
'baz',
'bar',
], TRUE, $scope, 'foo');
$this->assertEquals([], $item->getPermissions(), 'Permissions were emptied out for an admin item.');
$this->assertTrue($item->isAdmin(), 'Admin flag was set correctly');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.