function MigrateTestCase::getMigration

Same name in other branches
  1. 9 core/modules/migrate/tests/src/Unit/MigrateTestCase.php \Drupal\Tests\migrate\Unit\MigrateTestCase::getMigration()
  2. 10 core/modules/migrate/tests/src/Unit/MigrateTestCase.php \Drupal\Tests\migrate\Unit\MigrateTestCase::getMigration()
  3. 11.x 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.

28 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.
DedupeEntityTest::testDedupeMigrated in core/modules/migrate/tests/src/Unit/process/DedupeEntityTest.php
Test deduplicating only migrated entities.
Drupal6SqlBaseTest::setUp in core/modules/migrate_drupal/tests/src/Unit/source/d6/Drupal6SqlBaseTest.php

... See full list

1 method overrides MigrateTestCase::getMigration()
MigrationTest::getMigration in core/modules/migrate/tests/src/Unit/process/MigrationTest.php
Creates a mock Migration instance.

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;
}

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