Completed
Push — master ( 856f7c...9f8837 )
by Robbie
01:36
created

CacheAfterCallAspectTest::testAfterCall()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
3
namespace LeKoala\DebugBar\Test\Aspect;
4
5
use LeKoala\DebugBar\Aspect\CacheAfterCallAspect;
6
use LeKoala\DebugBar\Collector\PartialCacheCollector;
7
use Psr\SimpleCache\CacheInterface;
8
use SilverStripe\Core\Injector\AopProxyService;
9
use SilverStripe\Core\Injector\Injector;
10
use SilverStripe\Dev\SapphireTest;
11
12
class CacheAfterCallAspectTest extends SapphireTest
13
{
14
    /**
15
     * Tests if an entry was added to PartialCacheCollector::$template_cache_info array
16
     */
17
    public function testAfterCall()
18
    {
19
        $proxy = new AopProxyService();
20
        $aspect = new CacheAfterCallAspect();
21
        $proxy->afterCall = array(
22
            'get' => $aspect
23
        );
24
        $count = count(PartialCacheCollector::getTemplateCache());
25
        $proxy->proxied = Injector::inst()->get(CacheInterface::class . '.backend');
26
        $cacheKey = 'myCacheKey';
27
        $proxy->get($cacheKey);
28
        $this->assertCount($count + 1, PartialCacheCollector::getTemplateCache());
29
    }
30
}
31