You are here

protected function DomMigrationLookupTest::setUp in Migrate Plus 8.5

Overrides MigrateProcessTestCase::setUp

File

tests/src/Unit/process/DomMigrationLookupTest.php, line 61

Class

DomMigrationLookupTest
Tests the dom_migration_lookup process plugin.

Namespace

Drupal\Tests\migrate_plus\Unit\process

Code

protected function setUp() : void {
  parent::setUp();

  // Mock a  migration.
  $prophecy = $this
    ->prophesize(MigrationInterface::class);
  $this->migration = $prophecy
    ->reveal();

  // Mock two migration lookup plugins.
  $prophecy = $this
    ->prophesize(MigrateProcessInterface::class);
  $prophecy
    ->transform('123', $this->migrateExecutable, $this->row, 'destinationproperty')
    ->willReturn('321');
  $prophecy
    ->transform('456', $this->migrateExecutable, $this->row, 'destinationproperty')
    ->willReturn(NULL);
  $users_lookup_plugin = $prophecy
    ->reveal();
  $prophecy = $this
    ->prophesize(MigrateProcessInterface::class);
  $prophecy
    ->transform('123', $this->migrateExecutable, $this->row, 'destinationproperty')
    ->willReturn('ignored');
  $prophecy
    ->transform('456', $this->migrateExecutable, $this->row, 'destinationproperty')
    ->willReturn('654');
  $people_lookup_plugin = $prophecy
    ->reveal();

  // Mock a process plugin manager.
  $prophecy = $this
    ->prophesize(MigratePluginManager::class);
  $users_configuration = [
    'migration' => 'users',
    'no_stub' => TRUE,
  ];
  $people_configuration = [
    'migration' => 'people',
    'no_stub' => TRUE,
  ];
  $prophecy
    ->createInstance('migration_lookup', $users_configuration, $this->migration)
    ->willReturn($users_lookup_plugin);
  $prophecy
    ->createInstance('migration_lookup', $people_configuration, $this->migration)
    ->willReturn($people_lookup_plugin);
  $this->processPluginManager = $prophecy
    ->reveal();
}