379ba74717911f23b95494a476b209c2845ad166
[yaffs-website] / web / core / modules / media / tests / src / Functional / MediaFunctionalTestTrait.php
1 <?php
2
3 namespace Drupal\Tests\media\Functional;
4
5 /**
6  * Trait with helpers for Media functional tests.
7  */
8 trait MediaFunctionalTestTrait {
9
10   /**
11    * Permissions for the admin user that will be logged-in for test.
12    *
13    * @var array
14    */
15   protected static $adminUserPermissions = [
16     // Media module permissions.
17     'access media overview',
18     'administer media',
19     'administer media fields',
20     'administer media form display',
21     'administer media display',
22     'administer media types',
23     'view media',
24     // Other permissions.
25     'administer views',
26     'access content overview',
27     'view all revisions',
28     'administer content types',
29     'administer node fields',
30     'administer node form display',
31     'administer node display',
32     'bypass node access',
33   ];
34
35   /**
36    * An admin test user account.
37    *
38    * @var \Drupal\Core\Session\AccountInterface
39    */
40   protected $adminUser;
41
42   /**
43    * A non-admin test user account.
44    *
45    * @var \Drupal\user\UserInterface
46    */
47   protected $nonAdminUser;
48
49   /**
50    * The storage service.
51    *
52    * @var \Drupal\Core\Entity\EntityStorageInterface
53    */
54   protected $storage;
55
56   /**
57    * {@inheritdoc}
58    */
59   protected function setUp() {
60     parent::setUp();
61
62     // Have two users ready to be used in tests.
63     $this->adminUser = $this->drupalCreateUser(static::$adminUserPermissions);
64     $this->nonAdminUser = $this->drupalCreateUser([]);
65     // Start off logged in as admin.
66     $this->drupalLogin($this->adminUser);
67
68     $this->storage = $this->container->get('entity_type.manager')->getStorage('media');
69   }
70
71 }