Mercurial > hg > isophonics-drupal-site
diff core/modules/migrate/tests/src/Kernel/HighWaterTest.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 4c8ae668cc8c |
children |
line wrap: on
line diff
--- a/core/modules/migrate/tests/src/Kernel/HighWaterTest.php Tue Jul 10 15:07:59 2018 +0100 +++ b/core/modules/migrate/tests/src/Kernel/HighWaterTest.php Thu Feb 28 13:21:36 2019 +0000 @@ -137,6 +137,72 @@ } /** + * Tests that the high water value can be 0. + */ + 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); + } + + /** + * Tests that deleting the high water value causes all rows to be reimported. + */ + 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); + } + + /** * Tests high water property of SqlBase when rows marked for update. */ public function testHighWaterUpdate() {