protected function MigrateUserRoleTest::assertEntity in Drupal 9
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()
- 10 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.
Parameters
string $id: The role ID.
string $label: The role's expected label.
int|null $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 35
Class
- MigrateUserRoleTest
- Upgrade user roles to user.role.*.yml.
Namespace
Drupal\Tests\user\Kernel\Migrate\d7Code
protected function assertEntity($id, $label, $original_rid) {
/** @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());
}
}