public function TrackChangesTest::testTrackChanges in Drupal 8
Same name and namespace in other branches
- 9 core/modules/migrate/tests/src/Kernel/TrackChangesTest.php \Drupal\Tests\migrate\Kernel\TrackChangesTest::testTrackChanges()
Tests track changes property of SqlBase.
File
- core/
modules/ migrate/ tests/ src/ Kernel/ TrackChangesTest.php, line 92
Class
- TrackChangesTest
- Tests migration track changes property.
Namespace
Drupal\Tests\migrate\KernelCode
public function testTrackChanges() {
// Assert all of the terms have been imported.
$this
->assertTermExists('name', 'Item 1');
$this
->assertTermExists('name', 'Item 2');
$this
->assertTermExists('description', 'Text item 3');
$this
->assertTermExists('description', 'Text item 4');
// Update Item 1 triggering its track_changes by name.
$this->sourceDatabase
->update('track_changes_term')
->fields([
'name' => 'Item 1 updated',
])
->condition('name', 'Item 1')
->execute();
// Update Item 2 keeping it's track_changes name the same.
$this->sourceDatabase
->update('track_changes_term')
->fields([
'name' => 'Item 2',
])
->condition('name', 'Item 2')
->execute();
// Update Item 3 triggering its track_changes by field.
$this->sourceDatabase
->update('track_changes_term')
->fields([
'description' => 'Text item 3 updated',
])
->condition('name', 'Item 3')
->execute();
// Update Item 2 keeping it's track_changes field the same.
$this->sourceDatabase
->update('track_changes_term')
->fields([
'description' => 'Text item 4',
])
->condition('name', 'Item 4')
->execute();
// Execute migration again.
$this
->executeMigration('track_changes_test');
// Item with name changes should be updated.
$this
->assertTermExists('name', 'Item 1 updated');
$this
->assertTermDoesNotExist('name', 'Item 1');
// Item without name changes should not be updated.
$this
->assertTermExists('name', 'Item 2');
// Item with field changes should be updated.
$this
->assertTermExists('description', 'Text item 3 updated');
$this
->assertTermDoesNotExist('description', 'Text item 3');
// Item without field changes should not be updated.
$this
->assertTermExists('description', 'Text item 4');
}