Passed
Push — master ( 1451be...870e13 )
by Caen
05:30 queued 02:35
created

TestCase::cleanUpFilesystem()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 5
eloc 9
c 3
b 0
f 0
nc 5
nop 0
dl 0
loc 16
rs 9.6111
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Hyde\Testing;
6
7
use Hyde\Facades\Features;
8
use Illuminate\View\Component;
9
use LaravelZero\Framework\Testing\TestCase as BaseTestCase;
10
11
abstract class TestCase extends BaseTestCase
12
{
13
    use CreatesApplication;
14
    use ResetsApplication;
15
    use CreatesTemporaryFiles;
16
    use InteractsWithPages;
17
18
    protected static bool $booted = false;
19
20
    protected function setUp(): void
21
    {
22
        parent::setUp();
23
24
        if (! static::$booted) {
25
            $this->resetApplication();
26
27
            static::$booted = true;
28
        }
29
    }
30
31
    protected function tearDown(): void
32
    {
33
        $this->cleanUpFilesystem();
34
35
        if (method_exists(\Illuminate\View\Component::class, 'flushCache')) {
36
            /** Until https://github.com/laravel/framework/pull/44648 makes its way into Laravel Zero, we need to clear the cache ourselves */
37
            Component::flushCache();
38
            Component::forgetComponentsResolver();
39
            Component::forgetFactory();
40
        }
41
42
        Features::clearMockedInstances();
43
44
        parent::tearDown();
45
    }
46
}
47