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 foreach (array_reverse(self::$files) as $file) {
64 if (DIRECTORY_SEPARATOR === $file[strlen($file) - 1]) {
72 protected static function toAbsolute($files = null)
75 * Without the call to setUpBeforeClass() property can be null.
78 self::$tmpDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'symfony_finder';
81 if (is_array($files)) {
83 foreach ($files as $file) {
84 if (is_array($file)) {
85 $f[] = self::toAbsolute($file);
87 $f[] = self::$tmpDir.DIRECTORY_SEPARATOR.str_replace('/', DIRECTORY_SEPARATOR, $file);
94 if (is_string($files)) {
95 return self::$tmpDir.DIRECTORY_SEPARATOR.str_replace('/', DIRECTORY_SEPARATOR, $files);
101 protected static function toAbsoluteFixtures($files)
104 foreach ($files as $file) {
105 $f[] = realpath(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.$file);