You are here

protected function ConflictTrackerTest::checkEntityConflicts in Multiversion 8

Checks the conflict tracker for one entity.

Return value

array keys - uuid of entity values - The conflicts array as returned from ConflictTracker::get().

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

File

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

Class

ConflictTrackerTest
Test the methods on the ConflictTracker class.

Namespace

Drupal\Tests\multiversion\Functional

Code

protected function checkEntityConflicts($revision_start = 0) {

  /** @var \Drupal\entity_test\Entity\EntityTest $entity */
  $entity = $this->storage
    ->create();
  $uuid = $entity
    ->uuid();

  // Create a conflict scenario to fully test the parsing.
  // Initial revision.
  $entity
    ->save();
  $revs[] = $entity->_rev->value;
  $entity
    ->save();
  $revs[] = $entity->_rev->value;
  $entity
    ->save();
  $revs[] = $leaf_one = $entity->_rev->value;

  // Create a new branch from the second revision.
  $entity = $this->storage
    ->loadRevision($revision_start + 2);
  $entity
    ->save();
  $revs[] = $entity->_rev->value;

  // Continue the last branch.
  $entity = $this->storage
    ->loadRevision($revision_start + 4);
  $entity
    ->save();
  $revs[] = $entity->_rev->value;

  // Create a new branch based on the first revision.
  $entity = $this->storage
    ->loadRevision($revision_start + 1);
  $entity
    ->save();
  $revs[] = $entity->_rev->value;
  $expected_conflicts = [
    $revs[2] => 'available',
    $revs[5] => 'available',
  ];
  $tracker_conflicts = $this->conflictTracker
    ->get($uuid);
  $this
    ->assertEqual($tracker_conflicts, $expected_conflicts, 'Tracker conflicts are correct');
  return [
    $uuid => $tracker_conflicts,
  ];
}