You are here

protected function MigrateTestCase::getMigration in Drupal 9

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

Retrieves a mocked migration.

Return value

\Drupal\migrate\Plugin\MigrationInterface|\PHPUnit\Framework\MockObject\MockObject The mocked migration.

19 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

... See full list

File

core/modules/migrate/tests/src/Unit/MigrateTestCase.php, line 42

Class

MigrateTestCase
Provides setup and helper methods for Migrate module tests.

Namespace

Drupal\Tests\migrate\Unit

Code

protected function getMigration() {
  $this->migrationConfiguration += [
    'migrationClass' => 'Drupal\\migrate\\Plugin\\Migration',
  ];
  $this->idMap = $this
    ->createMock('Drupal\\migrate\\Plugin\\MigrateIdMapInterface');
  $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;
}