1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace GacelaTest\Unit\Framework\ClassResolver\Cache; |
6
|
|
|
|
7
|
|
|
use Gacela\Framework\Bootstrap\SetupGacelaInterface; |
8
|
|
|
use Gacela\Framework\ClassResolver\Cache\GacelaCache; |
9
|
|
|
use Gacela\Framework\Config\ConfigInterface; |
10
|
|
|
use PHPUnit\Framework\TestCase; |
11
|
|
|
|
12
|
|
|
final class GacelaCacheTest extends TestCase |
13
|
|
|
{ |
14
|
|
|
public function test_gacela_setup_is_disabled(): void |
15
|
|
|
{ |
16
|
|
|
$setupGacela = $this->createMock(SetupGacelaInterface::class); |
17
|
|
|
$setupGacela->method('isCacheEnabled') |
18
|
|
|
->willReturn(false); |
19
|
|
|
$config = $this->createMock(ConfigInterface::class); |
20
|
|
|
$config->method('getSetupGacela') |
21
|
|
|
->willReturn($setupGacela); |
22
|
|
|
|
23
|
|
|
$gacelaCache = new GacelaCache($config); |
24
|
|
|
|
25
|
|
|
self::assertFalse($gacelaCache->isProjectCacheEnabled()); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function test_application_config_key_is_disabled(): void |
29
|
|
|
{ |
30
|
|
|
$setupGacela = $this->createMock(SetupGacelaInterface::class); |
31
|
|
|
$setupGacela->method('isCacheEnabled') |
32
|
|
|
->willReturn(true); |
33
|
|
|
$config = $this->createMock(ConfigInterface::class); |
34
|
|
|
$config->method('getSetupGacela') |
35
|
|
|
->willReturn($setupGacela); |
36
|
|
|
$config->method('get') |
37
|
|
|
->willReturn(false); |
38
|
|
|
|
39
|
|
|
$gacelaCache = new GacelaCache($config); |
40
|
|
|
|
41
|
|
|
self::assertFalse($gacelaCache->isProjectCacheEnabled()); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function test_cache_is_enabled(): void |
45
|
|
|
{ |
46
|
|
|
$setupGacela = $this->createMock(SetupGacelaInterface::class); |
47
|
|
|
$setupGacela->method('isCacheEnabled') |
48
|
|
|
->willReturn(true); |
49
|
|
|
$config = $this->createMock(ConfigInterface::class); |
50
|
|
|
$config->method('getSetupGacela') |
51
|
|
|
->willReturn($setupGacela); |
52
|
|
|
$config->method('get') |
53
|
|
|
->willReturn(true); |
54
|
|
|
|
55
|
|
|
$gacelaCache = new GacelaCache($config); |
56
|
|
|
|
57
|
|
|
self::assertTrue($gacelaCache->isProjectCacheEnabled()); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|