You are here

public function MigrationTest::testMigrationDependenciesWithInvalidConfig in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/migrate/tests/src/Unit/MigrationTest.php \Drupal\Tests\migrate\Unit\MigrationTest::testMigrationDependenciesWithInvalidConfig()

Tests that getting migration dependencies fails with invalid configuration.

@covers ::getMigrationDependencies

File

core/modules/migrate/tests/src/Unit/MigrationTest.php, line 155
Contains \Drupal\Tests\migrate\Unit\MigrationTest.

Class

MigrationTest
@coversDefaultClass \Drupal\migrate\Plugin\Migration

Namespace

Drupal\Tests\migrate\Unit

Code

public function testMigrationDependenciesWithInvalidConfig() {
  $migration = new TestMigration();

  // Set the plugin ID to test the returned message.
  $plugin_id = 'test_migration';
  $migration
    ->setPluginId($plugin_id);

  // Migration dependencies expects ['optional' => []] or ['required' => []]].
  $migration
    ->set('migration_dependencies', [
    'test_migration_dependency',
  ]);
  $this
    ->expectException(InvalidPluginDefinitionException::class);
  $this
    ->expectExceptionMessage("Invalid migration dependencies configuration for migration {$plugin_id}");
  $migration
    ->getMigrationDependencies();
}