Same name in this branch
- 10 core/modules/migrate_drupal/tests/src/Kernel/d6/EntityContentBaseTest.php \Drupal\Tests\migrate_drupal\Kernel\d6\EntityContentBaseTest
- 10 core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php \Drupal\Tests\migrate\Unit\Plugin\migrate\destination\EntityContentBaseTest
Same name and namespace in other branches
- 8.9.x core/modules/migrate_drupal/tests/src/Kernel/d6/EntityContentBaseTest.php \Drupal\Tests\migrate_drupal\Kernel\d6\EntityContentBaseTest
- 9 core/modules/migrate_drupal/tests/src/Kernel/d6/EntityContentBaseTest.php \Drupal\Tests\migrate_drupal\Kernel\d6\EntityContentBaseTest
@group migrate_drupal
Hierarchy
- class \Drupal\Tests\migrate\Kernel\MigrateTestBase extends \Drupal\KernelTests\KernelTestBase implements MigrateMessageInterface
- class \Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase
- class \Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase uses NodeMigrateTypeTestTrait
- class \Drupal\Tests\migrate_drupal\Kernel\d6\EntityContentBaseTest
- class \Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase uses NodeMigrateTypeTestTrait
- class \Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase
Expanded class hierarchy of EntityContentBaseTest
File
- core/
modules/ migrate_drupal/ tests/ src/ Kernel/ d6/ EntityContentBaseTest.php, line 15
Namespace
Drupal\Tests\migrate_drupal\Kernel\d6View source
class EntityContentBaseTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'migrate_overwrite_test',
];
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
// Create a field on the user entity so that we can test nested property
// overwrites.
// @see static::testOverwriteSelectedNestedProperty()
FieldStorageConfig::create([
'field_name' => 'signature',
'entity_type' => 'user',
'type' => 'text_long',
])
->save();
FieldConfig::create([
'field_name' => 'signature',
'entity_type' => 'user',
'bundle' => 'user',
])
->save();
User::create([
'uid' => 2,
'name' => 'Ford Prefect',
'mail' => 'ford.prefect@localhost',
'signature' => [
[
'value' => 'Bring a towel.',
'format' => 'filtered_html',
],
],
'init' => 'proto@zo.an',
])
->save();
$this
->executeMigrations([
'd6_filter_format',
'd6_user_role',
]);
}
/**
* Tests overwriting all mapped properties in the destination entity.
*
* This is the default behavior.
*/
public function testOverwriteAllMappedProperties() {
$this
->executeMigration('d6_user');
/** @var \Drupal\user\UserInterface $account */
$account = User::load(2);
$this
->assertSame('john.doe', $account
->label());
$this
->assertSame('john.doe@example.com', $account
->getEmail());
$this
->assertSame('doe@example.com', $account
->getInitialEmail());
}
/**
* Tests overwriting selected properties in the destination entity.
*
* The selected properties are specified in the destination configuration.
*/
public function testOverwriteProperties() {
// Execute the migration in migrate_overwrite_test, which documents how
// property overwrites work.
$this
->executeMigration('users');
/** @var \Drupal\user\UserInterface $account */
$account = User::load(2);
$this
->assertSame('john.doe', $account
->label());
$this
->assertSame('john.doe@example.com', $account
->getEmail());
$this
->assertSame('The answer is 42.', $account->signature->value);
// This value is not overwritten because it's not listed in
// overwrite_properties.
$this
->assertSame('proto@zo.an', $account
->getInitialEmail());
}
/**
* Tests that translation destination fails for untranslatable entities.
*/
public function testUntranslatable() {
$this
->enableModules([
'language_test',
]);
$this
->installEntitySchema('no_language_entity_test');
/** @var MigrationInterface $migration */
$migration = \Drupal::service('plugin.manager.migration')
->createStubMigration([
'source' => [
'plugin' => 'embedded_data',
'ids' => [
'id' => [
'type' => 'integer',
],
],
'data_rows' => [
[
'id' => 1,
],
],
],
'process' => [
'id' => 'id',
],
'destination' => [
'plugin' => 'entity:no_language_entity_test',
'translations' => TRUE,
],
]);
$message = $this
->prophesize(MigrateMessageInterface::class);
// Match the expected message. Can't use default argument types, because
// we need to convert to string from TranslatableMarkup.
$argument = Argument::that(function ($msg) {
return str_contains((string) $msg, htmlentities('The "no_language_entity_test" entity type does not support translations.'));
});
$message
->display($argument, Argument::any())
->shouldBeCalled();
$executable = new MigrateExecutable($migration, $message
->reveal());
$executable
->import();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityContentBaseTest:: |
protected static | property |
Modules to enable. Overrides MigrateDrupal6TestBase:: |
|
EntityContentBaseTest:: |
protected | function |
Overrides MigrateDrupal6TestBase:: |
|
EntityContentBaseTest:: |
public | function | Tests overwriting all mapped properties in the destination entity. | |
EntityContentBaseTest:: |
public | function | Tests overwriting selected properties in the destination entity. | |
EntityContentBaseTest:: |
public | function | Tests that translation destination fails for untranslatable entities. | |
MigrateDrupal6TestBase:: |
protected | function | Gets the path to the fixture file. | 13 |
MigrateDrupal6TestBase:: |
protected | function | Executes all content migrations. | |
MigrateDrupal6TestBase:: |
protected | function | Migrates node types. | |
MigrateDrupal6TestBase:: |
protected | function | Executes all field migrations. | |
MigrateDrupal6TestBase:: |
protected | function | Executes all taxonomy migrations. | |
MigrateDrupal6TestBase:: |
protected | function | Executes all user migrations. | |
MigrateDrupalTestBase:: |
protected | function | Loads a database fixture into the source database connection. | |
MigrateTestBase:: |
protected | property | TRUE to collect messages instead of displaying them. | |
MigrateTestBase:: |
protected | property | A logger prophecy object. | 2 |
MigrateTestBase:: |
protected | property | A two dimensional array of messages. | |
MigrateTestBase:: |
protected | property | The primary migration being tested. | 1 |
MigrateTestBase:: |
protected | property | The source database connection. | |
MigrateTestBase:: |
private | function | Cleans up the test migrate connection. | |
MigrateTestBase:: |
private | function | Changes the database connection to the prefixed one. | |
MigrateTestBase:: |
public | function |
Displays a migrate message. Overrides MigrateMessageInterface:: |
|
MigrateTestBase:: |
protected | function | Executes a single migration. | |
MigrateTestBase:: |
protected | function | Executes a set of migrations in dependency order. | |
MigrateTestBase:: |
protected | function | Gets the migration plugin. | |
MigrateTestBase:: |
protected | function | Records a failure in the map table of a specific migration. | |
MigrateTestBase:: |
protected | function | Modify a migration's configuration before executing it. | |
MigrateTestBase:: |
protected | function | Prepare any dependent migrations. | |
MigrateTestBase:: |
protected | function | Injects the test logger into the container. | |
MigrateTestBase:: |
public | function | Start collecting messages and erase previous messages. | |
MigrateTestBase:: |
public | function | Stop collecting messages. | |
MigrateTestBase:: |
protected | function | ||
NodeMigrateTypeTestTrait:: |
public | property | The migrate_map table name. | |
NodeMigrateTypeTestTrait:: |
protected | function | Gets the migrate_map table name. | |
NodeMigrateTypeTestTrait:: |
protected | function | Create a node migrate_map table. | |
NodeMigrateTypeTestTrait:: |
protected | function | Gets the numbers of complete and classic node migrate_map tables. | |
NodeMigrateTypeTestTrait:: |
protected | function | Remove the node migrate map table. |