4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Finder\Tests\Iterator;
14 abstract class RealIteratorTestCase extends IteratorTestCase
16 protected static $tmpDir;
17 protected static $files;
19 public static function setUpBeforeClass()
21 self::$tmpDir = realpath(sys_get_temp_dir()).\DIRECTORY_SEPARATOR.'symfony_finder';
38 self::$files = self::toAbsolute(self::$files);
40 if (is_dir(self::$tmpDir)) {
41 self::tearDownAfterClass();
46 foreach (self::$files as $file) {
47 if (\DIRECTORY_SEPARATOR === $file[\strlen($file) - 1]) {
54 file_put_contents(self::toAbsolute('test.php'), str_repeat(' ', 800));
55 file_put_contents(self::toAbsolute('test.py'), str_repeat(' ', 2000));
57 touch(self::toAbsolute('foo/bar.tmp'), strtotime('2005-10-15'));
58 touch(self::toAbsolute('test.php'), strtotime('2005-10-15'));
61 public static function tearDownAfterClass()
63 $paths = new \RecursiveIteratorIterator(
64 new \RecursiveDirectoryIterator(self::$tmpDir, \RecursiveDirectoryIterator::SKIP_DOTS),
65 \RecursiveIteratorIterator::CHILD_FIRST
68 foreach ($paths as $path) {
70 if ($path->isLink()) {
81 protected static function toAbsolute($files = null)
84 * Without the call to setUpBeforeClass() property can be null.
87 self::$tmpDir = realpath(sys_get_temp_dir()).\DIRECTORY_SEPARATOR.'symfony_finder';
90 if (\is_array($files)) {
92 foreach ($files as $file) {
93 if (\is_array($file)) {
94 $f[] = self::toAbsolute($file);
96 $f[] = self::$tmpDir.\DIRECTORY_SEPARATOR.str_replace('/', \DIRECTORY_SEPARATOR, $file);
103 if (\is_string($files)) {
104 return self::$tmpDir.\DIRECTORY_SEPARATOR.str_replace('/', \DIRECTORY_SEPARATOR, $files);
107 return self::$tmpDir;
110 protected static function toAbsoluteFixtures($files)
113 foreach ($files as $file) {
114 $f[] = realpath(__DIR__.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR.$file);