function MigrationTest::testRequirementsForSourcePlugin

Same name in other branches
  1. 8.9.x core/modules/migrate/tests/src/Unit/MigrationTest.php \Drupal\Tests\migrate\Unit\MigrationTest::testRequirementsForSourcePlugin()
  2. 10 core/modules/migrate/tests/src/Unit/MigrationTest.php \Drupal\Tests\migrate\Unit\MigrationTest::testRequirementsForSourcePlugin()
  3. 11.x core/modules/migrate/tests/src/Unit/MigrationTest.php \Drupal\Tests\migrate\Unit\MigrationTest::testRequirementsForSourcePlugin()

Tests checking requirements for source plugins.

@covers ::checkRequirements

File

core/modules/migrate/tests/src/Unit/MigrationTest.php, line 32

Class

MigrationTest
@coversDefaultClass \Drupal\migrate\Plugin\Migration

Namespace

Drupal\Tests\migrate\Unit

Code

public function testRequirementsForSourcePlugin() {
    $migration = new TestMigration();
    $source_plugin = $this->createMock('Drupal\\Tests\\migrate\\Unit\\RequirementsAwareSourceInterface');
    $source_plugin->expects($this->once())
        ->method('checkRequirements')
        ->willThrowException(new RequirementsException('Missing source requirement', [
        'key' => 'value',
    ]));
    $destination_plugin = $this->createMock('Drupal\\Tests\\migrate\\Unit\\RequirementsAwareDestinationInterface');
    $migration->setSourcePlugin($source_plugin);
    $migration->setDestinationPlugin($destination_plugin);
    $this->expectException(RequirementsException::class);
    $this->expectExceptionMessage('Missing source requirement');
    $migration->checkRequirements();
}

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