| 1 |
<?php |
| 2 |
|
| 3 |
namespace Assetic\Test; |
| 4 |
|
| 5 |
abstract class TestCase extends \PHPUnit_Framework_TestCase |
| 6 |
{ |
| 7 |
protected static function removeDirectory($dir) |
| 8 |
{ |
| 9 |
$inner = new \RecursiveDirectoryIterator($dir, \FilesystemIterator::SKIP_DOTS); |
| 10 |
$outer = new \RecursiveIteratorIterator($inner, \RecursiveIteratorIterator::SELF_FIRST); |
| 11 |
|
| 12 |
// remove the files first |
| 13 |
foreach ($outer as $file) { |
| 14 |
if ($file->isFile()) { |
| 15 |
unlink($file); |
| 16 |
} |
| 17 |
} |
| 18 |
|
| 19 |
// remove the sub-directories next |
| 20 |
$files = iterator_to_array($outer); |
| 21 |
foreach (array_reverse($files) as $file) { |
| 22 |
if ($file->isDir()) { |
| 23 |
rmdir($file); |
| 24 |
} |
| 25 |
} |
| 26 |
|
| 27 |
// finally the directory itself |
| 28 |
rmdir($dir); |
| 29 |
} |
| 30 |
} |
| 31 |
|