|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace GacelaTest\Unit\Framework\ClassResolver\Profiler; |
|
6
|
|
|
|
|
7
|
|
|
use Gacela\Framework\Bootstrap\SetupGacelaInterface; |
|
8
|
|
|
use Gacela\Framework\ClassResolver\Profiler\GacelaProfiler; |
|
9
|
|
|
use Gacela\Framework\Config\ConfigInterface; |
|
10
|
|
|
use PHPUnit\Framework\TestCase; |
|
11
|
|
|
|
|
12
|
|
|
final class GacelaProfilerTest extends TestCase |
|
13
|
|
|
{ |
|
14
|
|
|
public function tearDown(): void |
|
15
|
|
|
{ |
|
16
|
|
|
GacelaProfiler::resetCache(); |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
public function test_profiler_has_config_key_and_enabled(): void |
|
20
|
|
|
{ |
|
21
|
|
|
$config = $this->createMock(ConfigInterface::class); |
|
22
|
|
|
$config->method('hasKey')->willReturn(true); |
|
23
|
|
|
$config->method('get')->willReturn(true); |
|
24
|
|
|
|
|
25
|
|
|
$profiler = new GacelaProfiler($config); |
|
26
|
|
|
|
|
27
|
|
|
self::assertTrue($profiler->isEnabled()); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function test_profiler_has_config_key_and_disabled(): void |
|
31
|
|
|
{ |
|
32
|
|
|
$config = $this->createMock(ConfigInterface::class); |
|
33
|
|
|
$config->method('hasKey')->willReturn(true); |
|
34
|
|
|
$config->method('get')->willReturn(false); |
|
35
|
|
|
|
|
36
|
|
|
$profiler = new GacelaProfiler($config); |
|
37
|
|
|
|
|
38
|
|
|
self::assertFalse($profiler->isEnabled()); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function test_profiler_config_key_is_disabled_then_returns_true_flag_from_setup(): void |
|
42
|
|
|
{ |
|
43
|
|
|
$setupGacela = $this->createMock(SetupGacelaInterface::class); |
|
44
|
|
|
$setupGacela->method('isProfilerEnabled')->willReturn(true); |
|
45
|
|
|
|
|
46
|
|
|
$config = $this->createMock(ConfigInterface::class); |
|
47
|
|
|
$config->method('hasKey')->willReturn(false); |
|
48
|
|
|
$config->method('getSetupGacela')->willReturn($setupGacela); |
|
49
|
|
|
|
|
50
|
|
|
$profiler = new GacelaProfiler($config); |
|
51
|
|
|
|
|
52
|
|
|
self::assertTrue($profiler->isEnabled()); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function test_profiler_config_key_is_disabled_then_returns_false_flag_from_setup(): void |
|
56
|
|
|
{ |
|
57
|
|
|
$setupGacela = $this->createMock(SetupGacelaInterface::class); |
|
58
|
|
|
$setupGacela->method('isProfilerEnabled')->willReturn(false); |
|
59
|
|
|
|
|
60
|
|
|
$config = $this->createMock(ConfigInterface::class); |
|
61
|
|
|
$config->method('hasKey')->willReturn(false); |
|
62
|
|
|
$config->method('getSetupGacela')->willReturn($setupGacela); |
|
63
|
|
|
|
|
64
|
|
|
$profiler = new GacelaProfiler($config); |
|
65
|
|
|
|
|
66
|
|
|
self::assertFalse($profiler->isEnabled()); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|