3 namespace Drupal\Tests\user\Kernel\Migrate;
5 use Drupal\field\Entity\FieldStorageConfig;
6 use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
9 * Tests the user profile field migration.
11 * @group migrate_drupal_6
13 class MigrateUserProfileFieldTest extends MigrateDrupal6TestBase {
18 protected function setUp() {
20 $this->executeMigration('user_profile_field');
24 * Tests migration of user profile fields.
26 public function testUserProfileFields() {
27 // Migrated a text field.
28 $field_storage = FieldStorageConfig::load('user.profile_color');
29 $this->assertIdentical('text', $field_storage->getType(), 'Field type is text.');
30 $this->assertIdentical(1, $field_storage->getCardinality(), 'Text field has correct cardinality');
32 // Migrated a textarea.
33 $field_storage = FieldStorageConfig::load('user.profile_biography');
34 $this->assertIdentical('text_long', $field_storage->getType(), 'Field type is text_long.');
36 // Migrated checkbox field.
37 $field_storage = FieldStorageConfig::load('user.profile_sell_address');
38 $this->assertIdentical('boolean', $field_storage->getType(), 'Field type is boolean.');
40 // Migrated selection field.
41 $field_storage = FieldStorageConfig::load('user.profile_sold_to');
42 $this->assertIdentical('list_string', $field_storage->getType(), 'Field type is list_string.');
43 $settings = $field_storage->getSettings();
44 $this->assertEqual($settings['allowed_values'], [
45 'Pill spammers' => 'Pill spammers',
46 'Fitness spammers' => 'Fitness spammers',
47 'Back\slash' => 'Back\slash',
48 'Forward/slash' => 'Forward/slash',
49 'Dot.in.the.middle' => 'Dot.in.the.middle',
50 'Faithful servant' => 'Faithful servant',
51 'Anonymous donor' => 'Anonymous donor',
53 $this->assertIdentical('list_string', $field_storage->getType(), 'Field type is list_string.');
55 // Migrated list field.
56 $field_storage = FieldStorageConfig::load('user.profile_bands');
57 $this->assertIdentical('text', $field_storage->getType(), 'Field type is text.');
58 $this->assertIdentical(-1, $field_storage->getCardinality(), 'List field has correct cardinality');
60 // Migrated URL field.
61 $field_storage = FieldStorageConfig::load('user.profile_blog');
62 $this->assertIdentical('link', $field_storage->getType(), 'Field type is link.');
64 // Migrated date field.
65 $field_storage = FieldStorageConfig::load('user.profile_birthdate');
66 $this->assertIdentical('datetime', $field_storage->getType(), 'Field type is datetime.');
67 $this->assertIdentical('date', $field_storage->getSettings()['datetime_type']);