function RevisionRevertFormTest::testAccessRevertNonLatest

Same name in other branches
  1. 10 core/tests/Drupal/FunctionalTests/Entity/RevisionRevertFormTest.php \Drupal\FunctionalTests\Entity\RevisionRevertFormTest::testAccessRevertNonLatest()

Test can revert non-latest revision.

@covers \Drupal\Core\Entity\EntityAccessControlHandler::checkAccess

1 call to RevisionRevertFormTest::testAccessRevertNonLatest()
RevisionRevertFormTest::testFormRevisionRevert in core/tests/Drupal/FunctionalTests/Entity/RevisionRevertFormTest.php
Test form revision revert.

File

core/tests/Drupal/FunctionalTests/Entity/RevisionRevertFormTest.php, line 156

Class

RevisionRevertFormTest
Tests reverting a revision with revision revert form.

Namespace

Drupal\FunctionalTests\Entity

Code

protected function testAccessRevertNonLatest() : void {
    
    /** @var \Drupal\entity_test\Entity\EntityTestRev $entity */
    $entity = EntityTestRev::create();
    $entity->setName('revert');
    $entity->save();
    $revisionId = $entity->getRevisionId();
    $entity->setNewRevision();
    $entity->save();
    // Reload the entity.
    
    /** @var \Drupal\Core\Entity\RevisionableStorageInterface $storage */
    $storage = \Drupal::entityTypeManager()->getStorage('entity_test_rev');
    $revision = $storage->loadRevision($revisionId);
    $this->drupalGet($revision->toUrl('revision-revert-form'));
    $this->assertSession()
        ->statusCodeEquals(200);
    $this->assertTrue($revision->access('revert', $this->rootUser, FALSE));
}

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