|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace AbterPhp\Framework\Bootstrappers\Assets; |
|
4
|
|
|
|
|
5
|
|
|
use AbterPhp\Framework\Assets\CacheManager\ICacheManager; |
|
6
|
|
|
use AbterPhp\Framework\Constant\Env; |
|
7
|
|
|
use AbterPhp\Framework\Environments\Environment; |
|
8
|
|
|
use Opulence\Ioc\Container; |
|
9
|
|
|
use PHPUnit\Framework\TestCase; |
|
10
|
|
|
|
|
11
|
|
|
class CacheManagerBootstrapperTest extends TestCase |
|
12
|
|
|
{ |
|
13
|
|
|
/** @var CacheManagerBootstrapper */ |
|
14
|
|
|
protected CacheManagerBootstrapper $sut; |
|
15
|
|
|
|
|
16
|
|
|
public function setUp(): void |
|
17
|
|
|
{ |
|
18
|
|
|
$this->sut = new CacheManagerBootstrapper(); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
protected function tearDown(): void |
|
22
|
|
|
{ |
|
23
|
|
|
Environment::unsetVar(Env::ENV_NAME); |
|
24
|
|
|
Environment::unsetVar(Env::DIR_MEDIA); |
|
25
|
|
|
Environment::unsetVar(Env::CACHE_BASE_PATH); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function testRegisterBindingsDevelopment() |
|
29
|
|
|
{ |
|
30
|
|
|
Environment::setVar(Env::ENV_NAME, Environment::DEVELOPMENT); |
|
31
|
|
|
Environment::setVar(Env::DIR_MEDIA, '/tmp/foo'); |
|
32
|
|
|
Environment::setVar(Env::CACHE_BASE_PATH, '/tmp/bar'); |
|
33
|
|
|
|
|
34
|
|
|
$container = new Container(); |
|
35
|
|
|
|
|
36
|
|
|
$this->sut->registerBindings($container); |
|
37
|
|
|
|
|
38
|
|
|
$actual = $container->resolve(ICacheManager::class); |
|
39
|
|
|
$this->assertInstanceOf(ICacheManager::class, $actual); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function testRegisterBindingsProduction() |
|
43
|
|
|
{ |
|
44
|
|
|
Environment::setVar(Env::ENV_NAME, Environment::PRODUCTION); |
|
45
|
|
|
Environment::setVar(Env::DIR_MEDIA, '/tmp/foo'); |
|
46
|
|
|
Environment::setVar(Env::CACHE_BASE_PATH, '/tmp/bar'); |
|
47
|
|
|
|
|
48
|
|
|
$container = new Container(); |
|
49
|
|
|
|
|
50
|
|
|
$this->sut->registerBindings($container); |
|
51
|
|
|
|
|
52
|
|
|
$actual = $container->resolve(ICacheManager::class); |
|
53
|
|
|
$this->assertInstanceOf(ICacheManager::class, $actual); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|