function MigrateSqlIdMapTest::testErrorCount

Same name in other branches
  1. 9 core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest::testErrorCount()
  2. 8.9.x core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest::testErrorCount()
  3. 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 863

Class

MigrateSqlIdMapTest
Tests the SQL ID map plugin.

Namespace

Drupal\Tests\migrate\Unit

Code

public function testErrorCount($num_error_rows) : void {
    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());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.