Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[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  * @group legacy
13  */
14 class MediaUpdateTest extends UpdatePathTestBase {
15
16   /**
17    * {@inheritdoc}
18    */
19   protected function setDatabaseDumpFiles() {
20     $this->databaseDumpFiles = [
21       __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.4.0.bare.standard.php.gz',
22       __DIR__ . '/../../../fixtures/update/drupal-8.4.0-media_installed.php',
23       __DIR__ . '/../../../fixtures/update/drupal-8.media-add-additional-permissions.php',
24     ];
25   }
26
27   /**
28    * Tests that media permissions are correctly migrated.
29    *
30    * @see media_update_8500()
31    */
32   public function testBundlePermission() {
33     $this->runUpdates();
34
35     /** @var \Drupal\user\RoleInterface $role */
36     $role = Role::load(Role::AUTHENTICATED_ID);
37
38     $media_types = \Drupal::entityQuery('media_type')->execute();
39     foreach ($media_types as $media_type) {
40       $this->assertTrue($role->hasPermission("create $media_type media"));
41       $this->assertTrue($role->hasPermission("edit own $media_type media"));
42       $this->assertTrue($role->hasPermission("edit any $media_type media"));
43       $this->assertTrue($role->hasPermission("delete own $media_type media"));
44       $this->assertTrue($role->hasPermission("delete any $media_type media"));
45     }
46   }
47
48   /**
49    * Tests that media.settings config is updated with oEmbed configuration.
50    *
51    * @see media_update_8600()
52    */
53   public function testOEmbedConfig() {
54     $config = $this->config('media.settings');
55     $this->assertNull($config->get('oembed_providers_url'));
56     $this->assertNull($config->get('iframe_domain'));
57
58     $this->runUpdates();
59
60     $config = $this->config('media.settings');
61     $this->assertSame('https://oembed.com/providers.json', $config->get('oembed_providers_url'));
62     $this->assertSame('', $config->get('iframe_domain'));
63   }
64
65 }