VersionByRel example

$this->node2 = Node::create([
      'type' => 'dummy',
      'title' => 'Another test node',
      'uid' => $this->user->id(),
    ]);
    $this->node2->save();

    $entity_type_manager = \Drupal::entityTypeManager();
    $version_negotiator = new VersionNegotiator();
    $version_negotiator->addVersionNegotiator(new VersionById($entity_type_manager), 'id');
    $version_negotiator->addVersionNegotiator(new VersionByRel($entity_type_manager), 'rel');
    $this->versionNegotiator = $version_negotiator;

  }

  /** * @covers \Drupal\jsonapi\Revisions\VersionById::getRevision */
  public function testOldRevision() {
    $revision = $this->versionNegotiator->getRevision($this->node, 'id:' . $this->nodePreviousRevisionId);
    $this->assertEquals($this->node->id()$revision->id());
    $this->assertEquals($this->nodePreviousRevisionId, $revision->getRevisionId());
  }
Home | Imprint | This part of the site doesn't use cookies.