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