class MigrateUserSettingsTest
Same name and namespace in other branches
- 11.x core/modules/user/tests/src/Kernel/Migrate/d7/MigrateUserSettingsTest.php \Drupal\Tests\user\Kernel\Migrate\d7\MigrateUserSettingsTest
Tests migration of user settings.
@group migrate_drupal_7
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\d7\MigrateDrupal7TestBase uses \Drupal\Tests\migrate_drupal\Traits\NodeMigrateTypeTestTrait implements \Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase
- class \Drupal\Tests\user\Kernel\Migrate\d7\MigrateUserSettingsTest uses \Drupal\Tests\SchemaCheckTestTrait implements \Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase
- class \Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase 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 MigrateUserSettingsTest
File
-
core/
modules/ user/ tests/ src/ Kernel/ Migrate/ d7/ MigrateUserSettingsTest.php, line 16
Namespace
Drupal\Tests\user\Kernel\Migrate\d7View source
class MigrateUserSettingsTest extends MigrateDrupal7TestBase {
use SchemaCheckTestTrait;
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->executeMigrations([
'd7_user_settings',
]);
}
/**
* Tests the migration.
*/
public function testMigration() {
$config = $this->config('user.settings');
$this->assertTrue($config->get('notify.status_blocked'));
$this->assertTrue($config->get('notify.status_activated'));
$this->assertTrue($config->get('verify_mail'));
$this->assertSame(UserInterface::REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL, $config->get('register'));
$this->assertSame('Anonymous', $config->get('anonymous'));
// Tests migration of user_register using the AccountSettingsForm.
// Map source values to destination values.
$user_register_map = [
[
0,
UserInterface::REGISTER_ADMINISTRATORS_ONLY,
],
[
1,
UserInterface::REGISTER_VISITORS,
],
[
2,
UserInterface::REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL,
],
];
foreach ($user_register_map as $map) {
// Tests migration of user_register = 1.
Database::getConnection('default', 'migrate')->update('variable')
->fields([
'value' => serialize($map[0]),
])
->condition('name', 'user_register')
->execute();
/** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
$migration = $this->getMigration('d7_user_settings');
// Indicate we're rerunning a migration that's already run.
$migration->getIdMap()
->prepareUpdate();
$this->executeMigration($migration);
$form = $this->container
->get('form_builder')
->getForm(AccountSettingsForm::create($this->container));
$this->assertSame($map[1], $form['registration_cancellation']['user_register']['#value']);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.