RealIteratorTestCase.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Tests\Component\Finder\Iterator;
  11. require_once __DIR__.'/IteratorTestCase.php';
  12. abstract class RealIteratorTestCase extends IteratorTestCase
  13. {
  14. static protected $files;
  15. static public function setUpBeforeClass()
  16. {
  17. $tmpDir = sys_get_temp_dir().'/symfony2_finder';
  18. self::$files = array(
  19. $tmpDir.'/.git/',
  20. $tmpDir.'/test.py',
  21. $tmpDir.'/foo/',
  22. $tmpDir.'/foo/bar.tmp',
  23. $tmpDir.'/test.php',
  24. $tmpDir.'/toto/'
  25. );
  26. if (is_dir($tmpDir)) {
  27. self::tearDownAfterClass();
  28. } else {
  29. mkdir($tmpDir);
  30. }
  31. foreach (self::$files as $file) {
  32. if ('/' === $file[strlen($file) - 1]) {
  33. mkdir($file);
  34. } else {
  35. touch($file);
  36. }
  37. }
  38. file_put_contents($tmpDir.'/test.php', str_repeat(' ', 800));
  39. file_put_contents($tmpDir.'/test.py', str_repeat(' ', 2000));
  40. touch($tmpDir.'/foo/bar.tmp', strtotime('2005-10-15'));
  41. touch($tmpDir.'/test.php', strtotime('2005-10-15'));
  42. }
  43. static public function tearDownAfterClass()
  44. {
  45. foreach (array_reverse(self::$files) as $file) {
  46. if ('/' === $file[strlen($file) - 1]) {
  47. @rmdir($file);
  48. } else {
  49. @unlink($file);
  50. }
  51. }
  52. }
  53. }