You are here

public function MigrateSqlIdMapTest::testErrorCount in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest::testErrorCount()
  2. 10 core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest::testErrorCount()

Performs error count test with a given number of error rows.

@dataProvider errorCountDataProvider

Parameters

int $num_error_rows: Number of error rows to test.

File

core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php, line 822

Class

MigrateSqlIdMapTest
Tests the SQL ID map plugin.

Namespace

Drupal\Tests\migrate\Unit

Code

public function testErrorCount($num_error_rows) {
  for ($i = 0; $i < 5; $i++) {
    $row = $this
      ->idMapDefaults();
    $row['sourceid1'] = "source_id_value_{$i}";
    $row['source_ids_hash'] = $this
      ->getIdMap()
      ->getSourceIdsHash([
      'source_id_property' => $row['sourceid1'],
    ]);
    $row['destid1'] = "destination_id_value_{$i}";
    $row['source_row_status'] = MigrateIdMapInterface::STATUS_IMPORTED;
    $this
      ->saveMap($row);
  }
  for (; $i < 5 + $num_error_rows; $i++) {
    $row = $this
      ->idMapDefaults();
    $row['sourceid1'] = "source_id_value_{$i}";
    $row['source_ids_hash'] = $this
      ->getIdMap()
      ->getSourceIdsHash([
      'source_id_property' => $row['sourceid1'],
    ]);
    $row['destid1'] = "destination_id_value_{$i}";
    $row['source_row_status'] = MigrateIdMapInterface::STATUS_FAILED;
    $this
      ->saveMap($row);
  }
  $this
    ->assertSame($num_error_rows, $this
    ->getIdMap()
    ->errorCount());
}