2dbe28be365074c3aed24000b3e132f3e1402277
[yaffs-website] / web / core / modules / media / tests / src / Functional / Update / MediaUpdateTest.php
1 <?php
2
3 namespace Drupal\Tests\media\Functional\Update;
4
5 use Drupal\FunctionalTests\Update\UpdatePathTestBase;
6 use Drupal\user\Entity\Role;
7
8 /**
9  * Tests that media settings are properly updated during database updates.
10  *
11  * @group media
12  */
13 class MediaUpdateTest extends UpdatePathTestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   protected function setDatabaseDumpFiles() {
19     $this->databaseDumpFiles = [
20       __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
21       __DIR__ . '/../../../fixtures/update/drupal-8.media-enabled.php',
22     ];
23   }
24
25   /**
26    * Tests that media permissions are correctly migrated.
27    *
28    * @see media_update_8500()
29    */
30   public function testBundlePermission() {
31     $role = Role::load(Role::AUTHENTICATED_ID);
32
33     $this->grantPermissions($role, [
34       'update media',
35       'update any media',
36       'delete media',
37       'delete any media',
38       'create media',
39     ]);
40
41     $this->runUpdates();
42
43     /** @var \Drupal\user\RoleInterface $role */
44     $role = Role::load(Role::AUTHENTICATED_ID);
45
46     $media_types = \Drupal::entityQuery('media_type')->execute();
47     foreach ($media_types as $media_type) {
48       $this->assertTrue($role->hasPermission("create $media_type media"));
49       $this->assertTrue($role->hasPermission("edit own $media_type media"));
50       $this->assertTrue($role->hasPermission("edit any $media_type media"));
51       $this->assertTrue($role->hasPermission("delete own $media_type media"));
52       $this->assertTrue($role->hasPermission("delete any $media_type media"));
53     }
54   }
55
56 }