-
Notifications
You must be signed in to change notification settings - Fork 16
/
FingerprintedTestCase.php
53 lines (45 loc) 路 1.38 KB
/
FingerprintedTestCase.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
namespace Castor\Tests\Examples\Fingerprint;
use Castor\PlatformHelper;
use Castor\Tests\TaskTestCase;
use Symfony\Component\Finder\Finder;
abstract class FingerprintedTestCase extends TaskTestCase
{
public static function tearDownAfterClass(): void
{
self::clearFingerprintsCache();
}
protected function setUp(): void
{
self::clearFingerprintsCache();
}
private static function clearFingerprintsCache(): void
{
if (is_dir(PlatformHelper::getCacheDirectory())) {
foreach (
(new Finder())
->in(PlatformHelper::getCacheDirectory())
->contains('.fingerprint')
->files() as $file
) {
unlink($file->getRealPath());
}
foreach (
(new Finder())
->in(PlatformHelper::getCacheDirectory())
->notContains('.fingerprint')
->directories() as $directory
) {
rmdir($directory->getRealPath());
}
}
$examplesFingerprintFile = (new Finder())
->in(\dirname(__DIR__, 3) . '/examples')
->name('*.fingerprint_*')
->notName('*.php')
;
foreach ($examplesFingerprintFile as $file) {
unlink($file->getRealPath());
}
}
}