Upgraded imagemagick and manually altered pdf to image module to handle changes....
[yaffs-website] / web / modules / contrib / entity / tests / src / Functional / CollectionRouteAccessTest.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 collection route access check.
12  *
13  * @group entity
14  *
15  * @runTestsInSeparateProcesses
16  *
17  * @preserveGlobalState disabled
18  */
19 class CollectionRouteAccessTest extends BrowserTestBase {
20
21   use BlockCreationTrait;
22
23   /**
24    * Modules to enable.
25    *
26    * @var array
27    */
28   public static $modules = ['entity_module_test', 'user', 'entity', 'block'];
29
30   /**
31    * {@inheritdoc}
32    */
33   protected function setUp() {
34     parent::setUp();
35
36     EnhancedEntityBundle::create([
37       'id' => 'default',
38       'label' => 'Default',
39     ])->save();
40
41     $this->placeBlock('local_tasks_block');
42     $this->placeBlock('system_breadcrumb_block');
43   }
44
45   /**
46    * Test the collection route access.
47    */
48   public function testCollectionRouteAccess() {
49     $entity = EnhancedEntity::create([
50       'name' => 'rev 1',
51       'type' => 'default',
52     ]);
53     $entity->save();
54
55     // User without any relevant permissions.
56     $account = $this->drupalCreateUser(['access administration pages']);
57     $this->drupalLogin($account);
58
59     $this->drupalGet($entity->toUrl('collection'));
60     $this->assertSession()->statusCodeEquals(403);
61
62     // User with "access overview" permissions.
63     $account = $this->drupalCreateUser(['access entity_test_enhanced overview']);
64     $this->drupalLogin($account);
65
66     $this->drupalGet($entity->toUrl('collection'));
67     $this->assertSession()->statusCodeEquals(200);
68
69     // User with full administration permissions.
70     $account = $this->drupalCreateUser(['administer entity_test_enhanced']);
71     $this->drupalLogin($account);
72
73     $this->drupalGet($entity->toUrl('collection'));
74     $this->assertSession()->statusCodeEquals(200);
75   }
76
77 }