Commit d1119049 authored by webchick's avatar webchick

Issue #2562083 by phenaproxima, mikeryan: D7 user migration should skip over user picture if empty

parent 9210d05c
......@@ -25,9 +25,13 @@ process:
migration: d7_user_role
source: roles
user_picture:
plugin: migration
migration: d7_file
source: picture
-
plugin: default_value
source: picture
default_value: null
-
plugin: migration
migration: d7_file
destination:
plugin: entity:user
migration_dependencies:
......
......@@ -24,13 +24,19 @@ class MigrateUserTest extends MigrateDrupal7TestBase {
*
* @var array
*/
static $modules = array('user');
static $modules = array('file', 'image', 'user');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// Prepare to migrate user pictures as well.
$this->installEntitySchema('file');
$this->executeMigration('user_picture_field');
$this->executeMigration('user_picture_field_instance');
$this->executeMigration('d7_user_role');
$this->executeMigration('d7_user');
}
......@@ -56,8 +62,10 @@ protected function setUp() {
* The user's initial e-mail address.
* @param string[] $roles
* Role IDs the user account is expected to have.
* @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]) {
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);
......@@ -74,6 +82,7 @@ protected function assertEntity($id, $label, $mail, $access, $login, $blocked, $
$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());
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment