Passed
Pull Request — master (#197)
by Chema
06:49 queued 03:38
created

GacelaProfilerTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 25
c 1
b 0
f 0
dl 0
loc 50
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A test_profiler_config_key_is_disabled_then_returns_true_flag_from_setup() 0 12 1
A test_profiler_config_key_is_disabled_then_returns_false_flag_from_setup() 0 12 1
A test_profiler_has_config_key_and_enabled() 0 9 1
A test_profiler_has_config_key_and_disabled() 0 9 1
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 test_profiler_has_config_key_and_enabled(): void
15
    {
16
        $config = $this->createMock(ConfigInterface::class);
17
        $config->method('hasKey')->willReturn(true);
18
        $config->method('get')->willReturn(true);
19
20
        $profiler = new GacelaProfiler($config);
21
22
        self::assertTrue($profiler->isEnabled());
23
    }
24
25
    public function test_profiler_has_config_key_and_disabled(): void
26
    {
27
        $config = $this->createMock(ConfigInterface::class);
28
        $config->method('hasKey')->willReturn(true);
29
        $config->method('get')->willReturn(false);
30
31
        $profiler = new GacelaProfiler($config);
32
33
        self::assertFalse($profiler->isEnabled());
34
    }
35
36
    public function test_profiler_config_key_is_disabled_then_returns_true_flag_from_setup(): void
37
    {
38
        $setupGacela = $this->createMock(SetupGacelaInterface::class);
39
        $setupGacela->method('isProfilerEnabled')->willReturn(true);
40
41
        $config = $this->createMock(ConfigInterface::class);
42
        $config->method('hasKey')->willReturn(false);
43
        $config->method('getSetupGacela')->willReturn($setupGacela);
44
45
        $profiler = new GacelaProfiler($config);
46
47
        self::assertTrue($profiler->isEnabled());
48
    }
49
50
    public function test_profiler_config_key_is_disabled_then_returns_false_flag_from_setup(): void
51
    {
52
        $setupGacela = $this->createMock(SetupGacelaInterface::class);
53
        $setupGacela->method('isProfilerEnabled')->willReturn(false);
54
55
        $config = $this->createMock(ConfigInterface::class);
56
        $config->method('hasKey')->willReturn(false);
57
        $config->method('getSetupGacela')->willReturn($setupGacela);
58
59
        $profiler = new GacelaProfiler($config);
60
61
        self::assertFalse($profiler->isEnabled());
62
    }
63
}
64