diff --git a/core/modules/migrate_drupal/tests/fixtures/drupal7.php b/core/modules/migrate_drupal/tests/fixtures/drupal7.php index a02d12f..e32078d 100644 --- a/core/modules/migrate_drupal/tests/fixtures/drupal7.php +++ b/core/modules/migrate_drupal/tests/fixtures/drupal7.php @@ -3738,6 +3738,15 @@ 'data' => 'a:7:{s:5:"label";s:7:"Integer";s:6:"widget";a:5:{s:6:"weight";s:1:"2";s:4:"type";s:6:"number";s:6:"module";s:6:"number";s:6:"active";i:0;s:8:"settings";a:0:{}}s:8:"settings";a:5:{s:3:"min";s:0:"";s:3:"max";s:0:"";s:6:"prefix";s:0:"";s:6:"suffix";s:0:"";s:18:"user_register_form";b:0;}s:7:"display";a:1:{s:7:"default";a:5:{s:5:"label";s:5:"above";s:4:"type";s:14:"number_integer";s:8:"settings";a:4:{s:18:"thousand_separator";s:0:"";s:17:"decimal_separator";s:1:".";s:5:"scale";i:0;s:13:"prefix_suffix";b:1;}s:6:"module";s:6:"number";s:6:"weight";i:0;}}s:8:"required";i:0;s:11:"description";s:0:"";s:13:"default_value";N;}', 'deleted' => '0', )) +->values(array( + 'id' => '36', + 'field_id' => '14', + 'field_name' => 'field_integer', + 'entity_type' => 'user', + 'bundle' => 'user', + 'data' => 'a:7:{s:5:"label";s:7:"Integer";s:6:"widget";a:5:{s:6:"weight";s:1:"9";s:4:"type";s:6:"number";s:6:"module";s:6:"number";s:6:"active";i:0;s:8:"settings";a:0:{}}s:8:"settings";a:5:{s:3:"min";s:1:"1";s:3:"max";s:2:"25";s:6:"prefix";s:3:"abc";s:6:"suffix";s:3:"xyz";s:18:"user_register_form";b:0;}s:7:"display";a:1:{s:7:"default";a:5:{s:5:"label";s:5:"above";s:4:"type";s:14:"number_integer";s:6:"weight";s:1:"8";s:8:"settings";a:4:{s:18:"thousand_separator";s:1:" ";s:17:"decimal_separator";s:1:".";s:5:"scale";i:0;s:13:"prefix_suffix";b:1;}s:6:"module";s:6:"number";}}s:8:"required";i:1;s:11:"description";s:0:"";s:13:"default_value";N;}', + 'deleted' => '0', +)) ->execute(); $connection->schema()->createTable('field_data_body', array( @@ -4750,6 +4759,16 @@ 'delta' => '0', 'field_integer_value' => '5', )) +->values(array( + 'entity_type' => 'user', + 'bundle' => 'user', + 'deleted' => '0', + 'entity_id' => '2', + 'revision_id' => '2', + 'language' => 'und', + 'delta' => '0', + 'field_integer_value' => '99', +)) ->execute(); $connection->schema()->createTable('field_data_field_integer_list', array( @@ -6582,6 +6601,16 @@ 'delta' => '0', 'field_integer_value' => '5', )) +->values(array( + 'entity_type' => 'user', + 'bundle' => 'user', + 'deleted' => '0', + 'entity_id' => '2', + 'revision_id' => '2', + 'language' => 'und', + 'delta' => '0', + 'field_integer_value' => '99', +)) ->execute(); $connection->schema()->createTable('field_revision_field_integer_list', array( @@ -41015,7 +41044,7 @@ 'login' => '0', 'status' => '1', 'timezone' => 'America/Chicago', - 'language' => '', + 'language' => 'en', 'picture' => '0', 'init' => 'odo@local.host', 'data' => 'a:1:{s:7:"contact";i:1;}', diff --git a/core/modules/migrate_drupal_ui/src/Tests/d7/MigrateUpgrade7Test.php b/core/modules/migrate_drupal_ui/src/Tests/d7/MigrateUpgrade7Test.php index 2769b44..226bb9e 100644 --- a/core/modules/migrate_drupal_ui/src/Tests/d7/MigrateUpgrade7Test.php +++ b/core/modules/migrate_drupal_ui/src/Tests/d7/MigrateUpgrade7Test.php @@ -43,8 +43,8 @@ protected function getEntityCounts() { 'configurable_language' => 4, 'contact_form' => 3, 'editor' => 2, - 'field_config' => 43, - 'field_storage_config' => 32, + 'field_config' => 44, + 'field_storage_config' => 33, 'file' => 1, 'filter_format' => 7, 'image_style' => 6, diff --git a/core/modules/user/migration_templates/d7_user.yml b/core/modules/user/migration_templates/d7_user.yml index 12147f8..d68fddf 100644 --- a/core/modules/user/migration_templates/d7_user.yml +++ b/core/modules/user/migration_templates/d7_user.yml @@ -41,3 +41,4 @@ migration_dependencies: - user_picture_field_instance - user_picture_entity_display - user_picture_entity_form_display + - d7_field_instance 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 2e0965d..3b104ad 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,8 @@ namespace Drupal\Tests\user\Kernel\Migrate\d7; +use Drupal\comment\Entity\CommentType; +use Drupal\node\Entity\NodeType; use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase; use Drupal\user\Entity\User; use Drupal\user\RoleInterface; @@ -17,7 +19,18 @@ class MigrateUserTest extends MigrateDrupal7TestBase { /** * {@inheritdoc} */ - public static $modules = ['file', 'image']; + static $modules = [ + 'comment', + 'datetime', + 'file', + 'image', + 'link', + 'node', + 'system', + 'taxonomy', + 'telephone', + 'text', + ]; /** * {@inheritdoc} @@ -27,15 +40,42 @@ protected function setUp() { // Prepare to migrate user pictures as well. $this->installEntitySchema('file'); + $this->createType('page'); + $this->createType('article'); + $this->createType('blog'); + $this->createType('book'); + $this->createType('forum'); + $this->createType('test_content_type'); $this->executeMigrations([ 'user_picture_field', 'user_picture_field_instance', 'd7_user_role', + 'd7_field', + 'd7_field_instance', 'd7_user', ]); } /** + * Creates a node type with a corresponding comment type. + * + * @param string $id + * The node type ID. + */ + protected function createType($id) { + NodeType::create([ + 'type' => $id, + 'label' => $this->randomString(), + ])->save(); + + CommentType::create([ + 'id' => 'comment_node_' . $id, + 'label' => $this->randomString(), + 'target_entity_type_id' => 'node', + ])->save(); + } + + /** * Asserts various aspects of a user account. * * @param string $id @@ -60,8 +100,10 @@ protected function setUp() { * Role IDs the user account is expected to have. * @param bool $has_picture * Whether the user is expected to have a picture attached. + * @param int $field_integer + * The value of the integer field. */ - protected function assertEntity($id, $label, $mail, $password, $access, $login, $blocked, $langcode, $init, array $roles = [RoleInterface::AUTHENTICATED_ID], $has_picture = FALSE) { + protected function assertEntity($id, $label, $mail, $password, $access, $login, $blocked, $langcode, $init, array $roles = [RoleInterface::AUTHENTICATED_ID], $has_picture = FALSE, $field_integer = NULL) { /** @var \Drupal\user\UserInterface $user */ $user = User::load($id); $this->assertTrue($user instanceof UserInterface); @@ -80,6 +122,10 @@ protected function assertEntity($id, $label, $mail, $password, $access, $login, $this->assertIdentical($roles, $user->getRoles()); $this->assertIdentical($has_picture, !$user->user_picture->isEmpty()); $this->assertIdentical($password, $user->getPassword()); + if (!is_null($field_integer)) { + $this->assertTrue($user->hasField('field_integer')); + $this->assertEquals($field_integer, $user->field_integer->value); + } } /** @@ -87,7 +133,7 @@ protected function assertEntity($id, $label, $mail, $password, $access, $login, */ public function testUser() { $password = '$S$DGFZUE.FhrXbe4y52eC7p0ZVRGD/gOPtVctDlmC89qkujnBokAlJ'; - $this->assertEntity(2, 'Odo', 'odo@local.host', $password, '0', '0', FALSE, '', 'odo@local.host'); + $this->assertEntity(2, 'Odo', 'odo@local.host', $password, '0', '0', FALSE, 'en', 'odo@local.host', [RoleInterface::AUTHENTICATED_ID], FALSE, 99); // Ensure that the user can authenticate. $this->assertEquals(2, \Drupal::service('user.auth')->authenticate('Odo', 'a password'));