function RevisionDeleteFormTest::testAccessDeleteDefault
Same name in other branches
- 10 core/tests/Drupal/FunctionalTests/Entity/RevisionDeleteFormTest.php \Drupal\FunctionalTests\Entity\RevisionDeleteFormTest::testAccessDeleteDefault()
Test cannot delete default revision.
@covers \Drupal\Core\Entity\EntityAccessControlHandler::checkAccess
1 call to RevisionDeleteFormTest::testAccessDeleteDefault()
- 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 164
Class
- RevisionDeleteFormTest
- Tests deleting a revision with revision delete form.
Namespace
Drupal\FunctionalTests\EntityCode
protected function testAccessDeleteDefault() : void {
/** @var \Drupal\entity_test\Entity\EntityTestRevPub $entity */
$entity = EntityTestRevPub::create();
$entity->setName('delete revision');
$entity->save();
$entity->isDefaultRevision(TRUE);
$entity->setPublished();
$entity->setNewRevision();
$entity->save();
$revisionId = $entity->getRevisionId();
$entity->isDefaultRevision(FALSE);
$entity->setUnpublished();
$entity->setNewRevision();
$entity->save();
// Reload the entity.
/** @var \Drupal\Core\Entity\RevisionableStorageInterface $storage */
$storage = \Drupal::entityTypeManager()->getStorage('entity_test_revpub');
/** @var \Drupal\entity_test\Entity\EntityTestRevPub $revision */
$revision = $storage->loadRevision($revisionId);
// Check default but not latest.
$this->assertTrue($revision->isDefaultRevision());
$this->assertFalse($revision->isLatestRevision());
$this->drupalGet($revision->toUrl('revision-delete-form'));
$this->assertSession()
->statusCodeEquals(403);
$this->assertFalse($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.