3 namespace Drupal\Tests\entity\Functional;
5 use Drupal\entity_module_test\Entity\EnhancedEntity;
6 use Drupal\Tests\block\Traits\BlockCreationTrait;
7 use Drupal\Tests\BrowserTestBase;
10 * Tests the revision route access check.
14 * @runTestsInSeparateProcesses
16 * @preserveGlobalState disabled
18 class RevisionRouteAccessTest extends BrowserTestBase {
20 use BlockCreationTrait;
25 * @var \Drupal\Core\Session\AccountInterface
34 public static $modules = ['entity_module_test', 'user', 'entity', 'block'];
39 protected function setUp() {
42 $this->placeBlock('local_tasks_block');
43 $this->placeBlock('system_breadcrumb_block');
45 $this->account = $this->drupalCreateUser([
46 'administer entity_test_enhanced',
47 'view all entity_test_enhanced revisions',
50 $this->drupalLogin($this->account);
54 * Test enhanced entity revision routes access.
56 public function testRevisionRouteAccess() {
57 $entity = EnhancedEntity::create([
63 $revision = clone $entity;
64 $revision->name->value = 'rev 2';
65 $revision->setNewRevision(TRUE);
66 $revision->isDefaultRevision(FALSE);
69 $this->drupalGet('/entity_test_enhanced/1/revisions');
70 $this->assertSession()->statusCodeEquals(200);
71 $this->assertSession()->responseContains('Revisions');
72 $collection_link = $this->getSession()->getPage()->findLink('Enhanced entities');
73 $collection_link->click();
74 $this->assertSession()->addressEquals('/entity_test_enhanced');
75 $this->assertSession()->responseContains('Edit');
76 $edit_link = $this->getSession()->getPage()->findLink('Edit');
78 $this->assertSession()->addressEquals('/entity_test_enhanced/1/edit');
79 // Check if we have revision tab link on edit page.
80 $this->getSession()->getPage()->findLink('Revisions')->click();
81 $this->assertSession()->addressEquals('/entity_test_enhanced/1/revisions');
82 $this->drupalGet('/entity_test_enhanced/1/revisions/2/view');
83 $this->assertSession()->statusCodeEquals(200);
84 $this->assertSession()->responseContains('rev 2');
85 $revisions_link = $this->getSession()->getPage()->findLink('Revisions');
86 $revisions_link->click();
87 $this->assertSession()->addressEquals('/entity_test_enhanced/1/revisions');
88 $this->assertSession()->statusCodeEquals(200);