You are here

public function MigrateTestCase::queryResultTest in Drupal 9

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

Tests a query.

Parameters

array|\Traversable $iter: The countable. foreach-able actual results if a query is being run.

array $expected_results: An array of expected results.

4 calls to MigrateTestCase::queryResultTest()
MigrateSqlIdMapTest::testGetRowsNeedingUpdate in core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php
Tests the getRowsNeedingUpdate method for rows that need an update.
MigrateSqlIdMapTest::testPrepareUpdate in core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php
Tests prepareUpdate().
MigrateSqlIdMapTest::testSaveIdMapping in core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php
Tests the ID mapping method.
MigrateSqlIdMapTest::testSetUpdate in core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php
Tests setting a row source_row_status to STATUS_NEEDS_UPDATE.

File

core/modules/migrate/tests/src/Unit/MigrateTestCase.php, line 159

Class

MigrateTestCase
Provides setup and helper methods for Migrate module tests.

Namespace

Drupal\Tests\migrate\Unit

Code

public function queryResultTest($iter, $expected_results) {
  $this
    ->assertSameSize($expected_results, $iter, 'Number of results match');
  $count = 0;
  foreach ($iter as $data_row) {
    $expected_row = $expected_results[$count];
    $count++;
    foreach ($expected_row as $key => $expected_value) {
      $this
        ->retrievalAssertHelper($expected_value, $this
        ->getValue($data_row, $key), sprintf('Value matches for key "%s"', $key));
    }
  }
  $this
    ->assertSame(count($expected_results), $count);
}