You are here

protected function SmartSqlTest::getIdMap in Smart SQL ID Map 1.0.x

Same name and namespace in other branches
  1. 1.1.x tests/src/Unit/Plugin/migrate/id_map/SmartSqlTest.php \Drupal\Tests\smart_sql_idmap\Unit\Plugin\migrate\id_map\SmartSqlTest::getIdMap()

Creates a test SQL ID map plugin.

Return value

\Drupal\Tests\smart_sql_idmap\Unit\TestSmartSqlIdMap A SQL ID map plugin test instance.

Overrides MigrateSqlIdMapTest::getIdMap

5 calls to SmartSqlTest::getIdMap()
SmartSqlTest::testGetRowsNeedingUpdate in tests/src/Unit/Plugin/migrate/id_map/SmartSqlTest.php
Tests the getRowsNeedingUpdate method for rows that need an update.
SmartSqlTest::testMapTableCreation in tests/src/Unit/Plugin/migrate/id_map/SmartSqlTest.php
Tests the delayed creation of the "map" and "message" migrate tables.
SmartSqlTest::testPrepareUpdate in tests/src/Unit/Plugin/migrate/id_map/SmartSqlTest.php
Tests prepareUpdate().
SmartSqlTest::testSaveIdMapping in tests/src/Unit/Plugin/migrate/id_map/SmartSqlTest.php
Tests the ID mapping method.
SmartSqlTest::testSetUpdate in tests/src/Unit/Plugin/migrate/id_map/SmartSqlTest.php
Tests setting a row source_row_status to STATUS_NEEDS_UPDATE.

File

tests/src/Unit/Plugin/migrate/id_map/SmartSqlTest.php, line 80

Class

SmartSqlTest
Tests the Smart SQL ID map plugin.

Namespace

Drupal\Tests\smart_sql_idmap\Unit\Plugin\migrate\id_map

Code

protected function getIdMap() {
  $migration = $this
    ->getMigration();
  $plugin = $this
    ->createMock('Drupal\\migrate\\Plugin\\MigrateSourceInterface');
  $plugin
    ->method('getIds')
    ->willReturn($this->sourceIds);
  $migration
    ->method('getSourcePlugin')
    ->willReturn($plugin);
  $plugin = $this
    ->createMock('Drupal\\migrate\\Plugin\\MigrateDestinationInterface');
  $plugin
    ->method('getIds')
    ->willReturn($this->destinationIds);
  $migration
    ->method('getDestinationPlugin')
    ->willReturn($plugin);
  $event_dispatcher = $this
    ->createMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
  $migration_plugin_manager = $this
    ->createMock(MigrationPluginManagerInterface::class);
  $base_plugin_id = substr($migration
    ->id(), 0, strpos($migration
    ->id(), PluginBase::DERIVATIVE_SEPARATOR));
  if ($base_plugin_id) {
    $migration_plugin_manager
      ->expects($this
      ->any())
      ->method('getDefinitions')
      ->willReturn([]);
  }
  $id_map = new TestSmartSqlIdMap($this->database, $migration_plugin_manager, [], 'smart_sql', [], $migration, $event_dispatcher);
  $migration
    ->method('getIdMap')
    ->willReturn($id_map);
  return $id_map;
}