Completed
Push — master ( 79e164...d4fdcb )
by Tomáš
06:12
created

getTempAndLogDirectories()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Symplify\ControllerAutowire\Tests\PHPUnit\Listener;
6
7
use Nette\Utils\FileSystem;
8
use Nette\Utils\Finder;
9
use PHPUnit_Framework_BaseTestListener;
10
use PHPUnit_Framework_TestSuite;
11
12
final class ClearLogAndCacheTestListener extends PHPUnit_Framework_BaseTestListener
13
{
14
    public function endTestSuite(PHPUnit_Framework_TestSuite $testSuite)
15
    {
16
        if ($testSuite->getName()) { // skip for tests, run only for whole Test Suite
17
            return;
18
        }
19
20
        foreach ($this->getTempAndLogDirectories() as $path => $info) {
21
            FileSystem::delete($path);
22
        }
23
    }
24
25
    /**
26
     * @return string[]
27
     */
28
    private function getTempAndLogDirectories() : array
29
    {
30
        $finder = Finder::findDirectories('cache', 'logs')->from(__DIR__ . '/../..');
31
        return iterator_to_array($finder->getIterator());
32
    }
33
}
34