function RevisionRouteProviderTest::testRevisionTitle

Same name in other branches
  1. 11.x core/tests/Drupal/FunctionalTests/Entity/RevisionRouteProviderTest.php \Drupal\FunctionalTests\Entity\RevisionRouteProviderTest::testRevisionTitle()

Tests title is from revision in context.

File

core/tests/Drupal/FunctionalTests/Entity/RevisionRouteProviderTest.php, line 42

Class

RevisionRouteProviderTest
Tests revision route provider.

Namespace

Drupal\FunctionalTests\Entity

Code

public function testRevisionTitle() : void {
    $entity = EntityTestRev::create();
    $entity->setName('first revision, view revision')
        ->setNewRevision();
    $entity->save();
    $revisionId = $entity->getRevisionId();
    // A default revision is created to ensure it is not pulled from the
    // non-revision entity parameter.
    $entity->setName('second revision, view revision')
        ->setNewRevision();
    $entity->isDefaultRevision(TRUE);
    $entity->save();
    // Reload the object.
    
    /** @var \Drupal\Core\Entity\RevisionableStorageInterface $storage */
    $storage = \Drupal::entityTypeManager()->getStorage('entity_test_rev');
    $revision = $storage->loadRevision($revisionId);
    $this->drupalGet($revision->toUrl('revision'));
    $this->assertSession()
        ->responseContains('first revision');
    $this->assertSession()
        ->responseNotContains('second revision');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.