protected function MigrateUserRoleTest::assertEntity in Drupal 10
Same name and namespace in other branches
- 8 core/modules/user/tests/src/Kernel/Migrate/d7/MigrateUserRoleTest.php \Drupal\Tests\user\Kernel\Migrate\d7\MigrateUserRoleTest::assertEntity()
- 9 core/modules/user/tests/src/Kernel/Migrate/d7/MigrateUserRoleTest.php \Drupal\Tests\user\Kernel\Migrate\d7\MigrateUserRoleTest::assertEntity()
Asserts aspects of a user role config entity.
@internal
Parameters
string $id: The role ID.
string $label: The role's expected label.
int $original_rid: The original (integer) ID of the role, to check permissions.
1 call to MigrateUserRoleTest::assertEntity()
- MigrateUserRoleTest::testUserRole in core/
modules/ user/ tests/ src/ Kernel/ Migrate/ d7/ MigrateUserRoleTest.php - Tests user role migration.
File
- core/
modules/ user/ tests/ src/ Kernel/ Migrate/ d7/ MigrateUserRoleTest.php, line 37
Class
- MigrateUserRoleTest
- Upgrade user roles to user.role.*.yml.
Namespace
Drupal\Tests\user\Kernel\Migrate\d7Code
protected function assertEntity(string $id, string $label, int $original_rid) : void {
/** @var \Drupal\user\RoleInterface $entity */
$entity = Role::load($id);
$this
->assertInstanceOf(RoleInterface::class, $entity);
$this
->assertSame($label, $entity
->label());
if (isset($original_rid)) {
$permissions = Database::getConnection('default', 'migrate')
->select('role_permission', 'rp')
->fields('rp', [
'permission',
])
->condition('rid', $original_rid)
->execute()
->fetchCol();
sort($permissions);
$this
->assertSame($permissions, $entity
->getPermissions());
}
}