You are here

class SmartSqlTest in Smart SQL ID Map 1.1.x

Same name and namespace in other branches
  1. 1.0.x tests/src/Unit/Plugin/migrate/id_map/SmartSqlTest.php \Drupal\Tests\smart_sql_idmap\Unit\Plugin\migrate\id_map\SmartSqlTest

Tests the Smart SQL ID map plugin.

@group smart_sql_idmap

Hierarchy

Expanded class hierarchy of SmartSqlTest

File

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

Namespace

Drupal\Tests\smart_sql_idmap\Unit\Plugin\migrate\id_map
View source
class SmartSqlTest extends MigrateSqlIdMapTest {

  /**
   * {@inheritdoc}
   */
  protected $migrationConfiguration = [
    'id' => 'smart_sql_idmap_test',
  ];

  /**
   * The expected map table name.
   *
   * @var string
   */
  protected $expectedMapTableName = 'm_map_smart_sql_idmap_test';

  /**
   * The expected map table name with "prefix" as prefix.
   *
   * @var string
   */
  protected $expectedPrefixedMapTableName = 'm_map_smart_sql_idmap_test';

  /**
   * The expected message table name.
   *
   * @var string
   */
  protected $expectedMessageTableName = 'm_message_smart_sql_idmap_test';

  /**
   * Saves a single ID mapping row in the database.
   *
   * @param array $map
   *   The row to save.
   */
  protected function saveMap(array $map) {
    $table = $this
      ->getIdMap()
      ->mapTableName();
    $schema = $this->database
      ->schema();

    // If the table already exists, add any columns which are in the map array,
    // but don't yet exist in the table. Yay, flexibility!
    if ($schema
      ->tableExists($table)) {
      foreach (array_keys($map) as $field) {
        if (!$schema
          ->fieldExists($table, $field)) {
          $schema
            ->addField($table, $field, [
            'type' => 'text',
          ]);
        }
      }
    }
    else {
      $schema
        ->createTable($table, $this
        ->createSchemaFromRow($map));
    }
    $this->database
      ->insert($table)
      ->fields($map)
      ->execute();
  }

  /**
   * Creates a test SQL ID map plugin.
   *
   * @return \Drupal\Tests\smart_sql_idmap\Unit\TestSmartSqlIdMap
   *   A SQL ID map plugin test instance.
   */
  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;
  }

  /**
   * Tests the ID mapping method.
   *
   * Create two ID mappings and update the second to verify that:
   * - saving new to empty tables work.
   * - saving new to nonempty tables work.
   * - updating work.
   */
  public function testSaveIdMapping() {
    $source = [
      'source_id_property' => 'source_value',
    ];
    $row = new Row($source, [
      'source_id_property' => [],
    ]);
    $id_map = $this
      ->getIdMap();
    $id_map
      ->saveIdMapping($row, [
      'destination_id_property' => 2,
    ]);
    $expected_result = [
      [
        'sourceid1' => 'source_value',
        'source_ids_hash' => $this
          ->getIdMap()
          ->getSourceIdsHash($source),
        'destid1' => 2,
      ] + $this
        ->idMapDefaults(),
    ];
    $this
      ->queryResultTest($this
      ->getIdMapContents(), $expected_result);
    $source = [
      'source_id_property' => 'source_value_1',
    ];
    $row = new Row($source, [
      'source_id_property' => [],
    ]);
    $id_map
      ->saveIdMapping($row, [
      'destination_id_property' => 3,
    ]);
    $expected_result[] = [
      'sourceid1' => 'source_value_1',
      'source_ids_hash' => $this
        ->getIdMap()
        ->getSourceIdsHash($source),
      'destid1' => 3,
    ] + $this
      ->idMapDefaults();
    $this
      ->queryResultTest($this
      ->getIdMapContents(), $expected_result);
    $id_map
      ->saveIdMapping($row, [
      'destination_id_property' => 4,
    ]);
    $expected_result[1]['destid1'] = 4;
    $this
      ->queryResultTest($this
      ->getIdMapContents(), $expected_result);
  }

  /**
   * Tests the getRowsNeedingUpdate method for rows that need an update.
   */
  public function testGetRowsNeedingUpdate() {
    $id_map = $this
      ->getIdMap();
    $row_statuses = [
      MigrateIdMapInterface::STATUS_IMPORTED,
      MigrateIdMapInterface::STATUS_NEEDS_UPDATE,
      MigrateIdMapInterface::STATUS_IGNORED,
      MigrateIdMapInterface::STATUS_FAILED,
    ];

    // Create a mapping row for each STATUS constant.
    foreach ($row_statuses as $status) {
      $source = [
        'source_id_property' => 'source_value_' . $status,
      ];
      $row = new Row($source, [
        'source_id_property' => [],
      ]);
      $destination = [
        'destination_id_property' => 'destination_value_' . $status,
      ];
      $id_map
        ->saveIdMapping($row, $destination, $status);
      $expected_results[] = [
        'sourceid1' => 'source_value_' . $status,
        'source_ids_hash' => $this
          ->getIdMap()
          ->getSourceIdsHash($source),
        'destid1' => 'destination_value_' . $status,
        'source_row_status' => $status,
        'rollback_action' => MigrateIdMapInterface::ROLLBACK_DELETE,
        'hash' => '',
      ];

      // Assert zero rows need an update.
      if ($status == MigrateIdMapInterface::STATUS_IMPORTED) {
        $rows_needing_update = $id_map
          ->getRowsNeedingUpdate(1);
        $this
          ->assertCount(0, $rows_needing_update);
      }
    }

    // Assert that test values exist.
    $this
      ->queryResultTest($this
      ->getIdMapContents(), $expected_results);

    // Assert a single row needs an update.
    $row_needing_update = $id_map
      ->getRowsNeedingUpdate(1);
    $this
      ->assertCount(1, $row_needing_update);

    // Assert the row matches its original source.
    $source_id = $expected_results[MigrateIdMapInterface::STATUS_NEEDS_UPDATE]['sourceid1'];
    $test_row = $id_map
      ->getRowBySource([
      'source_id_property' => $source_id,
    ]);

    // $row_needing_update is an array of objects returned from the database,
    // but $test_row is an array, so the cast is necessary.
    $this
      ->assertSame($test_row, (array) $row_needing_update[0]);

    // Add additional row that needs an update.
    $source = [
      'source_id_property' => 'source_value_multiple',
    ];
    $row = new Row($source, [
      'source_id_property' => [],
    ]);
    $destination = [
      'destination_id_property' => 'destination_value_multiple',
    ];
    $id_map
      ->saveIdMapping($row, $destination, MigrateIdMapInterface::STATUS_NEEDS_UPDATE);

    // Assert multiple rows need an update.
    $rows_needing_update = $id_map
      ->getRowsNeedingUpdate(2);
    $this
      ->assertCount(2, $rows_needing_update);
  }

  /**
   * Tests lookupDestinationIds().
   */
  public function testLookupDestinationIds() {

    // Simple map with one source and one destination ID.
    $id_map = $this
      ->setupRows([
      'nid',
    ], [
      'nid',
    ], [
      [
        1,
        101,
      ],
      [
        2,
        102,
      ],
      [
        3,
        103,
      ],
    ]);

    // Lookup nothing, gives nothing.
    $this
      ->assertEquals([], $id_map
      ->lookupDestinationIds([]));

    // Lookup by complete non-associative list.
    $this
      ->assertEquals([
      [
        101,
      ],
    ], $id_map
      ->lookupDestinationIds([
      1,
    ]));
    $this
      ->assertEquals([
      [
        102,
      ],
    ], $id_map
      ->lookupDestinationIds([
      2,
    ]));
    $this
      ->assertEquals([], $id_map
      ->lookupDestinationIds([
      99,
    ]));

    // Lookup by complete associative list.
    $this
      ->assertEquals([
      [
        101,
      ],
    ], $id_map
      ->lookupDestinationIds([
      'nid' => 1,
    ]));
    $this
      ->assertEquals([
      [
        102,
      ],
    ], $id_map
      ->lookupDestinationIds([
      'nid' => 2,
    ]));
    $this
      ->assertEquals([], $id_map
      ->lookupDestinationIds([
      'nid' => 99,
    ]));

    // Map with multiple source and destination IDs.
    $id_map = $this
      ->setupRows([
      'nid',
      'language',
    ], [
      'nid',
      'langcode',
    ], [
      [
        1,
        'en',
        101,
        'en',
      ],
      [
        1,
        'fr',
        101,
        'fr',
      ],
      [
        1,
        'de',
        101,
        'de',
      ],
      [
        2,
        'en',
        102,
        'en',
      ],
    ]);

    // Lookup nothing, gives nothing.
    $this
      ->assertEquals([], $id_map
      ->lookupDestinationIds([]));

    // Lookup by complete non-associative list.
    $this
      ->assertEquals([
      [
        101,
        'en',
      ],
    ], $id_map
      ->lookupDestinationIds([
      1,
      'en',
    ]));
    $this
      ->assertEquals([
      [
        101,
        'fr',
      ],
    ], $id_map
      ->lookupDestinationIds([
      1,
      'fr',
    ]));
    $this
      ->assertEquals([
      [
        102,
        'en',
      ],
    ], $id_map
      ->lookupDestinationIds([
      2,
      'en',
    ]));
    $this
      ->assertEquals([], $id_map
      ->lookupDestinationIds([
      2,
      'fr',
    ]));
    $this
      ->assertEquals([], $id_map
      ->lookupDestinationIds([
      99,
      'en',
    ]));

    // Lookup by complete associative list.
    $this
      ->assertEquals([
      [
        101,
        'en',
      ],
    ], $id_map
      ->lookupDestinationIds([
      'nid' => 1,
      'language' => 'en',
    ]));
    $this
      ->assertEquals([
      [
        101,
        'fr',
      ],
    ], $id_map
      ->lookupDestinationIds([
      'nid' => 1,
      'language' => 'fr',
    ]));
    $this
      ->assertEquals([
      [
        102,
        'en',
      ],
    ], $id_map
      ->lookupDestinationIds([
      'nid' => 2,
      'language' => 'en',
    ]));
    $this
      ->assertEquals([], $id_map
      ->lookupDestinationIds([
      'nid' => 2,
      'language' => 'fr',
    ]));
    $this
      ->assertEquals([], $id_map
      ->lookupDestinationIds([
      'nid' => 99,
      'language' => 'en',
    ]));

    // Lookup by partial non-associative list.
    $this
      ->assertEquals([
      [
        101,
        'en',
      ],
      [
        101,
        'fr',
      ],
      [
        101,
        'de',
      ],
    ], $id_map
      ->lookupDestinationIds([
      1,
    ]));
    $this
      ->assertEquals([
      [
        102,
        'en',
      ],
    ], $id_map
      ->lookupDestinationIds([
      2,
    ]));
    $this
      ->assertEquals([], $id_map
      ->lookupDestinationIds([
      99,
    ]));

    // Lookup by partial associative list.
    $this
      ->assertEquals([
      [
        101,
        'en',
      ],
      [
        101,
        'fr',
      ],
      [
        101,
        'de',
      ],
    ], $id_map
      ->lookupDestinationIds([
      'nid' => 1,
    ]));
    $this
      ->assertEquals([
      [
        102,
        'en',
      ],
    ], $id_map
      ->lookupDestinationIds([
      'nid' => 2,
    ]));
    $this
      ->assertEquals([], $id_map
      ->lookupDestinationIds([
      'nid' => 99,
    ]));
    $this
      ->assertEquals([
      [
        101,
        'en',
      ],
      [
        101,
        'fr',
      ],
      [
        101,
        'de',
      ],
    ], $id_map
      ->lookupDestinationIds([
      'nid' => 1,
      'language' => NULL,
    ]));
    $this
      ->assertEquals([
      [
        102,
        'en',
      ],
    ], $id_map
      ->lookupDestinationIds([
      'nid' => 2,
      'language' => NULL,
    ]));

    // Out-of-order partial associative list.
    $this
      ->assertEquals([
      [
        101,
        'en',
      ],
      [
        102,
        'en',
      ],
    ], $id_map
      ->lookupDestinationIds([
      'language' => 'en',
    ]));
    $this
      ->assertEquals([
      [
        101,
        'fr',
      ],
    ], $id_map
      ->lookupDestinationIds([
      'language' => 'fr',
    ]));
    $this
      ->assertEquals([], $id_map
      ->lookupDestinationIds([
      'language' => 'zh',
    ]));

    // Error conditions.
    try {
      $id_map
        ->lookupDestinationIds([
        1,
        2,
        3,
      ]);
      $this
        ->fail('Too many source IDs should throw');
    } catch (MigrateException $e) {
      $this
        ->assertEquals("Extra unknown items for map {$this->expectedMapTableName} in source IDs: array (\n  0 => 3,\n)", $e
        ->getMessage());
    }
    try {
      $id_map
        ->lookupDestinationIds([
        'nid' => 1,
        'aaa' => '2',
      ]);
      $this
        ->fail('Unknown source ID key should throw');
    } catch (MigrateException $e) {
      $this
        ->assertEquals("Extra unknown items for map {$this->expectedMapTableName} in source IDs: array (\n  'aaa' => '2',\n)", $e
        ->getMessage());
    }

    // Verify that we are looking up by source_id_hash when all source IDs are
    // passed in.
    $id_map
      ->getDatabase()
      ->update($id_map
      ->mapTableName())
      ->condition('sourceid1', 1)
      ->condition('sourceid2', 'en')
      ->fields([
      TestSmartSqlIdMap::SOURCE_IDS_HASH => uniqid(),
    ])
      ->execute();
    $this
      ->assertNotEquals([
      [
        101,
        'en',
      ],
    ], $id_map
      ->lookupDestinationIds([
      1,
      'en',
    ]));
  }

  /**
   * Tests setting a row source_row_status to STATUS_NEEDS_UPDATE.
   */
  public function testSetUpdate() {
    $id_map = $this
      ->getIdMap();
    $row_statuses = [
      MigrateIdMapInterface::STATUS_IMPORTED,
      MigrateIdMapInterface::STATUS_NEEDS_UPDATE,
      MigrateIdMapInterface::STATUS_IGNORED,
      MigrateIdMapInterface::STATUS_FAILED,
    ];

    // Create a mapping row for each STATUS constant.
    foreach ($row_statuses as $status) {
      $source = [
        'source_id_property' => 'source_value_' . $status,
      ];
      $row = new Row($source, [
        'source_id_property' => [],
      ]);
      $destination = [
        'destination_id_property' => 'destination_value_' . $status,
      ];
      $id_map
        ->saveIdMapping($row, $destination, $status);
      $expected_results[] = [
        'sourceid1' => 'source_value_' . $status,
        'source_ids_hash' => $this
          ->getIdMap()
          ->getSourceIdsHash($source),
        'destid1' => 'destination_value_' . $status,
        'source_row_status' => $status,
        'rollback_action' => MigrateIdMapInterface::ROLLBACK_DELETE,
        'hash' => '',
      ];
    }

    // Assert that test values exist.
    $this
      ->queryResultTest($this
      ->getIdMapContents(), $expected_results);

    // Mark each row as STATUS_NEEDS_UPDATE.
    foreach ($row_statuses as $status) {
      $id_map
        ->setUpdate([
        'source_id_property' => 'source_value_' . $status,
      ]);
    }

    // Update expected results.
    foreach ($expected_results as $key => $value) {
      $expected_results[$key]['source_row_status'] = MigrateIdMapInterface::STATUS_NEEDS_UPDATE;
    }

    // Assert that updated expected values match.
    $this
      ->queryResultTest($this
      ->getIdMapContents(), $expected_results);

    // Assert an exception is thrown when source identifiers are not provided.
    try {
      $id_map
        ->setUpdate([]);
      $this
        ->assertFalse(FALSE, 'MigrateException not thrown, when source identifiers were provided to update.');
    } catch (MigrateException $e) {
      $this
        ->assertTrue(TRUE, "MigrateException thrown, when source identifiers were not provided to update.");
    }
  }

  /**
   * Tests prepareUpdate().
   */
  public function testPrepareUpdate() {
    $id_map = $this
      ->getIdMap();
    $row_statuses = [
      MigrateIdMapInterface::STATUS_IMPORTED,
      MigrateIdMapInterface::STATUS_NEEDS_UPDATE,
      MigrateIdMapInterface::STATUS_IGNORED,
      MigrateIdMapInterface::STATUS_FAILED,
    ];

    // Create a mapping row for each STATUS constant.
    foreach ($row_statuses as $status) {
      $source = [
        'source_id_property' => 'source_value_' . $status,
      ];
      $row = new Row($source, [
        'source_id_property' => [],
      ]);
      $destination = [
        'destination_id_property' => 'destination_value_' . $status,
      ];
      $id_map
        ->saveIdMapping($row, $destination, $status);
      $expected_results[] = [
        'sourceid1' => 'source_value_' . $status,
        'destid1' => 'destination_value_' . $status,
        'source_row_status' => $status,
        'rollback_action' => MigrateIdMapInterface::ROLLBACK_DELETE,
        'hash' => '',
      ];
    }

    // Assert that test values exist.
    $this
      ->queryResultTest($this
      ->getIdMapContents(), $expected_results);

    // Mark all rows as STATUS_NEEDS_UPDATE.
    $id_map
      ->prepareUpdate();

    // Update expected results.
    foreach ($expected_results as $key => $value) {
      $expected_results[$key]['source_row_status'] = MigrateIdMapInterface::STATUS_NEEDS_UPDATE;
    }

    // Assert that updated expected values match.
    $this
      ->queryResultTest($this
      ->getIdMapContents(), $expected_results);
  }

  /**
   * Tests the getQualifiedMapTable method with a prefixed database.
   */
  public function testGetQualifiedMapTablePrefix() {
    $connection_options = [
      'database' => ':memory:',
      'prefix' => 'prefix',
    ];
    $pdo = Connection::open($connection_options);
    $this->database = new Connection($pdo, $connection_options);
    $qualified_map_table = $this
      ->getIdMap()
      ->getQualifiedMapTableName();

    // The SQLite driver is a special flower. It will prefix tables with
    // PREFIX.TABLE, instead of the standard PREFIXTABLE.
    // @see \Drupal\Core\Database\Driver\sqlite\Connection::__construct()
    $this
      ->assertEquals("prefix.{$this->expectedPrefixedMapTableName}", $qualified_map_table);
  }

  /**
   * Retrieves the contents of an ID map.
   *
   * @return array
   *   The contents of an ID map.
   */
  private function getIdMapContents() {
    $result = $this->database
      ->select($this
      ->getIdMap()
      ->getQualifiedMapTableName(), 't')
      ->fields('t')
      ->execute();

    // The return value needs to be countable, or it will fail certain
    // assertions. iterator_to_array() will not suffice because it won't
    // respect the PDO fetch mode, if specified.
    $contents = [];
    foreach ($result as $row) {
      $contents[] = (array) $row;
    }
    return $contents;
  }

  /**
   * Tests the delayed creation of the "map" and "message" migrate tables.
   */
  public function testMapTableCreation() {
    $id_map = $this
      ->getIdMap();
    $map_table_name = $id_map
      ->mapTableName();
    $message_table_name = $id_map
      ->messageTableName();

    // Check that tables names do exist.
    $this
      ->assertEquals($this->expectedMapTableName, $map_table_name);
    $this
      ->assertEquals($this->expectedMessageTableName, $message_table_name);

    // Check that tables don't exist.
    $this
      ->assertFalse($this->database
      ->schema()
      ->tableExists($map_table_name));
    $this
      ->assertFalse($this->database
      ->schema()
      ->tableExists($message_table_name));
    $id_map
      ->getDatabase();

    // Check that tables do exist.
    $this
      ->assertTrue($this->database
      ->schema()
      ->tableExists($map_table_name));
    $this
      ->assertTrue($this->database
      ->schema()
      ->tableExists($message_table_name));
  }

  /**
   * Tests the getRowByDestination method.
   */
  public function testGetRowByDestination() {
    try {
      parent::testGetRowByDestination();
    } catch (ExpectationFailedException $exception) {

      // The parent test method may throw an expectation failed exception,
      // because expects that the sql ID map plugin violates its interface,
      // meaning that it returns FALSE.
      $message_is_about_actual_array_is_not_false = preg_match('/^Failed asserting that Array .*/', $exception
        ->getMessage()) && preg_match('/.* is false\\.$/', $exception
        ->getMessage()) || preg_match('/^Failed asserting that an array is empty.$/', $exception
        ->getMessage());
      if (!$message_is_about_actual_array_is_not_false) {
        throw $exception;
      }
    }
    $id_map = $this
      ->getIdMap();

    // This value does not exist, getRowByDestination should return an (empty)
    // array.
    // @see \Drupal\migrate\Plugin\MigrateIdMapInterface::getRowByDestination()
    $missing_result_row = $id_map
      ->getRowByDestination([
      'destination_id_property' => 'invalid_destination_id_property',
    ]);
    $this
      ->assertIsArray($missing_result_row);

    // The destination ID values array does not contain all the destination ID
    // keys, we expect an empty array.
    $invalid_result_row = $id_map
      ->getRowByDestination([
      'invalid_destination_key' => 'invalid_destination_id_property',
    ]);
    $this
      ->assertIsArray($invalid_result_row);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MigrateSqlIdMapTest::$database protected property The database connection.
MigrateSqlIdMapTest::$destinationIds protected property The destination IDs.
MigrateSqlIdMapTest::$sourceIds protected property The source IDs.
MigrateSqlIdMapTest::errorCountDataProvider public function Data provider for testErrorCount().
MigrateSqlIdMapTest::getHighestIdDataProvider public function Data provider for getHighestId().
MigrateSqlIdMapTest::getHighestIdInvalidDataProvider public function Data provider for testGetHighestIdInvalid().
MigrateSqlIdMapTest::idMapDefaults protected function Sets defaults for SQL ID map plugin tests.
MigrateSqlIdMapTest::lookupDestinationIdMappingDataProvider public function Data provider for testLookupDestinationIdMapping().
MigrateSqlIdMapTest::lookupSourceIdMappingDataProvider public function Data provider for testLookupSourceIdMapping().
MigrateSqlIdMapTest::setUp protected function Overrides UnitTestCase::setUp
MigrateSqlIdMapTest::setupRows protected function Setup a database with the given rows.
MigrateSqlIdMapTest::testClearMessages public function Tests the clear messages method.
MigrateSqlIdMapTest::testCurrentDestinationAndSource public function Tests currentDestination() and currentSource().
MigrateSqlIdMapTest::testDestroy public function Tests the destroy method.
MigrateSqlIdMapTest::testErrorCount public function Performs error count test with a given number of error rows.
MigrateSqlIdMapTest::testGetHighestId public function Tests getHighestId method.
MigrateSqlIdMapTest::testGetHighestIdInvalid public function Tests getHighestId method with invalid data.
MigrateSqlIdMapTest::testGetRowBySource public function Tests the getRowBySource method.
MigrateSqlIdMapTest::testImportedCount public function Tests the imported count method.
MigrateSqlIdMapTest::testIterators public function Tests all the iterator methods in one swing.
MigrateSqlIdMapTest::testLookupDestinationIdMapping public function Performs destination ID test on source and destination fields.
MigrateSqlIdMapTest::testLookupSourceIdMapping public function Performs the source ID test on source and destination fields.
MigrateSqlIdMapTest::testMessageCount public function Tests the SQL ID map message count method by counting and saving messages.
MigrateSqlIdMapTest::testMessageSave public function Tests the SQL ID map save message method.
MigrateSqlIdMapTest::testProcessedCount public function Tests the number of processed source rows.
MigrateSqlIdMapTest::testSetMessage public function Tests the SQL ID map set message method.
MigrateSqlIdMapTest::testUpdateCount public function Performs the update count test with a given number of update rows.
MigrateSqlIdMapTest::updateCountDataProvider public function Data provider for testUpdateCount().
MigrateTestCase::$idMap protected property The migration ID map.
MigrateTestCase::$migrationStatus protected property Local store for mocking setStatus()/getStatus().
MigrateTestCase::createSchemaFromRow protected function Generates a table schema from a row.
MigrateTestCase::getDatabase protected function Gets an SQLite database connection object for use in tests.
MigrateTestCase::getMigration protected function Retrieves a mocked migration.
MigrateTestCase::getValue protected function Gets the value on a row for a given key.
MigrateTestCase::queryResultTest public function Tests a query.
MigrateTestCase::retrievalAssertHelper protected function Asserts tested values during test retrieval.
PhpUnitWarnings::$deprecationWarnings private static property Deprecation warnings from PHPUnit to raise with @trigger_error().
PhpUnitWarnings::addWarning public function Converts PHPUnit deprecation warnings to E_USER_DEPRECATED.
SmartSqlTest::$expectedMapTableName protected property The expected map table name. 2
SmartSqlTest::$expectedMessageTableName protected property The expected message table name. 2
SmartSqlTest::$expectedPrefixedMapTableName protected property The expected map table name with "prefix" as prefix. 2
SmartSqlTest::$migrationConfiguration protected property The migration configuration, initialized to set the ID and destination IDs. Overrides MigrateSqlIdMapTest::$migrationConfiguration 2
SmartSqlTest::getIdMap protected function Creates a test SQL ID map plugin. Overrides MigrateSqlIdMapTest::getIdMap
SmartSqlTest::getIdMapContents private function Retrieves the contents of an ID map. Overrides MigrateSqlIdMapTest::getIdMapContents
SmartSqlTest::saveMap protected function Saves a single ID mapping row in the database. Overrides MigrateSqlIdMapTest::saveMap
SmartSqlTest::testGetQualifiedMapTablePrefix public function Tests the getQualifiedMapTable method with a prefixed database. Overrides MigrateSqlIdMapTest::testGetQualifiedMapTablePrefix
SmartSqlTest::testGetRowByDestination public function Tests the getRowByDestination method. Overrides MigrateSqlIdMapTest::testGetRowByDestination
SmartSqlTest::testGetRowsNeedingUpdate public function Tests the getRowsNeedingUpdate method for rows that need an update. Overrides MigrateSqlIdMapTest::testGetRowsNeedingUpdate
SmartSqlTest::testLookupDestinationIds public function Tests lookupDestinationIds(). Overrides MigrateSqlIdMapTest::testLookupDestinationIds
SmartSqlTest::testMapTableCreation public function Tests the delayed creation of the "map" and "message" migrate tables. Overrides MigrateSqlIdMapTest::testMapTableCreation
SmartSqlTest::testPrepareUpdate public function Tests prepareUpdate(). Overrides MigrateSqlIdMapTest::testPrepareUpdate
SmartSqlTest::testSaveIdMapping public function Tests the ID mapping method. Overrides MigrateSqlIdMapTest::testSaveIdMapping
SmartSqlTest::testSetUpdate public function Tests setting a row source_row_status to STATUS_NEEDS_UPDATE. Overrides MigrateSqlIdMapTest::testSetUpdate
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root. 1
UnitTestCase::assertArrayEquals Deprecated protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.
UnitTestCase::setUpBeforeClass public static function