You are here

protected function MigrateTestCase::getMigration in Zircon Profile 8

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

Retrieve a mocked migration.

Return value

\Drupal\migrate\Entity\MigrationInterface|\PHPUnit_Framework_MockObject_MockObject The mocked migration.

16 calls to MigrateTestCase::getMigration()
DedupeEntityTest::testDedupe in core/modules/migrate/tests/src/Unit/process/DedupeEntityTest.php
Tests entity based deduplication based on providerTestDedupe() values.
DedupeEntityTest::testDedupeEntityInvalidLength in core/modules/migrate/tests/src/Unit/process/DedupeEntityTest.php
Tests that invalid length option throws an exception.
DedupeEntityTest::testDedupeEntityInvalidStart in core/modules/migrate/tests/src/Unit/process/DedupeEntityTest.php
Tests that invalid start position throws an exception.
Drupal6SqlBaseTest::setUp in core/modules/migrate_drupal/tests/src/Unit/source/d6/Drupal6SqlBaseTest.php
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 40
Contains \Drupal\Tests\migrate\Unit\MigrateTestCase.

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\\Entity\\Migration',
  ];
  $this->idMap = $this
    ->getMock('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('get')
    ->willReturnCallback(function ($argument) use (&$configuration) {
    return isset($configuration[$argument]) ? $configuration[$argument] : '';
  });
  $migration
    ->method('set')
    ->willReturnCallback(function ($argument, $value) use (&$configuration) {
    $configuration[$argument] = $value;
  });
  $migration
    ->method('id')
    ->willReturn($configuration['id']);
  return $migration;
}