public function UrlAliasPermissionsUpdate8001::testUpdate8001 in URL Alias Permissions 8
Update test that checks if the permissions are converted to the new ones.
See also
url_alias_permissions_update_8001()
File
- tests/
src/ Functional/ Update/ UrlAliasPermissionsUpdate8001.php, line 54
Class
- UrlAliasPermissionsUpdate8001
- Update test that checks if the permissions are converted to the new ones.
Namespace
Drupal\Tests\url_alias_permissions\Functional\UpdateCode
public function testUpdate8001() {
// Check that the authenticated and anonymous roles have the old
// permissions before the update. This functionality is tested with the
// anonymous user because the administrator role is an admin role and
// always return true when calling hasPermission. Even when the permission
// no longer exists.
/** @var \Drupal\user\Entity\Role $authenticated */
$authenticated = $this->roleStorage
->loadUnchanged('authenticated');
$this
->assertTrue($authenticated
->hasPermission('edit article URL alias'));
$this
->assertFalse($authenticated
->hasPermission('edit page URL alias'));
/** @var \Drupal\user\Entity\Role $anonymous */
$anonymous = $this->roleStorage
->loadUnchanged('anonymous');
$this
->assertTrue($anonymous
->hasPermission('edit article URL alias'));
$this
->assertTrue($anonymous
->hasPermission('edit page URL alias'));
$this
->runUpdates();
// Check that the old permissions are no longer present and are replaced
// with the new ones.
$authenticated = $this->roleStorage
->loadUnchanged('authenticated');
$this
->assertFalse($authenticated
->hasPermission('edit article URL alias'));
$this
->assertFalse($authenticated
->hasPermission('edit page URL alias'));
$this
->assertTrue($authenticated
->hasPermission('edit article node url alias'));
$this
->assertFalse($authenticated
->hasPermission('edit page node url alias'));
$anonymous = $this->roleStorage
->loadUnchanged('anonymous');
$this
->assertFalse($anonymous
->hasPermission('edit article URL alias'));
$this
->assertFalse($anonymous
->hasPermission('edit page URL alias'));
$this
->assertTrue($anonymous
->hasPermission('edit article node url alias'));
$this
->assertTrue($anonymous
->hasPermission('edit page node url alias'));
}