-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathConfigCachingServiceTest.php
57 lines (42 loc) · 1.85 KB
/
ConfigCachingServiceTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
use Mockery as m;
use JsLocalization\Facades\ConfigCachingService;
class ConfigCachingServiceTest extends TestCase {
public function setUp()
{
parent::setUp();
Cache::forget(JsLocalization\Caching\ConfigCachingService::CACHE_KEY);
Cache::forget(JsLocalization\Caching\ConfigCachingService::CACHE_TIMESTAMP_KEY);
}
public function tearDown()
{
m::close();
parent::tearDown();
}
public function testIsDisabled()
{
Config::set('js-localization.disable_config_cache', false);
$this->assertFalse(ConfigCachingService::isDisabled());
Config::set('js-localization.disable_config_cache', true);
$this->assertTrue(ConfigCachingService::isDisabled());
}
public function testGetConfigJson()
{
$expectedJson = json_encode($this->testConfigExportFlat);
$this->assertEquals($expectedJson, ConfigCachingService::getConfigJson());
// Test that getConfigJson() returns the old value after Config::set()
Config::set('js-localization.test-config', 'new value');
$this->assertEquals($expectedJson, ConfigCachingService::getConfigJson());
}
public function testGetConfigJsonWithCacheDisabled()
{
Config::set('js-localization.disable_config_cache', true);
$expectedJson = json_encode($this->testConfigExportFlat);
$this->assertEquals($expectedJson, ConfigCachingService::getConfigJson());
// Test that getConfigJson() returns the new value after Config::set()
$this->testConfigExportFlat['js-localization.test-config'] = 'new value';
$expectedJson = json_encode($this->testConfigExportFlat);
Config::set('js-localization.test-config', 'new value');
$this->assertEquals($expectedJson, ConfigCachingService::getConfigJson());
}
}