imageTest.php

  1. 8.0.x tests/imageTest.php
  2. 6.x tests/imageTest.php
  3. 7.x tests/imageTest.php
  4. 5.x tests/imageTest.php
  5. master tests/imageTest.php

Classes

Namesort descending Description
ImageCase

File

tests/imageTest.php
View source
  1. <?php
  2. /*
  3. * @file
  4. * Tests image-flush command
  5. *
  6. * @group commands
  7. */
  8. class ImageCase extends Drush_CommandTestCase {
  9. function testImage() {
  10. // Install Drupal 7 with standard installation profile
  11. $sites = $this->setUpDrupal(1, TRUE, UNISH_DRUPAL_MAJOR_VERSION, 'standard');
  12. $options = array(
  13. 'yes' => NULL,
  14. 'root' => $this->webroot(),
  15. 'uri' => key($sites),
  16. );
  17. // Test that "drush image-flush thumbnail" deletes derivatives created by the thumbnail image style.
  18. $style_name = 'thumbnail';
  19. $php = "\$image_style = image_style_load('--stylename--');" .
  20. "image_style_create_derivative(\$image_style, '" . $options['root'] .
  21. "/themes/bartik/logo.png', 'public://styles/--stylename--/logo.png');";
  22. $this->drush('php-eval', array(str_replace('--stylename--', $style_name, $php)), $options);
  23. $this->assertFileExists($options['root'] . '/sites/' . key($sites) . '/files/styles/' . $style_name . '/logo.png');
  24. $this->drush('image-flush', array($style_name), $options);
  25. $this->assertFileNotExists($options['root'] . '/sites/' . key($sites) . '/files/styles/' . $style_name . '/logo.png');
  26. // Check that "drush image-flush --all" deletes all image styles by creating two different ones and testing its
  27. // existance afterwards.
  28. $style_name = 'thumbnail';
  29. $this->drush('php-eval', array(str_replace('--stylename--', $style_name, $php)), $options);
  30. $this->assertFileExists($options['root'] . '/sites/' . key($sites) . '/files/styles/' . $style_name . '/logo.png');
  31. $style_name = 'medium';
  32. $this->drush('php-eval', array(str_replace('--stylename--', $style_name, $php)), $options);
  33. $this->assertFileExists($options['root'] . '/sites/' . key($sites) . '/files/styles/' . $style_name . '/logo.png');
  34. $this->drush('image-flush', array(), array('all' => TRUE) + $options);
  35. $this->assertFileNotExists($options['root'] . '/sites/' . key($sites) . '/files/styles/thumbnail/logo.png');
  36. $this->assertFileNotExists($options['root'] . '/sites/' . key($sites) . '/files/styles/medium/logo.png');
  37. }
  38. }