MigrateUserProfileValuesTest.php 3.38 KB
Newer Older
1
2
<?php

3
namespace Drupal\Tests\user\Kernel\Migrate\d6;
4

5
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
6
use Drupal\user\Entity\User;
7
8

/**
9
10
 * User profile values migration.
 *
11
 * @group migrate_drupal_6
12
 */
13
class MigrateUserProfileValuesTest extends MigrateDrupal6TestBase {
14

15
16
17
  /**
   * {@inheritdoc}
   */
18
  protected static $modules = ['language'];
19

20
21
22
  /**
   * {@inheritdoc}
   */
23
  protected function setUp(): void {
24
25
    parent::setUp();

26
    $this->executeMigrations([
27
      'language',
28
29
30
31
32
33
      'user_profile_field',
      'user_profile_field_instance',
      'user_profile_entity_display',
      'user_profile_entity_form_display',
    ]);
    $this->migrateUsers(FALSE);
34
    $this->executeMigration('d6_profile_values');
35
36
37
38
39
40
  }

  /**
   * Tests Drupal 6 profile values to Drupal 8 migration.
   */
  public function testUserProfileValues() {
41
    $user = User::load(2);
42
    $this->assertNotNull($user);
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
    $this->assertIdentical('red', $user->profile_color->value);
    $expected = <<<EOT
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam nulla sapien, congue nec risus ut, adipiscing aliquet felis. Maecenas quis justo vel nulla varius euismod. Quisque metus metus, cursus sit amet sem non, bibendum vehicula elit. Cras dui nisl, eleifend at iaculis vitae, lacinia ut felis. Nullam aliquam ligula volutpat nulla consectetur accumsan. Maecenas tincidunt molestie diam, a accumsan enim fringilla sit amet. Morbi a tincidunt tellus. Donec imperdiet scelerisque porta. Sed quis sem bibendum eros congue sodales. Vivamus vel fermentum est, at rutrum orci. Nunc consectetur purus ut dolor pulvinar, ut volutpat felis congue. Cras tincidunt odio sed neque sollicitudin, vehicula tempor metus scelerisque.
EOT;
    $this->assertIdentical($expected, $user->profile_biography->value);
    $this->assertIdentical('1', $user->profile_sell_address->value);
    $this->assertIdentical('Back\slash', $user->profile_sold_to->value);
    $this->assertIdentical('AC/DC', $user->profile_bands[0]->value);
    $this->assertIdentical('Eagles', $user->profile_bands[1]->value);
    $this->assertIdentical('Elton John', $user->profile_bands[2]->value);
    $this->assertIdentical('Lemonheads', $user->profile_bands[3]->value);
    $this->assertIdentical('Rolling Stones', $user->profile_bands[4]->value);
    $this->assertIdentical('Queen', $user->profile_bands[5]->value);
    $this->assertIdentical('The White Stripes', $user->profile_bands[6]->value);
    $this->assertIdentical('1974-06-02', $user->profile_birthdate->value);
58
59
60
61
    $this->assertIdentical('http://example.com/blog', $user->profile_blog->uri);
    $this->assertNull($user->profile_blog->title);
    $this->assertIdentical([], $user->profile_blog->options);
    $this->assertIdentical('http://example.com/blog', $user->profile_blog->uri);
62
63
64
65
66
67
68

    // Check that the source profile field names that are longer than 32
    // characters have been migrated.
    $this->assertNotNull($user->getFieldDefinition('profile_really_really_love_mig'));
    $this->assertNotNull($user->getFieldDefinition('profile_really_really_love_mig1'));
    $this->assertSame('1', $user->profile_really_really_love_mig->value);
    $this->assertNull($user->profile_really_really_love_mig1->value);
69
70

    $user = User::load(8);
71
    $this->assertIdentical('Forward/slash', $user->profile_sold_to->value);
72
73

    $user = User::load(15);
74
    $this->assertIdentical('Dot.in.the.middle', $user->profile_sold_to->value);
75
76
77
  }

}