X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fentity%2Ftests%2Fsrc%2FFunctional%2FRevisionRouteAccessTest.php;fp=web%2Fmodules%2Fcontrib%2Fentity%2Ftests%2Fsrc%2FFunctional%2FRevisionRouteAccessTest.php;h=8eddca4914a06843d2bca02a9a22065f7ae9446c;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/modules/contrib/entity/tests/src/Functional/RevisionRouteAccessTest.php b/web/modules/contrib/entity/tests/src/Functional/RevisionRouteAccessTest.php new file mode 100644 index 000000000..8eddca491 --- /dev/null +++ b/web/modules/contrib/entity/tests/src/Functional/RevisionRouteAccessTest.php @@ -0,0 +1,97 @@ + 'default', + 'label' => 'Default', + ])->save(); + + $this->placeBlock('local_tasks_block'); + $this->placeBlock('system_breadcrumb_block'); + + $this->account = $this->drupalCreateUser([ + 'administer entity_test_enhanced', + 'view all entity_test_enhanced revisions', + ]); + + $this->drupalLogin($this->account); + } + + /** + * Test enhanced entity revision routes access. + */ + 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('Entity test with enhancements'); + $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); + } + +}