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

ClearLogAndCacheTestListener   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 4
dl 0
loc 22
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A endTestSuite() 0 10 3
A getTempAndLogDirectories() 0 5 1
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