Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / drush / drush / tests / ImageTest.php
1 <?php
2
3 namespace Unish;
4
5 /**
6  * Tests image-flush command
7  *
8  * @group commands
9  */
10 class ImageCase extends CommandUnishTestCase
11 {
12
13     public function testImage()
14     {
15         $this->setUpDrupal(1, true);
16         $this->drush('pm-enable', ['image']);
17         $logo = 'core/themes/bartik/screenshot.png';
18         $styles_dir = $this->webroot() . '/sites/' . $this->getUri() . '/files/styles/';
19         $thumbnail = $styles_dir . 'thumbnail/public/' . $logo;
20         $medium = $styles_dir . 'medium/public/' . $logo;
21
22         // Test that "drush image-derive" works.
23         $style_name = 'thumbnail';
24         $this->drush('image-derive', [$style_name, $logo]);
25         $this->assertFileExists($thumbnail);
26
27         // Test that "drush image-flush thumbnail" deletes derivatives created by the thumbnail image style.
28         $this->drush('image-flush', [$style_name], ['all' => null]);
29         $this->assertFileNotExists($thumbnail);
30
31         // Check that "drush image-flush --all" deletes all image styles by creating two different ones and testing its
32         // existence afterwards.
33         $this->drush('image-derive', ['thumbnail', $logo]);
34         $this->assertFileExists($thumbnail);
35         $this->drush('image-derive', ['medium', $logo]);
36         $this->assertFileExists($medium);
37         $this->drush('image-flush', [], ['all' => null]);
38         $this->assertFileNotExists($thumbnail);
39         $this->assertFileNotExists($medium);
40     }
41 }