You are here

protected function MigrateUserTest::assertEntity in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/user/src/Tests/Migrate/d7/MigrateUserTest.php \Drupal\user\Tests\Migrate\d7\MigrateUserTest::assertEntity()

Asserts various aspects of a user account.

Parameters

string $id: The user ID.

string $label: The username.

string $mail: The user's email address.

int $access: The last access time.

int $login: The last login time.

bool $blocked: Whether or not the account is blocked.

string $langcode: The user account's language code.

string $init: The user's initial email address.

string[] $roles: Role IDs the user account is expected to have.

bool $has_picture: Whether the user is expected to have a picture attached.

1 call to MigrateUserTest::assertEntity()
MigrateUserTest::testUser in core/modules/user/src/Tests/Migrate/d7/MigrateUserTest.php
Tests the Drupal 7 user to Drupal 8 migration.

File

core/modules/user/src/Tests/Migrate/d7/MigrateUserTest.php, line 67
Contains \Drupal\user\Tests\Migrate\d7\MigrateUserTest.

Class

MigrateUserTest
Users migration.

Namespace

Drupal\user\Tests\Migrate\d7

Code

protected function assertEntity($id, $label, $mail, $access, $login, $blocked, $langcode, $init, array $roles = [
  RoleInterface::AUTHENTICATED_ID,
], $has_picture = FALSE) {

  /** @var \Drupal\user\UserInterface $user */
  $user = User::load($id);
  $this
    ->assertTrue($user instanceof UserInterface);
  $this
    ->assertIdentical($label, $user
    ->label());
  $this
    ->assertIdentical($mail, $user
    ->getEmail());
  $this
    ->assertIdentical($access, $user
    ->getLastAccessedTime());
  $this
    ->assertIdentical($login, $user
    ->getLastLoginTime());
  $this
    ->assertIdentical($blocked, $user
    ->isBlocked());

  // $user->getPreferredLangcode() might fallback to default language if the
  // user preferred language is not configured on the site. We just want to
  // test if the value was imported correctly.
  $this
    ->assertIdentical($langcode, $user->langcode->value);
  $this
    ->assertIdentical($langcode, $user->preferred_langcode->value);
  $this
    ->assertIdentical($langcode, $user->preferred_admin_langcode->value);
  $this
    ->assertIdentical($init, $user
    ->getInitialEmail());
  $this
    ->assertIdentical($roles, $user
    ->getRoles());
  $this
    ->assertIdentical($has_picture, !$user->user_picture
    ->isEmpty());
}