Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/finder/Tests/Iterator/RealIteratorTestCase.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | c2387f117808 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 /* | |
4 * This file is part of the Symfony package. | |
5 * | |
6 * (c) Fabien Potencier <fabien@symfony.com> | |
7 * | |
8 * For the full copyright and license information, please view the LICENSE | |
9 * file that was distributed with this source code. | |
10 */ | |
11 | |
12 namespace Symfony\Component\Finder\Tests\Iterator; | |
13 | |
14 abstract class RealIteratorTestCase extends IteratorTestCase | |
15 { | |
16 protected static $tmpDir; | |
17 protected static $files; | |
18 | |
19 public static function setUpBeforeClass() | |
20 { | |
21 self::$tmpDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'symfony_finder'; | |
22 | |
23 self::$files = array( | |
24 '.git/', | |
25 '.foo/', | |
26 '.foo/.bar', | |
27 '.foo/bar', | |
28 '.bar', | |
29 'test.py', | |
30 'foo/', | |
31 'foo/bar.tmp', | |
32 'test.php', | |
33 'toto/', | |
34 'toto/.git/', | |
35 'foo bar', | |
36 ); | |
37 | |
38 self::$files = self::toAbsolute(self::$files); | |
39 | |
40 if (is_dir(self::$tmpDir)) { | |
41 self::tearDownAfterClass(); | |
42 } else { | |
43 mkdir(self::$tmpDir); | |
44 } | |
45 | |
46 foreach (self::$files as $file) { | |
47 if (DIRECTORY_SEPARATOR === $file[strlen($file) - 1]) { | |
48 mkdir($file); | |
49 } else { | |
50 touch($file); | |
51 } | |
52 } | |
53 | |
54 file_put_contents(self::toAbsolute('test.php'), str_repeat(' ', 800)); | |
55 file_put_contents(self::toAbsolute('test.py'), str_repeat(' ', 2000)); | |
56 | |
57 touch(self::toAbsolute('foo/bar.tmp'), strtotime('2005-10-15')); | |
58 touch(self::toAbsolute('test.php'), strtotime('2005-10-15')); | |
59 } | |
60 | |
61 public static function tearDownAfterClass() | |
62 { | |
63 foreach (array_reverse(self::$files) as $file) { | |
64 if (DIRECTORY_SEPARATOR === $file[strlen($file) - 1]) { | |
65 @rmdir($file); | |
66 } else { | |
67 @unlink($file); | |
68 } | |
69 } | |
70 } | |
71 | |
72 protected static function toAbsolute($files = null) | |
73 { | |
74 /* | |
75 * Without the call to setUpBeforeClass() property can be null. | |
76 */ | |
77 if (!self::$tmpDir) { | |
78 self::$tmpDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'symfony_finder'; | |
79 } | |
80 | |
81 if (is_array($files)) { | |
82 $f = array(); | |
83 foreach ($files as $file) { | |
84 if (is_array($file)) { | |
85 $f[] = self::toAbsolute($file); | |
86 } else { | |
87 $f[] = self::$tmpDir.DIRECTORY_SEPARATOR.str_replace('/', DIRECTORY_SEPARATOR, $file); | |
88 } | |
89 } | |
90 | |
91 return $f; | |
92 } | |
93 | |
94 if (is_string($files)) { | |
95 return self::$tmpDir.DIRECTORY_SEPARATOR.str_replace('/', DIRECTORY_SEPARATOR, $files); | |
96 } | |
97 | |
98 return self::$tmpDir; | |
99 } | |
100 | |
101 protected static function toAbsoluteFixtures($files) | |
102 { | |
103 $f = array(); | |
104 foreach ($files as $file) { | |
105 $f[] = realpath(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.$file); | |
106 } | |
107 | |
108 return $f; | |
109 } | |
110 } |