You are here

public function MigrateUserRoleTest::testUserRole in Zircon Profile 8

Same name in this branch
  1. 8 core/modules/user/src/Tests/Migrate/d6/MigrateUserRoleTest.php \Drupal\user\Tests\Migrate\d6\MigrateUserRoleTest::testUserRole()
  2. 8 core/modules/user/src/Tests/Migrate/d7/MigrateUserRoleTest.php \Drupal\user\Tests\Migrate\d7\MigrateUserRoleTest::testUserRole()
Same name and namespace in other branches
  1. 8.0 core/modules/user/src/Tests/Migrate/d6/MigrateUserRoleTest.php \Drupal\user\Tests\Migrate\d6\MigrateUserRoleTest::testUserRole()

Tests user role migration.

File

core/modules/user/src/Tests/Migrate/d6/MigrateUserRoleTest.php, line 32
Contains \Drupal\user\Tests\Migrate\d6\MigrateUserRoleTest.

Class

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

Namespace

Drupal\user\Tests\Migrate\d6

Code

public function testUserRole() {

  /** @var \Drupal\migrate\entity\Migration $migration */
  $id_map = Migration::load('d6_user_role')
    ->getIdMap();
  $rid = 'anonymous';
  $anonymous = Role::load($rid);
  $this
    ->assertIdentical($rid, $anonymous
    ->id());
  $this
    ->assertIdentical(array(
    'migrate test anonymous permission',
    'use text format filtered_html',
  ), $anonymous
    ->getPermissions());
  $this
    ->assertIdentical(array(
    $rid,
  ), $id_map
    ->lookupDestinationId(array(
    1,
  )));
  $rid = 'authenticated';
  $authenticated = Role::load($rid);
  $this
    ->assertIdentical($rid, $authenticated
    ->id());
  $this
    ->assertIdentical(array(
    'migrate test authenticated permission',
    'use text format filtered_html',
  ), $authenticated
    ->getPermissions());
  $this
    ->assertIdentical(array(
    $rid,
  ), $id_map
    ->lookupDestinationId(array(
    2,
  )));
  $rid = 'migrate_test_role_1';
  $migrate_test_role_1 = Role::load($rid);
  $this
    ->assertIdentical($rid, $migrate_test_role_1
    ->id());
  $this
    ->assertIdentical(array(
    'migrate test role 1 test permission',
    'use text format full_html',
    'use text format php_code',
  ), $migrate_test_role_1
    ->getPermissions());
  $this
    ->assertIdentical(array(
    $rid,
  ), $id_map
    ->lookupDestinationId(array(
    3,
  )));
  $rid = 'migrate_test_role_2';
  $migrate_test_role_2 = Role::load($rid);
  $this
    ->assertIdentical(array(
    'migrate test role 2 test permission',
    'use PHP for settings',
    'administer contact forms',
    'skip comment approval',
    'edit own blog content',
    'edit any blog content',
    'delete own blog content',
    'delete any blog content',
    'create forum content',
    'delete any forum content',
    'delete own forum content',
    'edit any forum content',
    'edit own forum content',
    'administer nodes',
    'access content overview',
    'use text format php_code',
  ), $migrate_test_role_2
    ->getPermissions());
  $this
    ->assertIdentical($rid, $migrate_test_role_2
    ->id());
  $this
    ->assertIdentical(array(
    $rid,
  ), $id_map
    ->lookupDestinationId(array(
    4,
  )));
  $rid = 'migrate_test_role_3_that_is_long';
  $migrate_test_role_3 = Role::load($rid);
  $this
    ->assertIdentical($rid, $migrate_test_role_3
    ->id());
  $this
    ->assertIdentical(array(
    $rid,
  ), $id_map
    ->lookupDestinationId(array(
    5,
  )));
}