function HighWaterTest::testHighWaterUpdate
Same name in other branches
- 9 core/modules/migrate/tests/src/Kernel/HighWaterTest.php \Drupal\Tests\migrate\Kernel\HighWaterTest::testHighWaterUpdate()
- 8.9.x core/modules/migrate/tests/src/Kernel/HighWaterTest.php \Drupal\Tests\migrate\Kernel\HighWaterTest::testHighWaterUpdate()
- 11.x core/modules/migrate/tests/src/Kernel/HighWaterTest.php \Drupal\Tests\migrate\Kernel\HighWaterTest::testHighWaterUpdate()
Tests high water property of SqlBase when rows marked for update.
File
-
core/
modules/ migrate/ tests/ src/ Kernel/ HighWaterTest.php, line 212
Class
- HighWaterTest
- Tests migration high water property.
Namespace
Drupal\Tests\migrate\KernelCode
public function testHighWaterUpdate() : void {
// Assert all of the nodes have been imported.
$this->assertNodeExists('Item 1');
$this->assertNodeExists('Item 2');
$this->assertNodeExists('Item 3');
// Update Item 1 setting its high_water_property to value that is below
// current high water mark.
$this->sourceDatabase
->update('high_water_node')
->fields([
'title' => 'Item 1 updated',
'changed' => 2,
])
->condition('title', 'Item 1')
->execute();
// Update Item 2 setting its high_water_property to value equal to
// current high water mark.
$this->sourceDatabase
->update('high_water_node')
->fields([
'title' => 'Item 2 updated',
'changed' => 3,
])
->condition('title', 'Item 2')
->execute();
// Update Item 3 setting its high_water_property to value that is above
// current high water mark.
$this->sourceDatabase
->update('high_water_node')
->fields([
'title' => 'Item 3 updated',
'changed' => 4,
])
->condition('title', 'Item 3')
->execute();
// Set all rows as needing an update.
$id_map = $this->getMigration('high_water_test')
->getIdMap();
$id_map->prepareUpdate();
$this->executeMigration('high_water_test');
// Item with lower high water should be updated.
$this->assertNodeExists('Item 1 updated');
$this->assertNodeDoesNotExist('Item 1');
// Item with equal high water should be updated.
$this->assertNodeExists('Item 2 updated');
$this->assertNodeDoesNotExist('Item 2');
// Item with greater high water should be updated.
$this->assertNodeExists('Item 3 updated');
$this->assertNodeDoesNotExist('Item 3');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.