You are here

public function GraphCreationTest::testGraphCreation3 in Multiversion 8

Graph structure defined in /vendor/relaxedws/lca/pictures/simple_graph.png

File

tests/src/Functional/GraphCreationTest.php, line 205

Class

GraphCreationTest
Test the getGraph method from the RevisionTreeIndex class.

Namespace

Drupal\Tests\multiversion\Functional

Code

public function testGraphCreation3() {
  $storage = $this->entityTypeManager
    ->getStorage('entity_test_rev');
  $entity = $storage
    ->create();
  $uuid = $entity
    ->uuid();
  $entity
    ->save();
  $revs[] = $entity->_rev->value;
  $entity
    ->save();
  $revs[] = $entity->_rev->value;
  $entity
    ->save();
  $revs[] = $entity->_rev->value;
  $entity
    ->save();
  $revs[] = $entity->_rev->value;
  $entity
    ->save();
  $revs[] = $entity->_rev->value;
  $entity
    ->save();
  $revs[] = $entity->_rev->value;
  $entity = $storage
    ->loadRevision(3);
  $entity
    ->save();
  $revs[] = $entity->_rev->value;
  $entity = $storage
    ->loadRevision(3);
  $entity
    ->save();
  $revs[] = $entity->_rev->value;
  $entity = $storage
    ->loadRevision(4);
  $entity
    ->save();
  $revs[] = $entity->_rev->value;
  $entity = $storage
    ->loadRevision(7);
  $entity
    ->save();
  $revs[] = $entity->_rev->value;
  $entity = $storage
    ->loadRevision(8);
  $entity
    ->save();
  $revs[] = $entity->_rev->value;
  $entity = $storage
    ->loadRevision(1);
  $entity
    ->save();
  $revs[] = $entity->_rev->value;
  $entity = $storage
    ->loadRevision(12);
  $entity
    ->save();
  $revs[] = $entity->_rev->value;
  $entity = $storage
    ->loadRevision(13);
  $entity
    ->save();
  $revs[] = $entity->_rev->value;
  $entity = $storage
    ->loadRevision(13);
  $entity
    ->save();
  $revs[] = $entity->_rev->value;
  $entity = $storage
    ->loadRevision(14);
  $entity
    ->save();
  $revs[] = $entity->_rev->value;
  $entity = $storage
    ->loadRevision(15);
  $entity
    ->save();
  $revs[] = $entity->_rev->value;
  $entity = $storage
    ->loadRevision(16);
  $entity
    ->save();
  $revs[] = $entity->_rev->value;
  $entity = $storage
    ->loadRevision(16);
  $entity
    ->save();
  $revs[] = $entity->_rev->value;
  $entity = $storage
    ->loadRevision(17);
  $entity
    ->save();
  $revs[] = $entity->_rev->value;
  $entity = $storage
    ->loadRevision(5);
  $entity
    ->save();
  $revs[] = $entity->_rev->value;
  $graph = $this->tree
    ->getGraph($uuid);
  $vertices = $graph
    ->getVertices()
    ->getMap();
  foreach ($vertices[$revs[1]]
    ->getVerticesEdgeFrom() as $parent) {
    $this
      ->assertEqual($parent
      ->getId(), $revs[0], 'node 2\'s parent is 1');
  }
  foreach ($vertices[$revs[2]]
    ->getVerticesEdgeFrom() as $parent) {
    $this
      ->assertEqual($parent
      ->getId(), $revs[1], 'node 3\'s parent is 2');
  }
  foreach ($vertices[$revs[3]]
    ->getVerticesEdgeFrom() as $parent) {
    $this
      ->assertEqual($parent
      ->getId(), $revs[2], 'node 4\'s parent is 3');
  }
  foreach ($vertices[$revs[4]]
    ->getVerticesEdgeFrom() as $parent) {
    $this
      ->assertEqual($parent
      ->getId(), $revs[3], 'node 5\'s parent is 4');
  }
  foreach ($vertices[$revs[5]]
    ->getVerticesEdgeFrom() as $parent) {
    $this
      ->assertEqual($parent
      ->getId(), $revs[4], 'node 6\'s parent is 5');
  }
  foreach ($vertices[$revs[6]]
    ->getVerticesEdgeFrom() as $parent) {
    $this
      ->assertEqual($parent
      ->getId(), $revs[2], 'node 7\'s parent is 3');
  }
  foreach ($vertices[$revs[7]]
    ->getVerticesEdgeFrom() as $parent) {
    $this
      ->assertEqual($parent
      ->getId(), $revs[2], 'node 8\'s parent is 3');
  }
  foreach ($vertices[$revs[8]]
    ->getVerticesEdgeFrom() as $parent) {
    $this
      ->assertEqual($parent
      ->getId(), $revs[3], 'node 9\'s parent is 4');
  }
  foreach ($vertices[$revs[9]]
    ->getVerticesEdgeFrom() as $parent) {
    $this
      ->assertEqual($parent
      ->getId(), $revs[6], 'node 10\'s parent is 7');
  }
  foreach ($vertices[$revs[10]]
    ->getVerticesEdgeFrom() as $parent) {
    $this
      ->assertEqual($parent
      ->getId(), $revs[7], 'node 11\'s parent is 8');
  }
  foreach ($vertices[$revs[11]]
    ->getVerticesEdgeFrom() as $parent) {
    $this
      ->assertEqual($parent
      ->getId(), $revs[0], 'node 12\'s parent is 1');
  }
  foreach ($vertices[$revs[12]]
    ->getVerticesEdgeFrom() as $parent) {
    $this
      ->assertEqual($parent
      ->getId(), $revs[11], 'node 13\'s parent is 12');
  }
  foreach ($vertices[$revs[13]]
    ->getVerticesEdgeFrom() as $parent) {
    $this
      ->assertEqual($parent
      ->getId(), $revs[12], 'node 14\'s parent is 13');
  }
  foreach ($vertices[$revs[14]]
    ->getVerticesEdgeFrom() as $parent) {
    $this
      ->assertEqual($parent
      ->getId(), $revs[12], 'node 15\'s parent is 13');
  }
  foreach ($vertices[$revs[15]]
    ->getVerticesEdgeFrom() as $parent) {
    $this
      ->assertEqual($parent
      ->getId(), $revs[13], 'node 16\'s parent is 14');
  }
  foreach ($vertices[$revs[16]]
    ->getVerticesEdgeFrom() as $parent) {
    $this
      ->assertEqual($parent
      ->getId(), $revs[14], 'node 17\'s parent is 15');
  }
  foreach ($vertices[$revs[17]]
    ->getVerticesEdgeFrom() as $parent) {
    $this
      ->assertEqual($parent
      ->getId(), $revs[15], 'node 18\'s parent is 16');
  }
  foreach ($vertices[$revs[18]]
    ->getVerticesEdgeFrom() as $parent) {
    $this
      ->assertEqual($parent
      ->getId(), $revs[15], 'node 19\'s parent is 16');
  }
  foreach ($vertices[$revs[19]]
    ->getVerticesEdgeFrom() as $parent) {
    $this
      ->assertEqual($parent
      ->getId(), $revs[16], 'node 20\'s parent is 17');
  }
  foreach ($vertices[$revs[20]]
    ->getVerticesEdgeFrom() as $parent) {
    $this
      ->assertEqual($parent
      ->getId(), $revs[4], 'node 21\'s parent is 5');
  }
}