You are here

public function DrupalSqlBaseTest::testSourceProviderNotActive in Drupal 8

Same name and namespace in other branches
  1. 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 44

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_definition['requirements_met'] = TRUE;
  $plugin_definition['source_module'] = 'module1';

  /** @var \Drupal\Core\State\StateInterface $state */
  $state = $this
    ->createMock('Drupal\\Core\\State\\StateInterface');

  /** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager */
  $entity_type_manager = $this
    ->createMock('Drupal\\Core\\Entity\\EntityTypeManagerInterface');
  $plugin = new TestDrupalSqlBase([], 'placeholder_id', $plugin_definition, $this
    ->getMigration(), $state, $entity_type_manager);
  $plugin
    ->setDatabase($this
    ->getDatabase($this->databaseContents));
  $system_data = $plugin
    ->getSystemData();
  $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;
  }
}