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

Namespace

Unish

Classes

Namesort descending Description
ImageCase Tests image-flush command

File

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