forked from drush-ops/drush
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimageTest.php
47 lines (40 loc) · 1.67 KB
/
imageTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
namespace Unish;
/**
* Tests image-flush command
*
* @group commands
*/
class ImageCase extends CommandUnishTestCase {
function testImage() {
if (UNISH_DRUPAL_MAJOR_VERSION == 6) {
$this->markTestSkipped("Image styles not available in Drupal 6 core.");
}
$sites = $this->setUpDrupal(1, TRUE, UNISH_DRUPAL_MAJOR_VERSION, 'standard');
$options = array(
'yes' => NULL,
'root' => $this->webroot(),
'uri' => key($sites),
);
$logo = UNISH_DRUPAL_MAJOR_VERSION >= 8 ? 'core/themes/bartik/logo.png' : 'themes/bartik/logo.png';
$styles_dir = $options['root'] . '/sites/' . key($sites) . '/files/styles/';
$thumbnail = $styles_dir . 'thumbnail/public/' . $logo;
$medium = $styles_dir . 'medium/public/' . $logo;
// Test that "drush image-derive" works.
$style_name = 'thumbnail';
$this->drush('image-derive', array($style_name, $logo), $options);
$this->assertFileExists($thumbnail);
// Test that "drush image-flush thumbnail" deletes derivatives created by the thumbnail image style.
$this->drush('image-flush', array($style_name), $options);
$this->assertFileNotExists($thumbnail);
// Check that "drush image-flush --all" deletes all image styles by creating two different ones and testing its
// existance afterwards.
$this->drush('image-derive', array('thumbnail', $logo), $options);
$this->assertFileExists($thumbnail);
$this->drush('image-derive', array('medium', $logo), $options);
$this->assertFileExists($medium);
$this->drush('image-flush', array(), array('all' => TRUE) + $options);
$this->assertFileNotExists($thumbnail);
$this->assertFileNotExists($medium);
}
}