public function HighWaterTest::testHighWater in Drupal 8
Same name and namespace in other branches
- 9 core/modules/migrate/tests/src/Kernel/HighWaterTest.php \Drupal\Tests\migrate\Kernel\HighWaterTest::testHighWater()
Tests high water property of SqlBase.
File
- core/modules/ migrate/ tests/ src/ Kernel/ HighWaterTest.php, line 87 
Class
- HighWaterTest
- Tests migration high water property.
Namespace
Drupal\Tests\migrate\KernelCode
public function testHighWater() {
  // 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();
  // Execute migration again.
  $this
    ->executeMigration('high_water_test');
  // Item with lower highwater should not be updated.
  $this
    ->assertNodeExists('Item 1');
  $this
    ->assertNodeDoesNotExist('Item 1 updated');
  // Item with equal highwater should not be updated.
  $this
    ->assertNodeExists('Item 2');
  $this
    ->assertNodeDoesNotExist('Item 2 updated');
  // Item with greater highwater should be updated.
  $this
    ->assertNodeExists('Item 3 updated');
  $this
    ->assertNodeDoesNotExist('Item 3');
}