Upgraded imagemagick and manually altered pdf to image module to handle changes....
[yaffs-website] / web / modules / contrib / entity / tests / src / Functional / RevisionRouteAccessTest.php
1 <?php
2
3 namespace Drupal\Tests\entity\Functional;
4
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;
9
10 /**
11  * Tests the revision route access check.
12  *
13  * @group entity
14  *
15  * @runTestsInSeparateProcesses
16  *
17  * @preserveGlobalState disabled
18  */
19 class RevisionRouteAccessTest extends BrowserTestBase {
20
21   use BlockCreationTrait;
22
23   /**
24    * The current user.
25    *
26    * @var \Drupal\Core\Session\AccountInterface;
27    */
28   protected $account;
29
30   /**
31    * Modules to enable.
32    *
33    * @var array
34    */
35   public static $modules = ['entity_module_test', 'user', 'entity', 'block'];
36
37   /**
38    * {@inheritdoc}
39    */
40   protected function setUp() {
41     parent::setUp();
42
43     EnhancedEntityBundle::create([
44       'id' => 'default',
45       'label' => 'Default',
46     ])->save();
47
48     $this->placeBlock('local_tasks_block');
49     $this->placeBlock('system_breadcrumb_block');
50
51     $this->account = $this->drupalCreateUser([
52       'administer entity_test_enhanced',
53       'view all entity_test_enhanced revisions',
54     ]);
55
56     $this->drupalLogin($this->account);
57   }
58
59   /**
60    * Test enhanced entity revision routes access.
61    */
62   public function testRevisionRouteAccess() {
63     $entity = EnhancedEntity::create([
64       'name' => 'rev 1',
65       'type' => 'default',
66     ]);
67     $entity->save();
68
69     $revision = clone $entity;
70     $revision->name->value = 'rev 2';
71     $revision->setNewRevision(TRUE);
72     $revision->isDefaultRevision(FALSE);
73     $revision->save();
74
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');
83     $edit_link->click();
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);
95   }
96
97 }