Skip to content

Commit b0cc29a

Browse files
committed
fix integration tests cache
1 parent 0f86c41 commit b0cc29a

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

tests/FunctionalTest.php renamed to tests/IntegrationTest.php

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Symfony\Component\DependencyInjection\ContainerBuilder;
1212
use Symfony\Component\HttpKernel\Kernel;
1313

14-
class FunctionalTest extends TestCase
14+
class IntegrationTest extends TestCase
1515
{
1616
public function testServiceWiring()
1717
{
@@ -81,6 +81,42 @@ public function registerContainerConfiguration(LoaderInterface $loader)
8181
*/
8282
public function getCacheDir()
8383
{
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);
85121
}
86122
}

0 commit comments

Comments
 (0)