You are here

public function MigrationTest::testTransformWithStubbing in Drupal 8

Tests a lookup with stubbing.

@covers ::transform

@expectedDeprecation Not passing the migrate lookup service as the fifth parameter to Drupal\migrate\Plugin\migrate\process\MigrationLookup::__construct is deprecated in drupal:8.8.0 and will throw a type error in drupal:9.0.0. Pass an instance of \Drupal\migrate\MigrateLookupInterface. See https://www.drupal.org/node/3047268 @expectedDeprecation Not passing the migrate stub service as the sixth parameter to Drupal\migrate\Plugin\migrate\process\MigrationLookup::__construct is deprecated in drupal:8.8.0 and will throw a type error in drupal:9.0.0. Pass an instance of \Drupal\migrate\MigrateStubInterface. See https://www.drupal.org/node/3047268

File

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

Class

MigrationTest
@coversDefaultClass \Drupal\migrate\Plugin\migrate\process\Migration @group migrate @group legacy

Namespace

Drupal\Tests\migrate\Unit\process

Code

public function testTransformWithStubbing() {
  $configuration = [
    'no_stub' => FALSE,
    'migration' => 'destination_migration',
  ];
  $this->migrateLookup
    ->lookup('destination_migration', [
    1,
  ])
    ->willReturn([]);
  $this->migrateStub
    ->createStub('destination_migration', [
    1,
  ], [], FALSE)
    ->willReturn([
    2,
  ]);
  $this
    ->prepareContainer();
  $migration = new Migration($configuration, '', [], $this->migration_plugin
    ->reveal(), $this->migration_plugin_manager
    ->reveal(), $this->process_plugin_manager
    ->reveal());
  $result = $migration
    ->transform(1, $this->migrateExecutable, $this->row, '');
  $this
    ->assertEquals(2, $result);
}