RealIteratorTestCase.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien.potencier@symfony-project.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\Components\Finder\Iterator;
  11. require_once __DIR__.'/IteratorTestCase.php';
  12. 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($tmpDir.'/.git', $tmpDir.'/test.py', $tmpDir.'/foo', $tmpDir.'/foo/bar.tmp', $tmpDir.'/test.php', $tmpDir.'/toto');
  19. if (is_dir($tmpDir))
  20. {
  21. self::tearDownAfterClass();
  22. rmdir($tmpDir);
  23. }
  24. mkdir($tmpDir);
  25. foreach (self::$files as $file)
  26. {
  27. if (false !== ($pos = strpos($file, '.')) && '/' !== $file[$pos - 1])
  28. {
  29. touch($file);
  30. }
  31. else
  32. {
  33. mkdir($file);
  34. }
  35. }
  36. file_put_contents($tmpDir.'/test.php', str_repeat(' ', 800));
  37. file_put_contents($tmpDir.'/test.py', str_repeat(' ', 2000));
  38. }
  39. static public function tearDownAfterClass()
  40. {
  41. foreach (self::$files as $file)
  42. {
  43. if (false !== ($pos = strpos($file, '.')) && '/' !== $file[$pos - 1])
  44. {
  45. @unlink($file);
  46. }
  47. else
  48. {
  49. @rmdir($file);
  50. }
  51. }
  52. }
  53. }