BaseFileCacheTest.php 944 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace Doctrine\Tests\Common\Cache;
  3. use RecursiveDirectoryIterator;
  4. use RecursiveIteratorIterator;
  5. abstract class BaseFileCacheTest extends CacheTest
  6. {
  7. protected $directory;
  8. public function setUp()
  9. {
  10. do {
  11. $this->directory = sys_get_temp_dir() . '/doctrine_cache_'. uniqid();
  12. } while (file_exists($this->directory));
  13. }
  14. public function tearDown()
  15. {
  16. if ( ! is_dir($this->directory)) {
  17. return;
  18. }
  19. $iterator = new RecursiveDirectoryIterator($this->directory);
  20. foreach (new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST) as $file) {
  21. if ($file->isFile()) {
  22. @unlink($file->getRealPath());
  23. } elseif ($file->isDir()) {
  24. @rmdir($file->getRealPath());
  25. }
  26. }
  27. }
  28. protected function isSharedStorage()
  29. {
  30. return false;
  31. }
  32. }