public function RevisionRouteAccessTest::testRevisionRouteAccess in Entity API 8
Test enhanced entity revision routes access.
File
- tests/
src/ Functional/ RevisionRouteAccessTest.php, line 61
Class
- RevisionRouteAccessTest
- Tests the revision route access check.
Namespace
Drupal\Tests\entity\FunctionalCode
public function testRevisionRouteAccess() {
$entity = EnhancedEntity::create([
'name' => 'rev 1',
'type' => 'default',
]);
$entity
->save();
$revision = clone $entity;
$revision->name->value = 'rev 2';
$revision
->setNewRevision(TRUE);
$revision
->isDefaultRevision(FALSE);
$revision
->save();
$this
->drupalGet('/entity_test_enhanced/1/revisions');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->responseContains('Revisions');
$collection_link = $this
->getSession()
->getPage()
->findLink('Enhanced entities');
$collection_link
->click();
$this
->assertSession()
->addressEquals('/entity_test_enhanced');
$this
->assertSession()
->responseContains('Edit');
$edit_link = $this
->getSession()
->getPage()
->findLink('Edit');
$edit_link
->click();
$this
->assertSession()
->addressEquals('/entity_test_enhanced/1/edit');
// Check if we have revision tab link on edit page.
$this
->getSession()
->getPage()
->findLink('Revisions')
->click();
$this
->assertSession()
->addressEquals('/entity_test_enhanced/1/revisions');
$this
->drupalGet('/entity_test_enhanced/1/revisions/2/view');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->responseContains('rev 2');
$revisions_link = $this
->getSession()
->getPage()
->findLink('Revisions');
$revisions_link
->click();
$this
->assertSession()
->addressEquals('/entity_test_enhanced/1/revisions');
$this
->assertSession()
->statusCodeEquals(200);
}