getProcessPlugins example

'@file' => $e->getFile(),
          '@line' => $e->getLine(),
        ]), 'error');
      $this->migration->setStatus(MigrationInterface::STATUS_IDLE);
      return MigrationInterface::RESULT_FAILED;
    }

    // Get the process pipeline.     $pipeline = FALSE;
    if ($source->valid()) {
      try {
        $pipeline = $this->migration->getProcessPlugins();
      }
      catch (MigrateException $e) {
        $row = $source->current();
        $this->sourceIdValues = $row->getSourceIdValues();
        $this->getIdMap()->saveIdMapping($row[]$e->getStatus());
        $this->saveMessage($e->getMessage()$e->getLevel());
      }
    }

    $return = MigrationInterface::RESULT_COMPLETED;
    if ($pipeline) {
      
$destination_plugin = $this->prophesize(MigrateDestinationInterface::class);
    $destination_plugin->import(Argument::type(Row::class))->willReturn(['id' => 2]);

    $source_plugin = $this->prophesize(MigrateSourceInterface::class);
    $source_plugin->getIds()->willReturn(['id' => ['type' => 'integer']]);

    $id_map = $this->prophesize(MigrateIdMapInterface::class);

    $migration = $this->prophesize(MigrationInterface::class);
    $migration->getIdMap()->willReturn($id_map->reveal());
    $migration->getDestinationPlugin(TRUE)->willReturn($destination_plugin->reveal());
    $migration->getProcessPlugins([])->willReturn([]);
    $migration->getProcess()->willReturn([]);
    $migration->getSourceConfiguration()->willReturn([]);
    $migration->getSourcePlugin()->willReturn($source_plugin->reveal());

    $this->migrationPluginManager->createInstances(['test_migration'])->willReturn([$migration->reveal()]);

    $stub = new MigrateStub($this->migrationPluginManager->reveal());

    $this->assertSame(['id' => 2]$stub->createStub('test_migration', ['id' => 1][]));
  }

  

  protected static $modules = ['migrate', 'migrate_expected_migrations_test'];

  /** * Tests Migration::getProcessPlugins() * * @covers ::getProcessPlugins */
  public function testGetProcessPlugins() {
    $migration = \Drupal::service('plugin.manager.migration')->createStubMigration([]);
    $this->assertEquals([]$migration->getProcessPlugins([]));
  }

  /** * Tests Migration::getProcessPlugins() throws an exception. * * @covers ::getProcessPlugins */
  public function testGetProcessPluginsException() {
    $migration = \Drupal::service('plugin.manager.migration')->createStubMigration([]);
    $this->expectException(MigrateException::class);
    $this->expectExceptionMessage('Invalid process configuration for foobar');
    
Home | Imprint | This part of the site doesn't use cookies.