You are here

public function RelationAPITest::testRelationRevision in Relation 8

Same name and namespace in other branches
  1. 8.2 src/Tests/RelationAPITest.php \Drupal\relation\Tests\RelationAPITest::testRelationRevision()

Tests relation revisions.

File

src/Tests/RelationAPITest.php, line 287

Class

RelationAPITest
Test general API for Relation.

Namespace

Drupal\relation\Tests

Code

public function testRelationRevision() {

  /* todo Uncomment when revisions are fixed.
      $first_user = $this->drupalCreateUser(['edit relations']);
      $second_user = $this->drupalCreateUser(['edit relations']);

      $this->drupalLogin($first_user);
      $relation = Relation::create(array('relation_type' => $this->relation_type_octopus));
      $relation->endpoints = $this->endpoints_4;
      $relation->save();
      $relation_id = $relation->id();
      $this->assertEqual($relation->id(), $first_user->id(), 'Relation uid set to logged in user.');
      $revision_id = $relation->getRevisionId();

      // Relation should still be owned by the first user.
      $this->drupalLogin($second_user);
      $relation = Relation::load($relation_id);
      $relation = $this->container->get('entity_type.manager')->getStorage('relation')->load($relation_id);
      $relation->save();
      $this->assertEqual($relation->id(), $first_user->id(), 'Relation uid did not get changed to a user different to original.');

      // Relation revision authors should not be identical though.
      $first_revision = $this->container->get('entity_type.manager')->getStorage('relation')->loadRevision($revision_id);
      $second_revision = $this->container->get('entity_type.manager')->getStorage('relation')->loadRevision($relation->getRevisionId());
      $this->assertNotIdentical($first_revision->revision_uid, $second_revision->revision_uid, 'Each revision has a distinct user.');
      */
}