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. $sites = $this->setUpDrupal(1, TRUE, UNISH_DRUPAL_MAJOR_VERSION, 'standard');
  11. $options = array(
  12. 'yes' => NULL,
  13. 'root' => $this->webroot(),
  14. 'uri' => key($sites),
  15. );
  16. $logo = UNISH_DRUPAL_MAJOR_VERSION >= 8 ? 'core/themes/bartik/screenshot.png' : 'themes/bartik/screenshot.png';
  17. $styles_dir = $options['root'] . '/sites/' . key($sites) . '/files/styles/';
  18. $thumbnail = $styles_dir . 'thumbnail/public/' . $logo;
  19. $medium = $styles_dir . 'medium/public/' . $logo;
  20. // Test that "drush image-derive" works.
  21. $style_name = 'thumbnail';
  22. $this->drush('image-derive', array($style_name, $logo), $options);
  23. $this->assertFileExists($thumbnail);
  24. // Test that "drush image-flush thumbnail" deletes derivatives created by the thumbnail image style.
  25. $this->drush('image-flush', array($style_name), $options);
  26. $this->assertFileNotExists($thumbnail);
  27. // Check that "drush image-flush --all" deletes all image styles by creating two different ones and testing its
  28. // existance afterwards.
  29. $this->drush('image-derive', array('thumbnail', $logo), $options);
  30. $this->assertFileExists($thumbnail);
  31. $this->drush('image-derive', array('medium', $logo), $options);
  32. $this->assertFileExists($medium);
  33. $this->drush('image-flush', array(), array('all' => TRUE) + $options);
  34. $this->assertFileNotExists($thumbnail);
  35. $this->assertFileNotExists($medium);
  36. }
  37. }