Passed
Push — master ( b4f6c4...81b9da )
by Thomas
02:51 queued 10s
created

ConfigCollectorTest::testGetCallsAreCaptured()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 10
c 1
b 1
f 0
nc 1
nop 0
dl 0
loc 17
rs 9.9332
1
<?php
2
3
namespace LeKoala\DebugBar\Test\Collector;
4
5
use LeKoala\DebugBar\DebugBar;
6
use SilverStripe\View\SSViewer;
7
use SilverStripe\Dev\SapphireTest;
8
use SilverStripe\Core\Config\Config;
9
use LeKoala\DebugBar\Collector\ConfigCollector;
10
use LeKoala\DebugBar\Proxy\ProxyConfigCollectionInterface;
11
12
class ConfigCollectorTest extends SapphireTest
13
{
14
    /**
15
     * @var ConfigCollector
16
     */
17
    private $collector;
18
19
    protected function setUp()
20
    {
21
        parent::setUp();
22
23
        // We need to init DebugBar in order to get our proxied manifests
24
        DebugBar::clearDebugBar();
25
        DebugBar::initDebugBar();
26
        $this->collector = new ConfigCollector();
27
    }
28
29
    public function testGetName()
30
    {
31
        $this->assertNotEmpty($this->collector->getName());
32
    }
33
34
    public function testManifestIsProxied()
35
    {
36
        $manifest = $this->collector->getConfigManifest();
37
        $this->assertInstanceOf(ProxyConfigCollectionInterface::class, $manifest);
38
    }
39
40
    public function testGetCallsAreCaptured()
41
    {
42
        $manifest = $this->collector->getConfigManifest();
43
44
        Config::inst()->get(SSViewer::class, 'themes');
45
        $result = $manifest->getConfigCalls();
0 ignored issues
show
Bug introduced by Thomas
The method getConfigCalls() does not exist on SilverStripe\Config\Coll...nfigCollectionInterface. It seems like you code against a sub-type of SilverStripe\Config\Coll...nfigCollectionInterface such as LeKoala\DebugBar\Proxy\DeltaConfigManifestProxy or LeKoala\DebugBar\Proxy\ConfigManifestProxy. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

45
        /** @scrutinizer ignore-call */ 
46
        $result = $manifest->getConfigCalls();
Loading history...
46
47
        // Note : depending on class hierarchy, another class can be stored instead of the one being called
48
        $this->assertArrayHasKey(SSViewer::class, $result, "Available keys are : " . implode(",", array_keys($result)));
49
        $this->assertEquals(1, $result[SSViewer::class]['themes']['calls']);
50
51
        // Make 3 more calls, it should make 4
52
        Config::inst()->get(SSViewer::class, 'themes');
53
        Config::inst()->get(SSViewer::class, 'themes');
54
        Config::inst()->get(SSViewer::class, 'themes');
55
        $result = $manifest->getConfigCalls();
56
        $this->assertEquals(4, $result[SSViewer::class]['themes']['calls']);
57
    }
58
}
59