function MigrateUserRoleTest::assertEntity

Same name in other branches
  1. 8.9.x core/modules/user/tests/src/Kernel/Migrate/d7/MigrateUserRoleTest.php \Drupal\Tests\user\Kernel\Migrate\d7\MigrateUserRoleTest::assertEntity()
  2. 10 core/modules/user/tests/src/Kernel/Migrate/d7/MigrateUserRoleTest.php \Drupal\Tests\user\Kernel\Migrate\d7\MigrateUserRoleTest::assertEntity()
  3. 11.x 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\d7

Code

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());
    }
}

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