You are here

public function MigrateSqlIdMapTest::testMessageCount 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::testMessageCount()
  2. 10 core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest::testMessageCount()

Tests the SQL ID map message count method by counting and saving messages.

File

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

Class

MigrateSqlIdMapTest
Tests the SQL ID map plugin.

Namespace

Drupal\Tests\migrate\Unit

Code

public function testMessageCount() {
  $message = 'Hello world.';
  $expected_results = [
    0,
    1,
    2,
    3,
  ];
  $id_map = $this
    ->getIdMap();

  // Test count message multiple times starting from 0.
  foreach ($expected_results as $key => $expected_result) {
    $count = $id_map
      ->messageCount();
    $this
      ->assertSame($expected_result, $count);
    $id_map
      ->saveMessage([
      'source_id_property' => $key,
    ], $message);
  }
}