Pull merge.
[yaffs-website] / web / core / modules / user / tests / src / Kernel / Migrate / MigrateUserProfileFieldTest.php
1 <?php
2
3 namespace Drupal\Tests\user\Kernel\Migrate;
4
5 use Drupal\field\Entity\FieldStorageConfig;
6 use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
7
8 /**
9  * Tests the user profile field migration.
10  *
11  * @group migrate_drupal_6
12  */
13 class MigrateUserProfileFieldTest extends MigrateDrupal6TestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   protected function setUp() {
19     parent::setUp();
20     $this->executeMigration('user_profile_field');
21   }
22
23   /**
24    * Tests migration of user profile fields.
25    */
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');
31
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.');
35
36     // Migrated checkbox field.
37     $field_storage = FieldStorageConfig::load('user.profile_sell_address');
38     $this->assertIdentical('boolean', $field_storage->getType(), 'Field type is boolean.');
39
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',
52     ]);
53     $this->assertIdentical('list_string', $field_storage->getType(), 'Field type is list_string.');
54
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');
59
60     // Migrated URL field.
61     $field_storage = FieldStorageConfig::load('user.profile_blog');
62     $this->assertIdentical('link', $field_storage->getType(), 'Field type is link.');
63
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']);
68   }
69
70 }