1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace LeKoala\DebugBar\Test\Proxy; |
4
|
|
|
|
5
|
|
|
use SilverStripe\Core\Config\ConfigLoader; |
6
|
|
|
use SilverStripe\Core\Kernel; |
7
|
|
|
use LeKoala\DebugBar\DebugBar; |
8
|
|
|
use SilverStripe\Dev\SapphireTest; |
9
|
|
|
use SilverStripe\Core\Config\Config; |
10
|
|
|
use SilverStripe\Core\Injector\Injector; |
11
|
|
|
use LeKoala\DebugBar\Proxy\ConfigManifestProxy; |
12
|
|
|
use LeKoala\DebugBar\Proxy\SSViewerProxy; |
13
|
|
|
|
14
|
|
|
class ConfigManifestProxyTest extends SapphireTest |
15
|
|
|
{ |
16
|
|
|
protected function setUp() |
17
|
|
|
{ |
18
|
|
|
parent::setUp(); |
19
|
|
|
|
20
|
|
|
DebugBar::initDebugBar(); |
21
|
|
|
|
22
|
|
|
$configLoader = $this->getConfigLoader(); |
23
|
|
|
|
24
|
|
|
// Check top level manifest is our proxy |
25
|
|
|
// TODO: in tests, we have a SilverStripe\Config\Collections\DeltaConfigCollection which is not working with the proxy |
26
|
|
|
if (!($configLoader->getManifest() instanceof ConfigManifestProxy)) { |
27
|
|
|
$this->markTestSkipped("ConfigManifestProxy is not initialized"); |
28
|
|
|
} |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @return ConfigLoader |
33
|
|
|
*/ |
34
|
|
|
protected function getConfigLoader() |
35
|
|
|
{ |
36
|
|
|
return Injector::inst()->get(Kernel::class)->getConfigLoader(); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function testGetCallsAreCaptured() |
40
|
|
|
{ |
41
|
|
|
// TODO: check why this is not working properly |
42
|
|
|
$this->markTestSkipped("Result does not contain SSViewerProxy for some reason to determine"); |
43
|
|
|
|
44
|
|
|
$configLoader = $this->getConfigLoader(); |
45
|
|
|
$manifest = $configLoader->getManifest(); |
46
|
|
|
|
47
|
|
|
Config::inst()->get(SSViewerProxy::class, 'cached'); |
48
|
|
|
$result = $manifest->getConfigCalls(); |
49
|
|
|
$this->assertArrayHasKey(SSViewerProxy::class, $result); |
50
|
|
|
$this->assertArrayHasKey('cached', $result[SSViewerProxy::class]); |
51
|
|
|
$this->assertEquals(1, $result[SSViewerProxy::class]['cached']['calls']); |
52
|
|
|
|
53
|
|
|
Config::inst()->get(SSViewerProxy::class, 'cached'); |
54
|
|
|
Config::inst()->get(SSViewerProxy::class, 'cached'); |
55
|
|
|
Config::inst()->get(SSViewerProxy::class, 'cached'); |
56
|
|
|
$result = $manifest->getConfigCalls(); |
57
|
|
|
$this->assertEquals(4, $result[SSViewerProxy::class]['cached']['calls']); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|