protected function MigrateTestCase::getMigration in Drupal 10
Same name and namespace in other branches
- 8 core/modules/migrate/tests/src/Unit/MigrateTestCase.php \Drupal\Tests\migrate\Unit\MigrateTestCase::getMigration()
- 9 core/modules/migrate/tests/src/Unit/MigrateTestCase.php \Drupal\Tests\migrate\Unit\MigrateTestCase::getMigration()
Retrieves a mocked migration.
Parameters
\Drupal\migrate\Plugin\MigrateIdMapInterface|\PHPUnit\Framework\MockObject\MockObject|null $id_map: An ID map plugin to use, or NULL for using a mocked one. Optional, defaults to NULL.
Return value
\Drupal\migrate\Plugin\MigrationInterface|\PHPUnit\Framework\MockObject\MockObject The mocked migration.
10 calls to MigrateTestCase::getMigration()
- Drupal6SqlBaseTest::setUp in core/
modules/ migrate_drupal/ tests/ src/ Unit/ source/ d6/ Drupal6SqlBaseTest.php - DrupalSqlBaseTest::testMinimumVersion in core/
modules/ migrate_drupal/ tests/ src/ Unit/ source/ DrupalSqlBaseTest.php - @covers ::checkRequirements
- DrupalSqlBaseTest::testSourceDatabaseError in core/
modules/ migrate_drupal/ tests/ src/ Unit/ source/ DrupalSqlBaseTest.php - @covers ::checkRequirements
- DrupalSqlBaseTest::testSourceProviderNotActive in core/
modules/ migrate_drupal/ tests/ src/ Unit/ source/ DrupalSqlBaseTest.php - @covers ::checkRequirements
- FileUriTest::doTransform in core/
modules/ file/ tests/ src/ Unit/ Plugin/ migrate/ process/ d6/ FileUriTest.php
File
- core/
modules/ migrate/ tests/ src/ Unit/ MigrateTestCase.php, line 47
Class
- MigrateTestCase
- Provides setup and helper methods for Migrate module tests.
Namespace
Drupal\Tests\migrate\UnitCode
protected function getMigration($id_map = NULL) {
$this->migrationConfiguration += [
'migrationClass' => 'Drupal\\migrate\\Plugin\\Migration',
];
$this->idMap = $id_map;
if (is_null($id_map)) {
$this->idMap = $this
->createMock(MigrateIdMapInterface::class);
$this->idMap
->method('getQualifiedMapTableName')
->willReturn('test_map');
}
$migration = $this
->getMockBuilder($this->migrationConfiguration['migrationClass'])
->disableOriginalConstructor()
->getMock();
$migration
->method('checkRequirements')
->willReturn(TRUE);
$migration
->method('getIdMap')
->willReturn($this->idMap);
// We need the state to be toggled throughout the test so we store the value
// on the test class and use a return callback.
$migration
->expects($this
->any())
->method('getStatus')
->willReturnCallback(function () {
return $this->migrationStatus;
});
$migration
->expects($this
->any())
->method('setStatus')
->willReturnCallback(function ($status) {
$this->migrationStatus = $status;
});
$migration
->method('getMigrationDependencies')
->willReturn([
'required' => [],
'optional' => [],
]);
$configuration =& $this->migrationConfiguration;
$migration
->method('set')
->willReturnCallback(function ($argument, $value) use (&$configuration) {
$configuration[$argument] = $value;
});
$migration
->method('id')
->willReturn($configuration['id']);
return $migration;
}