function RevisionVersionHistoryTest::testOperationDeleteRevision
Same name in other branches
- 11.x core/tests/Drupal/FunctionalTests/Entity/RevisionVersionHistoryTest.php \Drupal\FunctionalTests\Entity\RevisionVersionHistoryTest::testOperationDeleteRevision()
Test delete operation.
@covers ::buildDeleteRevisionLink
File
-
core/
tests/ Drupal/ FunctionalTests/ Entity/ RevisionVersionHistoryTest.php, line 278
Class
- RevisionVersionHistoryTest
- Tests version history page.
Namespace
Drupal\FunctionalTests\EntityCode
public function testOperationDeleteRevision() : void {
/** @var \Drupal\entity_test_revlog\Entity\EntityTestWithRevisionLog $entity */
$entity = EntityTestWithRevisionLog::create([
'type' => 'entity_test_revlog',
]);
$entity->setName('view all revisions');
$entity->save();
$entity->setName('view all revisions, delete revision');
$entity->setNewRevision();
$entity->save();
$entity->setName('view all revisions, delete revision');
$entity->setNewRevision();
$entity->save();
$this->drupalGet($entity->toUrl('version-history'));
$this->assertSession()
->elementsCount('css', 'table tbody tr', 3);
// Latest revision does not have delete revision operation: deleting latest
// revision is not permitted.
$row1 = $this->assertSession()
->elementExists('css', 'table tbody tr:nth-child(1)');
$this->assertSession()
->elementTextContains('css', 'table tbody tr:nth-child(1)', 'Current revision');
$this->assertSession()
->elementNotExists('named', [
'link',
'Delete',
], $row1);
// Revision 2 has delete revision operation: granted access.
$row2 = $this->assertSession()
->elementExists('css', 'table tbody tr:nth-child(2)');
$this->assertSession()
->elementExists('named', [
'link',
'Delete',
], $row2);
// Revision 3 does not have delete revision operation: no access.
$row3 = $this->assertSession()
->elementExists('css', 'table tbody tr:nth-child(3)');
$this->assertSession()
->elementNotExists('named', [
'link',
'Delete',
], $row3);
$this->drupalGet($entity->toUrl('version-history'));
$this->assertSession()
->elementsCount('css', 'table tbody tr', 3);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.