You are here

public function HighWaterTest::testNullHighwater in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/migrate/tests/src/Kernel/HighWaterTest.php \Drupal\Tests\migrate\Kernel\HighWaterTest::testNullHighwater()

Tests that deleting the high water value causes all rows to be reimported.

File

core/modules/migrate/tests/src/Kernel/HighWaterTest.php, line 175

Class

HighWaterTest
Tests migration high water property.

Namespace

Drupal\Tests\migrate\Kernel

Code

public function testNullHighwater() {

  // Assert all of the nodes have been imported.
  $this
    ->assertNodeExists('Item 1');
  $this
    ->assertNodeExists('Item 2');
  $this
    ->assertNodeExists('Item 3');
  $migration = $this->container
    ->get('plugin.manager.migration')
    ->CreateInstance('high_water_test', []);
  $source = $migration
    ->getSourcePlugin();
  $source
    ->rewind();
  $count = 0;
  while ($source
    ->valid()) {
    $count++;
    $source
      ->next();
  }

  // Expect no rows as everything is below the high water mark.
  $this
    ->assertSame(0, $count);

  // Test resetting the high water mark.
  $this->container
    ->get('keyvalue')
    ->get('migrate:high_water')
    ->delete('high_water_test');
  $migration = $this->container
    ->get('plugin.manager.migration')
    ->CreateInstance('high_water_test', []);
  $source = $migration
    ->getSourcePlugin();
  $source
    ->rewind();
  $count = 0;
  while ($source
    ->valid()) {
    $count++;
    $source
      ->next();
  }
  $this
    ->assertSame(3, $count);
}