You are here

public function MigrateTestCase::queryResultTest in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/migrate/tests/src/Unit/MigrateTestCase.php \Drupal\Tests\migrate\Unit\MigrateTestCase::queryResultTest()
  2. 9 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.

File

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

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);
}