function MigrateUserRoleTest::assertRole

Same name in other branches
  1. 8.9.x core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserRoleTest.php \Drupal\Tests\user\Kernel\Migrate\d6\MigrateUserRoleTest::assertRole()
  2. 10 core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserRoleTest.php \Drupal\Tests\user\Kernel\Migrate\d6\MigrateUserRoleTest::assertRole()
  3. 11.x core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserRoleTest.php \Drupal\Tests\user\Kernel\Migrate\d6\MigrateUserRoleTest::assertRole()

Helper function to perform assertions on a user role.

@internal

Parameters

string $id: The role ID.

string[] $permissions: An array of user permissions.

int $lookupId: The original numeric ID of the role in the source database.

\Drupal\migrate\Plugin\MigrateIdMapInterface $id_map: The map table plugin.

2 calls to MigrateUserRoleTest::assertRole()
MigrateUserRoleTest::assertRoles in core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserRoleTest.php
Helper to assert the user roles.
MigrateUserRoleTest::testUserRole in core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserRoleTest.php
Tests user role migration.

File

core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserRoleTest.php, line 39

Class

MigrateUserRoleTest
Upgrade user roles to user.role.*.yml.

Namespace

Drupal\Tests\user\Kernel\Migrate\d6

Code

protected function assertRole(string $id, array $permissions, int $lookupId, MigrateIdMapInterface $id_map) : void {
    
    /** @var \Drupal\user\RoleInterface $role */
    $role = Role::load($id);
    $this->assertInstanceOf(RoleInterface::class, $role);
    sort($permissions);
    $this->assertSame($permissions, $role->getPermissions());
    $this->assertSame([
        [
            $id,
        ],
    ], $id_map->lookupDestinationIds([
        'rid' => $lookupId,
    ]));
}

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