function MigrateSqlIdMapTest::testClearMessages

Same name in other branches
  1. 9 core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest::testClearMessages()
  2. 8.9.x core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest::testClearMessages()
  3. 10 core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest::testClearMessages()

Tests the clear messages method.

File

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

Class

MigrateSqlIdMapTest
Tests the SQL ID map plugin.

Namespace

Drupal\Tests\migrate\Unit

Code

public function testClearMessages() : void {
    $message = 'Hello world.';
    $expected_results = [
        0,
        1,
        2,
        3,
    ];
    $id_map = $this->getIdMap();
    // Insert 4 message for later delete.
    foreach ($expected_results as $key => $expected_result) {
        $id_map->saveMessage([
            'source_id_property' => $key,
        ], $message);
    }
    // Truncate and check that 4 messages were deleted.
    $this->assertSame($id_map->messageCount(), 4);
    $id_map->clearMessages();
    $count = $id_map->messageCount();
    $this->assertSame($count, 0);
}

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