3 namespace Drupal\Tests\entity\Functional;
5 use Drupal\entity_module_test\Entity\EnhancedEntity;
6 use Drupal\entity_module_test\Entity\EnhancedEntityBundle;
7 use Drupal\Tests\block\Traits\BlockCreationTrait;
8 use Drupal\Tests\BrowserTestBase;
11 * Tests the revision route access check.
15 * @runTestsInSeparateProcesses
17 * @preserveGlobalState disabled
19 class RevisionRouteAccessTest extends BrowserTestBase {
21 use BlockCreationTrait;
26 * @var \Drupal\Core\Session\AccountInterface;
35 public static $modules = ['entity_module_test', 'user', 'entity', 'block'];
40 protected function setUp() {
43 EnhancedEntityBundle::create([
48 $this->placeBlock('local_tasks_block');
49 $this->placeBlock('system_breadcrumb_block');
51 $this->account = $this->drupalCreateUser([
52 'administer entity_test_enhanced',
53 'view all entity_test_enhanced revisions',
56 $this->drupalLogin($this->account);
60 * Test enhanced entity revision routes access.
62 public function testRevisionRouteAccess() {
63 $entity = EnhancedEntity::create([
69 $revision = clone $entity;
70 $revision->name->value = 'rev 2';
71 $revision->setNewRevision(TRUE);
72 $revision->isDefaultRevision(FALSE);
75 $this->drupalGet('/entity_test_enhanced/1/revisions');
76 $this->assertSession()->statusCodeEquals(200);
77 $this->assertSession()->responseContains('Revisions');
78 $collection_link = $this->getSession()->getPage()->findLink('Enhanced entities');
79 $collection_link->click();
80 $this->assertSession()->addressEquals('/entity_test_enhanced');
81 $this->assertSession()->responseContains('Edit');
82 $edit_link = $this->getSession()->getPage()->findLink('Edit');
84 $this->assertSession()->addressEquals('/entity_test_enhanced/1/edit');
85 // Check if we have revision tab link on edit page.
86 $this->getSession()->getPage()->findLink('Revisions')->click();
87 $this->assertSession()->addressEquals('/entity_test_enhanced/1/revisions');
88 $this->drupalGet('/entity_test_enhanced/1/revisions/2/view');
89 $this->assertSession()->statusCodeEquals(200);
90 $this->assertSession()->responseContains('rev 2');
91 $revisions_link = $this->getSession()->getPage()->findLink('Revisions');
92 $revisions_link->click();
93 $this->assertSession()->addressEquals('/entity_test_enhanced/1/revisions');
94 $this->assertSession()->statusCodeEquals(200);