0afae2d63c291740aabb8253d31bcc67c605b16c
[yaffs-website] / web / core / modules / views / src / Tests / Update / ImageStyleDependencyUpdateTest.php
1 <?php
2
3 namespace Drupal\views\Tests\Update;
4
5 use Drupal\system\Tests\Update\UpdatePathTestBase;
6 use Drupal\views\Entity\View;
7
8 /**
9  * Tests Views image style dependencies update.
10  *
11  * @group views
12  */
13 class ImageStyleDependencyUpdateTest extends UpdatePathTestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   protected function setDatabaseDumpFiles() {
19     $this->databaseDumpFiles = [
20       __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8-rc1.bare.standard.php.gz',
21       __DIR__ . '/../../../../system/tests/fixtures/update/drupal8.views-image-style-dependency-2649914.php',
22     ];
23   }
24
25   /**
26    * Tests the updating of views dependencies to image styles.
27    */
28   public function testUpdateImageStyleDependencies() {
29     $config_dependencies = View::load('foo')->getDependencies()['config'];
30
31     // Checks that 'thumbnail' image style is not a dependency of view 'foo'.
32     $this->assertFalse(in_array('image.style.thumbnail', $config_dependencies));
33
34     // We test the case the the field formatter image style doesn't exist.
35     // Checks that 'nonexistent' image style is not a dependency of view 'foo'.
36     $this->assertFalse(in_array('image.style.nonexistent', $config_dependencies));
37
38     // Run updates.
39     $this->runUpdates();
40
41     $config_dependencies = View::load('foo')->getDependencies()['config'];
42
43     // Checks that 'thumbnail' image style is a dependency of view 'foo'.
44     $this->assertTrue(in_array('image.style.thumbnail', $config_dependencies));
45
46     // The 'nonexistent' style doesn't exist, thus is not a dependency. Checks
47     // that 'nonexistent' image style is a not dependency of view 'foo'.
48     $this->assertFalse(in_array('image.style.nonexistent', $config_dependencies));
49   }
50
51 }