bootstrap.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. require_once 'src/autoloader.php';
  3. define('CLEAN_DUMP', 1); // Clear tmp folder after tests?
  4. define('DIR_TEST', __DIR__); // /tests/ directory
  5. define('DIR_TEST_IMG', __DIR__.'/images'); // /tests/images directory
  6. define('DIR_TMP', __DIR__ . '/tmp'); // Holds test generated images
  7. define('DIR_ASSERT_GD', __DIR__ . '/assert-gd'); // Contains correct images to test upon on GD
  8. define('DIR_ASSERT_IMAGICK', __DIR__ . '/assert-imagick'); // Contains correct images to test upon on Imagick
  9. function deleteTmpDirectory()
  10. {
  11. $dir = __DIR__ . '/tmp';
  12. foreach (scandir($dir) as $file) {
  13. if ('.' === $file || '..' === $file) {
  14. continue;
  15. }
  16. if (is_dir("$dir/$file")) {
  17. rmdirRecursive("$dir/$file");
  18. } else {
  19. unlink("$dir/$file");
  20. }
  21. }
  22. }
  23. function rmdirRecursive($dir)
  24. {
  25. foreach (scandir($dir) as $file) {
  26. if ('.' === $file || '..' === $file) {
  27. continue;
  28. }
  29. if (is_dir("$dir/$file")) {
  30. rmdirRecursive("$dir/$file");
  31. } else {
  32. unlink("$dir/$file");
  33. }
  34. }
  35. return rmdir($dir);
  36. }