function MigrateMissingDatabaseTest::testMissingDatabase

Same name in this branch
  1. 11.x core/modules/migrate/tests/src/Kernel/MigrateMissingDatabaseTest.php \Drupal\Tests\migrate\Kernel\MigrateMissingDatabaseTest::testMissingDatabase()
Same name in other branches
  1. 10 core/modules/migrate_drupal/tests/src/Kernel/MigrateMissingDatabaseTest.php \Drupal\Tests\migrate_drupal\Kernel\MigrateMissingDatabaseTest::testMissingDatabase()
  2. 10 core/modules/migrate/tests/src/Kernel/MigrateMissingDatabaseTest.php \Drupal\Tests\migrate\Kernel\MigrateMissingDatabaseTest::testMissingDatabase()

Tests that a migration can be instantiated with the node module enabled.

When the migrate_drupal and node modules are enabled, the migration derivers call checkRequirements() whenever createInstance() is used. If the database connection is not available, then Migration::setUpDatabase() throws an exception. Check that the exception is caught and the migration can still be used to access its IdMap.

File

core/modules/migrate_drupal/tests/src/Kernel/MigrateMissingDatabaseTest.php, line 53

Class

MigrateMissingDatabaseTest
Tests that a migration can be instantiated without a database connection.

Namespace

Drupal\Tests\migrate_drupal\Kernel

Code

public function testMissingDatabase() : void {
    $migration = $this->migrationPluginManager
        ->createInstance('d7_node_type');
    $this->assertInstanceOf(MigrationInterface::class, $migration);
    $this->assertInstanceOf(MigrateIdMapInterface::class, $migration->getIdMap());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.