function MigrateMissingDatabaseTest::testMissingDatabase

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

Tests a SQL migration without the database connection.

  • The migration can be instantiated.
  • The checkRequirements() method throws a RequirementsException.

File

core/modules/migrate/tests/src/Kernel/MigrateMissingDatabaseTest.php, line 51

Class

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

Namespace

Drupal\Tests\migrate\Kernel

Code

public function testMissingDatabase() : void {
    if (Database::getConnection()->driver() === 'sqlite') {
        $this->markTestSkipped('Not compatible with sqlite');
    }
    $migration = $this->migrationPluginManager
        ->createInstance('missing_database');
    $this->assertInstanceOf(MigrationInterface::class, $migration);
    $this->assertInstanceOf(MigrateIdMapInterface::class, $migration->getIdMap());
    $this->expectException(RequirementsException::class);
    $this->expectExceptionMessage('No database connection available for source plugin migrate_missing_database_test');
    $migration->checkRequirements();
}

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