function HighWaterTest::testNullHighwater

Same name in other branches
  1. 8.9.x core/modules/migrate/tests/src/Kernel/HighWaterTest.php \Drupal\Tests\migrate\Kernel\HighWaterTest::testNullHighwater()
  2. 10 core/modules/migrate/tests/src/Kernel/HighWaterTest.php \Drupal\Tests\migrate\Kernel\HighWaterTest::testNullHighwater()
  3. 11.x 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 177

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);
}

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