function MigrateSqlIdMapTest::testGetHighestId
Tests getHighestId method.
@dataProvider getHighestIdDataProvider
Parameters
array $destination_ids: Array of destination ids.
array $rows: Array of map table rows.
int $expected: Expected highest id value.
File
- 
              core/modules/ migrate/ tests/ src/ Unit/ MigrateSqlIdMapTest.php, line 1101 
Class
- MigrateSqlIdMapTest
- Tests the SQL ID map plugin.
Namespace
Drupal\Tests\migrate\UnitCode
public function testGetHighestId(array $destination_ids, array $rows, $expected) : void {
  $this->database = $this->getDatabase([]);
  $this->sourceIds = $destination_ids;
  $this->destinationIds = $destination_ids;
  $db_keys = [];
  $dest_id_count = count($destination_ids);
  for ($i = 1; $i <= $dest_id_count; $i++) {
    $db_keys[$i] = "sourceid{$i}";
  }
  for ($i = 1; $i <= $dest_id_count; $i++) {
    $db_keys[] = "destid{$i}";
  }
  $id_map = $this->getIdMap();
  foreach ($rows as $row) {
    $values = array_combine($db_keys, $row);
    $source_values = array_slice($row, 0, $dest_id_count);
    $values['source_ids_hash'] = $id_map->getSourceIdsHash($source_values);
    $this->saveMap($values);
  }
  $actual = $id_map->getHighestId();
  $this->assertSame($expected, $actual);
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
