TestSqlIdMap example

$plugin = $this->createMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
    $plugin
      ->method('getIds')
      ->willReturn($this->destinationIds);
    $migration
      ->method('getDestinationPlugin')
      ->willReturn($plugin);
    $event_dispatcher = $this->createMock('Symfony\Contracts\EventDispatcher\EventDispatcherInterface');
    $migration_manager = $this->createMock('Drupal\migrate\Plugin\MigrationPluginManagerInterface');

    $id_map = new TestSqlIdMap($this->database, [], 'sql', []$migration$event_dispatcher$migration_manager);
    $migration
      ->method('getIdMap')
      ->willReturn($id_map);

    return $id_map;
  }

  /** * Sets defaults for SQL ID map plugin tests. * * @return array * An associative array with the following keys: * - source_row_status * - rollback_action * - hash */
->willReturn([
        'destination_id_property' => [
          'type' => 'string',
        ],
      ]);
    $migration->expects($this->any())
      ->method('getDestinationPlugin')
      ->willReturn($plugin);
    /** @var \Symfony\Contracts\EventDispatcher\EventDispatcherInterface $event_dispatcher */
    $event_dispatcher = $this->createMock('Symfony\Contracts\EventDispatcher\EventDispatcherInterface');
    $migration_manager = $this->createMock('Drupal\migrate\Plugin\MigrationPluginManagerInterface');
    $map = new TestSqlIdMap($database[], 'sql', []$migration$event_dispatcher$migration_manager);
    $map->getDatabase();
  }

}


  /** * Tests that ensureTables creates the migrate map table. * * @dataProvider providerTestEnsureTables */
  public function testEnsureTables($ids) {
    $this->migrationDefinition['source']['ids'] = $ids;
    $migration = $this->migrationPluginManager->createStubMigration($this->migrationDefinition);

    $map = new TestSqlIdMap($this->database, [], 'test', []$migration$this->eventDispatcher, $this->migrationPluginManager);
    $map->ensureTables();

    // Checks that the map table was created.     $exists = $this->database->schema()->tableExists('migrate_map_test');
    $this->assertTrue($exists);
  }

  /** * Provides data for testEnsureTables. */
  public function providerTestEnsureTables() {
    
Home | Imprint | This part of the site doesn't use cookies.