You are here

public function MigrateSqlIdMapTest::testMessageCount in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 262
Contains \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest.

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
      ->assertEquals($expected_result, $count);
    $id_map
      ->saveMessage([
      'source_id_property' => $key,
    ], $message);
  }
}