You are here

public function HighWaterTest::testZeroHighwater in Drupal 8

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

Tests that the high water value can be 0.

File

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

Class

HighWaterTest
Tests migration high water property.

Namespace

Drupal\Tests\migrate\Kernel

Code

public function testZeroHighwater() {

  // 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 to 0.
  $this->container
    ->get('keyvalue')
    ->get('migrate:high_water')
    ->set('high_water_test', 0);
  $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);
}