function RevisionDeleteFormTest::testAccessDeleteNonLatest

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

Test can delete non-latest revision.

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

1 call to RevisionDeleteFormTest::testAccessDeleteNonLatest()
RevisionDeleteFormTest::testAccessDelete in core/tests/Drupal/FunctionalTests/Entity/RevisionDeleteFormTest.php
Test that revisions can and can't be deleted in various scenarios.

File

core/tests/Drupal/FunctionalTests/Entity/RevisionDeleteFormTest.php, line 199

Class

RevisionDeleteFormTest
Tests deleting a revision with revision delete form.

Namespace

Drupal\FunctionalTests\Entity

Code

protected function testAccessDeleteNonLatest() : void {
    
    /** @var \Drupal\entity_test\Entity\EntityTestRev $entity */
    $entity = EntityTestRev::create();
    $entity->setName('delete revision');
    $entity->save();
    $entity->isDefaultRevision();
    $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-delete-form'));
    $this->assertSession()
        ->statusCodeEquals(200);
    $this->assertTrue($revision->access('delete revision', $this->rootUser, FALSE));
}

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