TestMigrateExecutable example

'id' => ['type' => 'integer'],
        ],
      ],
      'destination' => [
        'plugin' => 'null',
      ],
    ];

    /** @var \Drupal\migrate\Plugin\migration $migration */
    $migration = \Drupal::service('plugin.manager.migration')
      ->createStubMigration($definition);
    $this->executable = new TestMigrateExecutable($migration);

    // Plugin being tested.     $this->logPlugin = \Drupal::service('plugin.manager.migrate.process')
      ->createInstance('log');
  }

  /** * Tests the Log plugin. */
  public function testLog() {
    $values = [
      
'migration_tags' => ['Embedded data test'],
      'source' => [
        'plugin' => 'embedded_data',
        'data_rows' => $data_rows,
        'ids' => $ids,
      ],
      'process' => [],
      'destination' => ['plugin' => 'entity:entity_test'],
    ];

    $migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
    $executable = new TestMigrateExecutable($migration);
    $this->assertEquals(MigrationInterface::RESULT_COMPLETED, $executable->import());

    // Test the exception message when a process plugin throws a     // MigrateSkipRowException. Change the definition to have one data row and a     // process that will throw a MigrateSkipRowException on every row.     $definition['source']['data_rows'] = [
      [
        'key' => '1',
        'field1' => 'f1value1',
      ],
    ];
    


  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    static::$idMapRecords = [];
    $this->migration = $this->getMigration();
    $this->message = $this->createMock('Drupal\migrate\MigrateMessageInterface');
    $this->eventDispatcher = $this->createMock('Symfony\Contracts\EventDispatcher\EventDispatcherInterface');
    $this->executable = new TestMigrateExecutable($this->migration, $this->message, $this->eventDispatcher);
    $this->executable->setStringTranslation($this->getStringTranslationStub());
  }

  /** * Tests an import with an incomplete rewinding. */
  public function testImportWithFailingRewind() {
    $exception_message = $this->getRandomGenerator()->string();
    $source = $this->createMock('Drupal\migrate\Plugin\MigrateSourceInterface');
    $source->expects($this->once())
      ->method('rewind')
      

  protected $memoryLimit = 10000000;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->migration = $this->getMigration();
    $this->message = $this->createMock('Drupal\migrate\MigrateMessageInterface');

    $this->executable = new TestMigrateExecutable($this->migration, $this->message);
    $this->executable->setStringTranslation($this->getStringTranslationStub());
  }

  /** * Runs the actual test. * * @param string $message * The second message to assert. * @param bool $memory_exceeded * Whether to test the memory exceeded case. * @param int|null $memory_usage_first * (optional) The first memory usage value. Defaults to NULL. * @param int|null $memory_usage_second * (optional) The fake amount of memory usage reported after memory reclaim. * Defaults to NULL. * @param int|null $memory_limit * (optional) The memory limit. Defaults to NULL. */
Home | Imprint | This part of the site doesn't use cookies.