You are here

public function DrupalSqlBaseTest::testSourceProviderNotActive in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/migrate_drupal/tests/src/Unit/source/DrupalSqlBaseTest.php \Drupal\Tests\migrate_drupal\Unit\source\DrupalSqlBaseTest::testSourceProviderNotActive()
  2. 9 core/modules/migrate_drupal/tests/src/Unit/source/DrupalSqlBaseTest.php \Drupal\Tests\migrate_drupal\Unit\source\DrupalSqlBaseTest::testSourceProviderNotActive()

@covers ::checkRequirements

File

core/modules/migrate_drupal/tests/src/Unit/source/DrupalSqlBaseTest.php, line 78

Class

DrupalSqlBaseTest
@coversDefaultClass \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase @group migrate_drupal

Namespace

Drupal\Tests\migrate_drupal\Unit\source

Code

public function testSourceProviderNotActive() {
  $plugin = new TestDrupalSqlBase([], 'placeholder_id', $this->pluginDefinition, $this
    ->getMigration(), $this->state, $this->entityTypeManager);
  $plugin
    ->setDatabase($this
    ->getDatabase($this->databaseContents));
  $this
    ->expectException(RequirementsException::class);
  $this
    ->expectExceptionMessage('The module module1 is not enabled in the source site.');
  try {
    $plugin
      ->checkRequirements();
  } catch (RequirementsException $e) {

    // Ensure requirements are set on the exception.
    $this
      ->assertEquals([
      'source_module' => 'module1',
    ], $e
      ->getRequirements());

    // Re-throw so PHPUnit can assert the exception.
    throw $e;
  }
}