diff --git a/core/modules/user/tests/src/Kernel/Migrate/d7/MigrateUserTest.php b/core/modules/user/tests/src/Kernel/Migrate/d7/MigrateUserTest.php index 61ff800..a1be14d 100644 --- a/core/modules/user/tests/src/Kernel/Migrate/d7/MigrateUserTest.php +++ b/core/modules/user/tests/src/Kernel/Migrate/d7/MigrateUserTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\user\Kernel\Migrate\d7; +use Drupal\language\Entity\ConfigurableLanguage; use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase; use Drupal\user\Entity\User; use Drupal\user\RoleInterface; @@ -17,7 +18,7 @@ class MigrateUserTest extends MigrateDrupal7TestBase { /** * {@inheritdoc} */ - public static $modules = ['file', 'image']; + public static $modules = ['file', 'image', 'language']; /** * {@inheritdoc} @@ -25,6 +26,12 @@ class MigrateUserTest extends MigrateDrupal7TestBase { protected function setUp() { parent::setUp(); + // Set the default language, so we can test that the user gets that + // language. + // Change when we have i18n user migrations. + ConfigurableLanguage::createFromLangcode('sv')->save(); + $this->config('system.site')->set('default_langcode', 'sv')->save(); + // Prepare to migrate user pictures as well. $this->installEntitySchema('file'); $this->executeMigrations([ @@ -51,7 +58,9 @@ protected function setUp() { * @param bool $blocked * Whether or not the account is blocked. * @param string $langcode - * The user account's language code. + * The user account's translation language code. + * @param string $langcode + * The user account's preferred UI language code. * @param string $init * The user's initial email address. * @param string[] $roles @@ -59,7 +68,7 @@ protected function setUp() { * @param bool $has_picture * Whether the user is expected to have a picture attached. */ - protected function assertEntity($id, $label, $mail, $access, $login, $blocked, $langcode, $init, array $roles = [RoleInterface::AUTHENTICATED_ID], $has_picture = FALSE) { + protected function assertEntity($id, $label, $mail, $access, $login, $blocked, $langcode, $preferred_langcode, $init, array $roles = [RoleInterface::AUTHENTICATED_ID], $has_picture = FALSE) { /** @var \Drupal\user\UserInterface $user */ $user = User::load($id); $this->assertTrue($user instanceof UserInterface); @@ -68,12 +77,12 @@ protected function assertEntity($id, $label, $mail, $access, $login, $blocked, $ $this->assertIdentical($access, $user->getLastAccessedTime()); $this->assertIdentical($login, $user->getLastLoginTime()); $this->assertIdentical($blocked, $user->isBlocked()); + $this->assertIdentical($langcode, $user->langcode->value); // $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($preferred_langcode, $user->preferred_langcode->value); + $this->assertIdentical($preferred_langcode, $user->preferred_admin_langcode->value); $this->assertIdentical($init, $user->getInitialEmail()); $this->assertIdentical($roles, $user->getRoles()); $this->assertIdentical($has_picture, !$user->user_picture->isEmpty()); @@ -83,7 +92,7 @@ protected function assertEntity($id, $label, $mail, $access, $login, $blocked, $ * Tests the Drupal 7 user to Drupal 8 migration. */ public function testUser() { - $this->assertEntity(2, 'Odo', 'odo@local.host', '0', '0', FALSE, '', 'odo@local.host'); + $this->assertEntity(2, 'Odo', 'odo@local.host', '0', '0', FALSE, 'sv', '', 'odo@local.host'); } }