function RevisionVersionHistoryTest::testOrder
Same name in other branches
- 10 core/tests/Drupal/FunctionalTests/Entity/RevisionVersionHistoryTest.php \Drupal\FunctionalTests\Entity\RevisionVersionHistoryTest::testOrder()
Test all revisions appear, in order of revision creation.
File
-
core/
tests/ Drupal/ FunctionalTests/ Entity/ RevisionVersionHistoryTest.php, line 38
Class
- RevisionVersionHistoryTest
- Tests version history page.
Namespace
Drupal\FunctionalTests\EntityCode
public function testOrder() : void {
/** @var \Drupal\entity_test_revlog\Entity\EntityTestWithRevisionLog $entity */
$entity = EntityTestWithRevisionLog::create([
'type' => 'entity_test_revlog',
]);
// Need label to be able to assert order.
$entity->setName('view all revisions');
$user = $this->drupalCreateUser([], 'first revision');
$entity->setRevisionUser($user);
$entity->setNewRevision();
$entity->save();
$entity->setNewRevision();
$user = $this->drupalCreateUser([], 'second revision');
$entity->setRevisionUser($user);
$entity->save();
$entity->setNewRevision();
$user = $this->drupalCreateUser([], 'third revision');
$entity->setRevisionUser($user);
$entity->save();
$this->drupalGet($entity->toUrl('version-history'));
$this->assertSession()
->elementsCount('css', 'table tbody tr', 3);
// Order is newest to oldest revision by creation order.
$this->assertSession()
->elementTextContains('css', 'table tbody tr:nth-child(1)', 'third revision');
$this->assertSession()
->elementTextContains('css', 'table tbody tr:nth-child(2)', 'second revision');
$this->assertSession()
->elementTextContains('css', 'table tbody tr:nth-child(3)', 'first revision');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.