You are here

protected function ConflictTrackerTest::resolveConflicts in Multiversion 8

Resolve a conflict and make sure it removed from the tracker.

Parameters

$uuid: The uuid of entity to resolve a conflict for.

1 call to ConflictTrackerTest::resolveConflicts()
ConflictTrackerTest::testConflictTracker in tests/src/Functional/ConflictTrackerTest.php
Tests the Conflict Tracker.

File

tests/src/Functional/ConflictTrackerTest.php, line 105

Class

ConflictTrackerTest
Test the methods on the ConflictTracker class.

Namespace

Drupal\Tests\multiversion\Functional

Code

protected function resolveConflicts($uuid) {

  // Get the conflicts for this entity.
  $expected_conflicts = $this->conflictTracker
    ->get($uuid);
  $revs = array_keys($expected_conflicts);
  foreach ($revs as $rev) {

    // Load and delete one of the revisions in conflict
    $record = \Drupal::service('multiversion.entity_index.rev')
      ->get("{$uuid}:{$rev}");
    $revision = $this->storage
      ->loadRevision($record['revision_id']);
    $revision
      ->delete();

    // Unset the expected conflict for the revision just deleted.
    unset($expected_conflicts[$rev]);
    $tracker_conflicts = $this->conflictTracker
      ->get($uuid);
    $this
      ->assertEqual($tracker_conflicts, $expected_conflicts, 'Resolved conflict removed correctly.');
  }
  $this
    ->assertEqual($tracker_conflicts, [], 'All conflicts resolved for entity.');
}