class MigrateUserProfileFieldTest
Same name and namespace in other branches
- 11.x core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserProfileFieldTest.php \Drupal\Tests\user\Kernel\Migrate\d6\MigrateUserProfileFieldTest
Tests the user profile field migration.
@group migrate_drupal_6
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\migrate\Kernel\MigrateTestBase extends \Drupal\migrate\MigrateMessageInterface implements \Drupal\KernelTests\KernelTestBase
- class \Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase implements \Drupal\Tests\migrate\Kernel\MigrateTestBase
- class \Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase uses \Drupal\Tests\migrate_drupal\Traits\NodeMigrateTypeTestTrait implements \Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase
- class \Drupal\Tests\user\Kernel\Migrate\d6\MigrateUserProfileFieldTest implements \Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase
- class \Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase uses \Drupal\Tests\migrate_drupal\Traits\NodeMigrateTypeTestTrait implements \Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase
- class \Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase implements \Drupal\Tests\migrate\Kernel\MigrateTestBase
- class \Drupal\Tests\migrate\Kernel\MigrateTestBase extends \Drupal\migrate\MigrateMessageInterface implements \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of MigrateUserProfileFieldTest
File
-
core/
modules/ user/ tests/ src/ Kernel/ Migrate/ d6/ MigrateUserProfileFieldTest.php, line 13
Namespace
Drupal\Tests\user\Kernel\Migrate\d6View source
class MigrateUserProfileFieldTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->executeMigration('user_profile_field');
}
/**
* Tests migration of user profile fields.
*/
public function testUserProfileFields() {
// Migrated a text field.
$field_storage = FieldStorageConfig::load('user.profile_color');
$this->assertSame('text', $field_storage->getType(), 'Field type is text.');
$this->assertSame(1, $field_storage->getCardinality(), 'Text field has correct cardinality');
// Migrated a textarea.
$field_storage = FieldStorageConfig::load('user.profile_biography');
$this->assertSame('text_long', $field_storage->getType(), 'Field type is text_long.');
// Migrated checkbox field.
$field_storage = FieldStorageConfig::load('user.profile_sell_address');
$this->assertSame('boolean', $field_storage->getType(), 'Field type is boolean.');
// Migrated selection field.
$field_storage = FieldStorageConfig::load('user.profile_sold_to');
$this->assertSame('list_string', $field_storage->getType(), 'Field type is list_string.');
$settings = $field_storage->getSettings();
$this->assertEquals([
'Pill spammers' => 'Pill spammers',
'Fitness spammers' => 'Fitness spammers',
'Back\\slash' => 'Back\\slash',
'Forward/slash' => 'Forward/slash',
'Dot.in.the.middle' => 'Dot.in.the.middle',
'Faithful servant' => 'Faithful servant',
'Anonymous donor' => 'Anonymous donor',
], $settings['allowed_values']);
$this->assertSame('list_string', $field_storage->getType(), 'Field type is list_string.');
// Migrated list field.
$field_storage = FieldStorageConfig::load('user.profile_bands');
$this->assertSame('text', $field_storage->getType(), 'Field type is text.');
$this->assertSame(-1, $field_storage->getCardinality(), 'List field has correct cardinality');
// Migrated URL field.
$field_storage = FieldStorageConfig::load('user.profile_blog');
$this->assertSame('link', $field_storage->getType(), 'Field type is link.');
// Migrated date field.
$field_storage = FieldStorageConfig::load('user.profile_birthdate');
$this->assertSame('datetime', $field_storage->getType(), 'Field type is datetime.');
$this->assertSame('date', $field_storage->getSettings()['datetime_type']);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.