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

CacheAfterCallAspectTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 5
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testAfterCall() 0 13 1
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