File tree Expand file tree Collapse file tree 1 file changed +38
-2
lines changed Expand file tree Collapse file tree 1 file changed +38
-2
lines changed Original file line number Diff line number Diff line change 11
11
use Symfony \Component \DependencyInjection \ContainerBuilder ;
12
12
use Symfony \Component \HttpKernel \Kernel ;
13
13
14
- class FunctionalTest extends TestCase
14
+ class IntegrationTest extends TestCase
15
15
{
16
16
public function testServiceWiring ()
17
17
{
@@ -81,6 +81,42 @@ public function registerContainerConfiguration(LoaderInterface $loader)
81
81
*/
82
82
public function getCacheDir ()
83
83
{
84
- return __DIR__ .'/cache_ ' .spl_object_hash ($ this );
84
+ $ currentCache = __DIR__ .'/cache_ ' .spl_object_hash ($ this );
85
+
86
+ foreach (glob (__DIR__ . "/cache_* " ) as $ item ) {
87
+ if (is_dir ($ item ) && $ currentCache != $ item )
88
+ $ this ->deleteDirectory ($ item );
89
+ }
90
+
91
+ return $ currentCache ;
92
+ }
93
+
94
+ /**
95
+ * Recursive delete a directory.
96
+ *
97
+ * @param string $dir
98
+ * @return bool
99
+ */
100
+ protected function deleteDirectory ($ dir ) {
101
+ if (!file_exists ($ dir )) {
102
+ return true ;
103
+ }
104
+
105
+ if (!is_dir ($ dir )) {
106
+ return unlink ($ dir );
107
+ }
108
+
109
+ foreach (scandir ($ dir ) as $ item ) {
110
+ if ($ item == '. ' || $ item == '.. ' ) {
111
+ continue ;
112
+ }
113
+
114
+ if (!$ this ->deleteDirectory ($ dir . DIRECTORY_SEPARATOR . $ item )) {
115
+ return false ;
116
+ }
117
+
118
+ }
119
+
120
+ return rmdir ($ dir );
85
121
}
86
122
}
You can’t perform that action at this time.
0 commit comments