Yaffs site version 1.1
[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   function testImage() {
13     if (UNISH_DRUPAL_MAJOR_VERSION == 6) {
14       $this->markTestSkipped("Image styles not available in Drupal 6 core.");
15     }
16
17     $sites = $this->setUpDrupal(1, TRUE, UNISH_DRUPAL_MAJOR_VERSION, 'standard');
18     $options = array(
19       'yes' => NULL,
20       'root' => $this->webroot(),
21       'uri' => key($sites),
22     );
23     $logo = UNISH_DRUPAL_MAJOR_VERSION >= 8 ? 'core/themes/bartik/screenshot.png' : 'themes/bartik/screenshot.png';
24     $styles_dir = $options['root'] . '/sites/' . key($sites) . '/files/styles/';
25     $thumbnail = $styles_dir . 'thumbnail/public/' . $logo;
26     $medium = $styles_dir . 'medium/public/' . $logo;
27
28     // Test that "drush image-derive" works.
29     $style_name = 'thumbnail';
30     $this->drush('image-derive', array($style_name, $logo), $options);
31     $this->assertFileExists($thumbnail);
32
33     // Test that "drush image-flush thumbnail" deletes derivatives created by the thumbnail image style.
34     $this->drush('image-flush', array($style_name), $options);
35     $this->assertFileNotExists($thumbnail);
36
37     // Check that "drush image-flush --all" deletes all image styles by creating two different ones and testing its
38     // existance afterwards.
39     $this->drush('image-derive', array('thumbnail', $logo), $options);
40     $this->assertFileExists($thumbnail);
41     $this->drush('image-derive', array('medium', $logo), $options);
42     $this->assertFileExists($medium);
43     $this->drush('image-flush', array(), array('all' => TRUE) + $options);
44     $this->assertFileNotExists($thumbnail);
45     $this->assertFileNotExists($medium);
46   }
47 }