You are here

protected function MigrateUserRoleTest::assertEntity in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/user/src/Tests/Migrate/d7/MigrateUserRoleTest.php \Drupal\user\Tests\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/src/Tests/Migrate/d7/MigrateUserRoleTest.php
Tests user role migration.

File

core/modules/user/src/Tests/Migrate/d7/MigrateUserRoleTest.php, line 40
Contains \Drupal\user\Tests\Migrate\d7\MigrateUserRoleTest.

Class

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

Namespace

Drupal\user\Tests\Migrate\d7

Code

protected function assertEntity($id, $label, $original_rid) {

  /** @var \Drupal\user\RoleInterface $entity */
  $entity = Role::load($id);
  $this
    ->assertTrue($entity instanceof RoleInterface);
  $this
    ->assertIdentical($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();
    $this
      ->assertIdentical($permissions, $entity
      ->getPermissions());
  }
}