diff --git a/core/modules/migrate_drupal/tests/fixtures/drupal7.php b/core/modules/migrate_drupal/tests/fixtures/drupal7.php index 2797b6c..ef12556 100644 --- a/core/modules/migrate_drupal/tests/fixtures/drupal7.php +++ b/core/modules/migrate_drupal/tests/fixtures/drupal7.php @@ -3720,6 +3720,15 @@ 'data' => 'a:6:{s:5:"label";s:4:"File";s:6:"widget";a:5:{s:6:"weight";s:1:"8";s:4:"type";s:12:"file_generic";s:6:"module";s:4:"file";s:6:"active";i:1;s:8:"settings";a:1:{s:18:"progress_indicator";s:8:"throbber";}}s:8:"settings";a:5:{s:14:"file_directory";s:0:"";s:15:"file_extensions";s:3:"txt";s:12:"max_filesize";s:0:"";s:17:"description_field";i:0;s:18:"user_register_form";i:0;}s:7:"display";a:1:{s:7:"default";a:5:{s:5:"label";s:5:"above";s:4:"type";s:12:"file_default";s:8:"settings";a:0:{}s:6:"module";s:4:"file";s:6:"weight";i:0;}}s:8:"required";i:0;s:11:"description";s:0:"";}', 'deleted' => '0', )) +->values(array( + 'id' => '34', + '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( @@ -4356,6 +4365,18 @@ 'field_file_display' => '1', 'field_file_description' => 'file desc', )) +->values(array( + 'entity_type' => 'user', + 'bundle' => 'user', + 'deleted' => '0', + 'entity_id' => '2', + 'revision_id' => '2', + 'language' => 'und', + 'delta' => '0', + 'field_file_fid' => '2', + 'field_file_display' => '1', + 'field_file_description' => 'file desc', +)) ->execute(); $connection->schema()->createTable('field_data_field_float', array( @@ -4720,6 +4741,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( @@ -6118,6 +6149,18 @@ 'field_file_display' => '1', 'field_file_description' => 'file desc', )) +->values(array( + 'entity_type' => 'user', + 'bundle' => 'user', + 'deleted' => '0', + 'entity_id' => '2', + 'revision_id' => '2', + 'language' => 'und', + 'delta' => '0', + 'field_file_fid' => '2', + 'field_file_display' => '1', + 'field_file_description' => 'file desc', +)) ->execute(); $connection->schema()->createTable('field_revision_field_float', array( @@ -6486,6 +6529,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( 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 1d3ce61..e42729e 100644 --- a/core/modules/migrate_drupal_ui/src/Tests/d7/MigrateUpgrade7Test.php +++ b/core/modules/migrate_drupal_ui/src/Tests/d7/MigrateUpgrade7Test.php @@ -42,7 +42,7 @@ protected function getEntityCounts() { 'contact_form' => 3, 'editor' => 2, 'field_config' => 41, - 'field_storage_config' => 31, + 'field_storage_config' => 32, 'file' => 1, 'filter_format' => 7, 'image_style' => 6, 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..232d0b7 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 = array( + '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(array( + 'type' => $id, + 'label' => $this->randomString(), + ))->save(); + + CommentType::create(array( + '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,12 @@ 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. + * @param int $field_file_target_id + * The target id of the file 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, $field_file_target_id = NULL) { /** @var \Drupal\user\UserInterface $user */ $user = User::load($id); $this->assertTrue($user instanceof UserInterface); @@ -80,6 +124,14 @@ 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); + } + if (!is_null($field_file_target_id)) { + $this->assertTrue($user->hasField('field_file')); + $this->assertEquals($field_file_target_id, $user->field_file->target_id); + } } /** @@ -87,7 +139,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, '', 'odo@local.host', [RoleInterface::AUTHENTICATED_ID], FALSE, 99, 2); // Ensure that the user can authenticate. $this->assertEquals(2, \Drupal::service('user.auth')->authenticate('Odo', 'a password'));