RealIteratorTestCase.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. self::tearDownAfterClass();
  21. rmdir($tmpDir);
  22. }
  23. mkdir($tmpDir);
  24. foreach (self::$files as $file) {
  25. if (false !== ($pos = strpos($file, '.')) && '/' !== $file[$pos - 1]) {
  26. touch($file);
  27. } else {
  28. mkdir($file);
  29. }
  30. }
  31. file_put_contents($tmpDir.'/test.php', str_repeat(' ', 800));
  32. file_put_contents($tmpDir.'/test.py', str_repeat(' ', 2000));
  33. }
  34. static public function tearDownAfterClass()
  35. {
  36. foreach (self::$files as $file) {
  37. if (false !== ($pos = strpos($file, '.')) && '/' !== $file[$pos - 1]) {
  38. @unlink($file);
  39. } else {
  40. @rmdir($file);
  41. }
  42. }
  43. }
  44. }