Update to Drupal 8.0.0-beta15. For more information, see: https://www.drupal.org/node/2563023
This commit is contained in:
parent
2720a9ec4b
commit
f3791f1da3
1898 changed files with 54300 additions and 11481 deletions
|
|
@ -59,7 +59,28 @@ abstract class MigrateTestBase extends KernelTestBase implements MigrateMessageI
|
|||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->createMigrationConnection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the database connection to the prefixed one.
|
||||
*
|
||||
* @todo Remove when we don't use global. https://www.drupal.org/node/2552791
|
||||
*/
|
||||
private function createMigrationConnection() {
|
||||
// If the backup already exists, something went terribly wrong.
|
||||
// This case is possible, because database connection info is a static
|
||||
// global state construct on the Database class, which at least persists
|
||||
// for all test methods executed in one PHP process.
|
||||
if (Database::getConnectionInfo('simpletest_original_migrate')) {
|
||||
throw new \RuntimeException("Bad Database connection state: 'simpletest_original_migrate' connection key already exists. Broken test?");
|
||||
}
|
||||
|
||||
// Clone the current connection and replace the current prefix.
|
||||
$connection_info = Database::getConnectionInfo('migrate');
|
||||
if ($connection_info) {
|
||||
Database::renameConnection('migrate', 'simpletest_original_migrate');
|
||||
}
|
||||
$connection_info = Database::getConnectionInfo('default');
|
||||
foreach ($connection_info as $target => $value) {
|
||||
$prefix = is_array($value['prefix']) ? $value['prefix']['default'] : $value['prefix'];
|
||||
|
|
@ -78,8 +99,24 @@ abstract class MigrateTestBase extends KernelTestBase implements MigrateMessageI
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
protected function tearDown() {
|
||||
Database::removeConnection('migrate');
|
||||
$this->cleanupMigrateConnection();
|
||||
parent::tearDown();
|
||||
$this->databaseDumpFiles = [];
|
||||
$this->collectMessages = FALSE;
|
||||
unset($this->migration, $this->migrateMessages);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans up the test migrate connection.
|
||||
*
|
||||
* @todo Remove when we don't use global. https://www.drupal.org/node/2552791
|
||||
*/
|
||||
private function cleanupMigrateConnection() {
|
||||
Database::removeConnection('migrate');
|
||||
$original_connection_info = Database::getConnectionInfo('simpletest_original_migrate');
|
||||
if ($original_connection_info) {
|
||||
Database::renameConnection('simpletest_original_migrate', 'migrate');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -113,20 +150,19 @@ abstract class MigrateTestBase extends KernelTestBase implements MigrateMessageI
|
|||
* ids.
|
||||
*/
|
||||
protected function prepareMigrations(array $id_mappings) {
|
||||
/** @var \Drupal\migrate\Entity\MigrationInterface[] $migrations */
|
||||
$migrations = entity_load_multiple('migration', array_keys($id_mappings));
|
||||
foreach ($id_mappings as $migration_id => $data) {
|
||||
$migration = $migrations[$migration_id];
|
||||
// Use loadMultiple() here in order to load all variants.
|
||||
foreach (Migration::loadMultiple([$migration_id]) as $migration) {
|
||||
// Mark the dependent migrations as complete.
|
||||
$migration->setMigrationResult(MigrationInterface::RESULT_COMPLETED);
|
||||
|
||||
// Mark the dependent migrations as complete.
|
||||
$migration->setMigrationResult(MigrationInterface::RESULT_COMPLETED);
|
||||
|
||||
$id_map = $migration->getIdMap();
|
||||
$id_map->setMessage($this);
|
||||
$source_ids = $migration->getSourcePlugin()->getIds();
|
||||
foreach ($data as $id_mapping) {
|
||||
$row = new Row(array_combine(array_keys($source_ids), $id_mapping[0]), $source_ids);
|
||||
$id_map->saveIdMapping($row, $id_mapping[1]);
|
||||
$id_map = $migration->getIdMap();
|
||||
$id_map->setMessage($this);
|
||||
$source_ids = $migration->getSourcePlugin()->getIds();
|
||||
foreach ($data as $id_mapping) {
|
||||
$row = new Row(array_combine(array_keys($source_ids), $id_mapping[0]), $source_ids);
|
||||
$id_map->saveIdMapping($row, $id_mapping[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue