1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of the KleijnWeb\JwtBundle 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\JwtBundle\Tests\Functional; |
10
|
|
|
|
11
|
|
|
use Exception; |
12
|
|
|
use PHPUnit\Framework\AssertionFailedError; |
13
|
|
|
use PHPUnit\Framework\Test; |
14
|
|
|
use PHPUnit\Framework\TestListener; |
15
|
|
|
use PHPUnit\Framework\TestSuite; |
16
|
|
|
use PHPUnit\Framework\Warning; |
17
|
|
|
|
18
|
|
|
class TestCacheSmashingPHPUnitListener implements TestListener |
19
|
|
|
{ |
20
|
|
|
const SUITE_NAME = 'Functional'; |
21
|
|
|
|
22
|
|
|
public function addError(Test $test, Exception $e, $time) |
23
|
|
|
{ |
24
|
|
|
//NOOP |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function addFailure(Test $test, AssertionFailedError $e, $time) |
28
|
|
|
{ |
29
|
|
|
//NOOP |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function addIncompleteTest(Test $test, Exception $e, $time) |
33
|
|
|
{ |
34
|
|
|
//NOOP |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function addRiskyTest(Test $test, Exception $e, $time) |
38
|
|
|
{ |
39
|
|
|
//NOOP |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function addSkippedTest(Test $test, Exception $e, $time) |
43
|
|
|
{ |
44
|
|
|
//NOOP |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function addWarning(Test $test, Warning $e, $time) |
48
|
|
|
{ |
49
|
|
|
//NOOP |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function startTest(Test $test) |
53
|
|
|
{ |
54
|
|
|
//NOOP |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function endTest(Test $test, $time) |
58
|
|
|
{ |
59
|
|
|
//NOOP |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function startTestSuite(TestSuite $suite) |
63
|
|
|
{ |
64
|
|
|
$this->smashIfFunctionalSuite($suite); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function endTestSuite(TestSuite $suite) |
68
|
|
|
{ |
69
|
|
|
$this->smashIfFunctionalSuite($suite); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
private function smashIfFunctionalSuite(TestSuite $suite) |
73
|
|
|
{ |
74
|
|
|
if ($suite->getName() !== self::SUITE_NAME) { |
75
|
|
|
return; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
$dir = __DIR__ . '/App/app/cache'; |
79
|
|
|
|
80
|
|
|
if (!is_dir($dir)) { |
81
|
|
|
return; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
$iterator = new \RecursiveIteratorIterator( |
85
|
|
|
new \RecursiveDirectoryIterator($dir, \FilesystemIterator::SKIP_DOTS), |
86
|
|
|
\RecursiveIteratorIterator::CHILD_FIRST |
87
|
|
|
); |
88
|
|
|
|
89
|
|
|
foreach ($iterator as $path) { |
90
|
|
|
$path->isDir() && !$path->isLink() ? rmdir($path->getPathname()) : unlink($path->getPathname()); |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|