Completed
Push — master ( d3c0d4...e76e12 )
by John
04:31
created

TestCacheSmashingPHPUnitListener::addSkippedTest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 3
1
<?php declare(strict_types = 1);
2
/*
3
 * This file is part of the KleijnWeb\SwaggerBundle package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace KleijnWeb\SwaggerBundle\Tests\Functional;
10
11
use PHPUnit_Framework_Test;
12
use PHPUnit_Framework_AssertionFailedError;
13
use Exception;
14
use PHPUnit_Framework_TestSuite;
15
16
class TestCacheSmashingPHPUnitListener implements \PHPUnit_Framework_TestListener
17
{
18
    const SUITE_NAME = 'Functional';
19
20
    public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
21
    {
22
        //NOOP
23
    }
24
25
    public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
26
    {
27
        //NOOP
28
    }
29
30
    public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)
31
    {
32
        //NOOP
33
    }
34
35
    public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time)
36
    {
37
        //NOOP
38
    }
39
40
    public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
41
    {
42
        //NOOP
43
    }
44
45
    public function startTest(PHPUnit_Framework_Test $test)
46
    {
47
        //NOOP
48
    }
49
50
    public function endTest(PHPUnit_Framework_Test $test, $time)
51
    {
52
        //NOOP
53
    }
54
55
    public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
56
    {
57
        $this->smashIfFunctionalSuite($suite);
58
    }
59
60
    public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
61
    {
62
        $this->smashIfFunctionalSuite($suite);
63
    }
64
65
    private function smashIfFunctionalSuite(PHPUnit_Framework_TestSuite $suite)
66
    {
67
        if ($suite->getName() !== self::SUITE_NAME) {
68
            return;
69
        }
70
71
        $iterator = new \RecursiveIteratorIterator(
72
            new \RecursiveDirectoryIterator(__DIR__ . '/PetStore/app/cache', \FilesystemIterator::SKIP_DOTS),
73
            \RecursiveIteratorIterator::CHILD_FIRST
74
        );
75
76
        foreach ($iterator as $path) {
77
            $path->isDir() && !$path->isLink() ? rmdir($path->getPathname()) : unlink($path->getPathname());
78
        }
79
    }
80
}