Loading core/modules/user/src/Plugin/migrate/source/d7/User.php +1 −1 Original line number Diff line number Diff line Loading @@ -76,7 +76,7 @@ public function prepareRow(Row $row) { ->fetchCol(); $row->setSourceProperty('roles', $roles); $row->setSourceProperty('data', unserialize($row->getSourceProperty('data'))); $row->setSourceProperty('data', unserialize($row->getSourceProperty('data') ?? '')); // If this entity was translated using Entity Translation, we need to get // its source language to get the field values in the right language. Loading core/modules/user/tests/src/Kernel/Plugin/migrate/source/d7/UserTest.php +59 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,18 @@ public function providerSource() { 'field_file_display' => 1, 'field_file_description' => 'None', ], [ 'entity_type' => 'user', 'bundle' => 'user', 'deleted' => 0, 'entity_id' => 3, 'revision_id' => NULL, 'language' => 'und', 'delta' => 0, 'field_file_fid' => 42, 'field_file_display' => 1, 'field_file_description' => 'None', ], ]; $tests[0]['source_data']['role'] = [ [ Loading Loading @@ -81,12 +93,34 @@ public function providerSource() { 'init' => 'odo@local.host', 'data' => 'a:1:{s:7:"contact";i:1;}', ], [ 'uid' => '3', 'name' => 'foo', 'pass' => 'password', 'mail' => 'foo@local.host', 'theme' => '', 'signature' => '', 'signature_format' => 'filtered_html', 'created' => '1647752102', 'access' => '0', 'login' => '0', 'status' => '1', 'timezone' => 'America/Chicago', 'language' => '', 'picture' => '0', 'init' => 'foo@local.host', 'data' => NULL, ], ]; $tests[0]['source_data']['users_roles'] = [ [ 'uid' => 2, 'rid' => 2, ], [ 'uid' => 3, 'rid' => 2, ], ]; // The expected results. Loading Loading @@ -118,6 +152,31 @@ public function providerSource() { ], ], ], [ 'uid' => '3', 'name' => 'foo', 'pass' => 'password', 'mail' => 'foo@local.host', 'signature' => '', 'signature_format' => 'filtered_html', 'created' => '1647752102', 'access' => '0', 'login' => '0', 'status' => '1', 'timezone' => 'America/Chicago', 'language' => '', 'picture' => '0', 'init' => 'foo@local.host', 'roles' => [2], 'data' => FALSE, 'field_file' => [ [ 'fid' => 42, 'display' => 1, 'description' => 'None', ], ], ], ]; return $tests; Loading Loading
core/modules/user/src/Plugin/migrate/source/d7/User.php +1 −1 Original line number Diff line number Diff line Loading @@ -76,7 +76,7 @@ public function prepareRow(Row $row) { ->fetchCol(); $row->setSourceProperty('roles', $roles); $row->setSourceProperty('data', unserialize($row->getSourceProperty('data'))); $row->setSourceProperty('data', unserialize($row->getSourceProperty('data') ?? '')); // If this entity was translated using Entity Translation, we need to get // its source language to get the field values in the right language. Loading
core/modules/user/tests/src/Kernel/Plugin/migrate/source/d7/UserTest.php +59 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,18 @@ public function providerSource() { 'field_file_display' => 1, 'field_file_description' => 'None', ], [ 'entity_type' => 'user', 'bundle' => 'user', 'deleted' => 0, 'entity_id' => 3, 'revision_id' => NULL, 'language' => 'und', 'delta' => 0, 'field_file_fid' => 42, 'field_file_display' => 1, 'field_file_description' => 'None', ], ]; $tests[0]['source_data']['role'] = [ [ Loading Loading @@ -81,12 +93,34 @@ public function providerSource() { 'init' => 'odo@local.host', 'data' => 'a:1:{s:7:"contact";i:1;}', ], [ 'uid' => '3', 'name' => 'foo', 'pass' => 'password', 'mail' => 'foo@local.host', 'theme' => '', 'signature' => '', 'signature_format' => 'filtered_html', 'created' => '1647752102', 'access' => '0', 'login' => '0', 'status' => '1', 'timezone' => 'America/Chicago', 'language' => '', 'picture' => '0', 'init' => 'foo@local.host', 'data' => NULL, ], ]; $tests[0]['source_data']['users_roles'] = [ [ 'uid' => 2, 'rid' => 2, ], [ 'uid' => 3, 'rid' => 2, ], ]; // The expected results. Loading Loading @@ -118,6 +152,31 @@ public function providerSource() { ], ], ], [ 'uid' => '3', 'name' => 'foo', 'pass' => 'password', 'mail' => 'foo@local.host', 'signature' => '', 'signature_format' => 'filtered_html', 'created' => '1647752102', 'access' => '0', 'login' => '0', 'status' => '1', 'timezone' => 'America/Chicago', 'language' => '', 'picture' => '0', 'init' => 'foo@local.host', 'roles' => [2], 'data' => FALSE, 'field_file' => [ [ 'fid' => 42, 'display' => 1, 'description' => 'None', ], ], ], ]; return $tests; Loading