97133325875d4196f4feef62b1bb470a64fc36fa
[yaffs-website] / web / core / modules / user / tests / src / Kernel / Migrate / MigrateUserProfileFieldInstanceTest.php
1 <?php
2
3 namespace Drupal\Tests\user\Kernel\Migrate;
4
5 use Drupal\field\Entity\FieldConfig;
6 use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
7
8 /**
9  * Tests the user profile field instance migration.
10  *
11  * @group migrate_drupal_6
12  */
13 class MigrateUserProfileFieldInstanceTest extends MigrateDrupal6TestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public static $modules = ['field'];
19
20   /**
21    * {@inheritdoc}
22    */
23   protected function setUp() {
24     parent::setUp();
25     $this->executeMigrations([
26       'user_profile_field',
27       'user_profile_field_instance',
28     ]);
29   }
30
31   /**
32    * Tests migration of user profile fields.
33    */
34   public function testUserProfileFields() {
35     // Migrated a text field.
36     $field = FieldConfig::load('user.user.profile_color');
37     $this->assertIdentical('Favorite color', $field->label());
38     $this->assertIdentical('List your favorite color', $field->getDescription());
39
40     // Migrated a textarea.
41     $field = FieldConfig::load('user.user.profile_biography');
42     $this->assertIdentical('Biography', $field->label());
43     $this->assertIdentical('Tell people a little bit about yourself', $field->getDescription());
44
45     // Migrated checkbox field.
46     $field = FieldConfig::load('user.user.profile_sell_address');
47     $this->assertIdentical('Sell your email address?', $field->label());
48     $this->assertIdentical("If you check this box, we'll sell your address to spammers to help line the pockets of our shareholders. Thanks!", $field->getDescription());
49
50     // Migrated selection field.
51     $field = FieldConfig::load('user.user.profile_sold_to');
52     $this->assertIdentical('Sales Category', $field->label());
53     $this->assertIdentical("Select the sales categories to which this user's address was sold.", $field->getDescription());
54
55     // Migrated list field.
56     $field = FieldConfig::load('user.user.profile_bands');
57     $this->assertIdentical('Favorite bands', $field->label());
58     $this->assertIdentical("Enter your favorite bands. When you've saved your profile, you'll be able to find other people with the same favorites.", $field->getDescription());
59
60     // Migrated URL field.
61     $field = FieldConfig::load('user.user.profile_blog');
62     $this->assertIdentical('Blog', $field->label());
63     $this->assertIdentical("Paste the full URL, including http://, of your personal blog.", $field->getDescription());
64
65     // Migrated date field.
66     $field = FieldConfig::load('user.user.profile_birthdate');
67     $this->assertIdentical('Birthdate', $field->label());
68     $this->assertIdentical("Enter your birth date and we'll send you a coupon.", $field->getDescription());
69
70     // Another migrated checkbox field, with a different source visibility setting.
71     $field = FieldConfig::load('user.user.profile_love_migrations');
72     $this->assertIdentical('I love migrations', $field->label());
73     $this->assertIdentical("If you check this box, you love migrations.", $field->getDescription());
74   }
75
76 }