Completed
Push — 8.7 ( b6d8c1...3ac046 )
by Markus
06:49
created

IdStoreTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 14
c 1
b 0
f 0
dl 0
loc 39
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testHas() 0 5 1
A testSet() 0 6 1
A setUp() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DMK\MKSamlAuth\Tests\Unit\Store;
6
7
use DMK\MKSamlAuth\Store\IdStore;
8
use PHPUnit\Framework\TestCase;
9
use TYPO3\CMS\Core\Cache\CacheManager;
10
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
11
12
class IdStoreTest extends TestCase
13
{
14
    /**
15
     * @var IdStore
16
     */
17
    private $store;
18
    /**
19
     * @var \Prophecy\Prophecy\ObjectProphecy
20
     */
21
    private $cacheManager;
22
    /**
23
     * @var \Prophecy\Prophecy\ObjectProphecy
24
     */
25
    private $cache;
26
27
    protected function setUp()
28
    {
29
        $this->cache = $this->prophesize(FrontendInterface::class);
30
31
        $this->cacheManager = $this->prophesize(CacheManager::class);
32
        $this->cacheManager->getCache(IdStore::CACHE_KEY)->willReturn($this->cache->reveal());
33
34
        $this->store = new IdStore();
35
        $this->store->injectCacheManager($this->cacheManager->reveal());
36
    }
37
38
    public function testHas()
39
    {
40
        $this->cache->has('footest')->willReturn(false);
41
42
        self::assertFalse($this->store->has('foo', 'test'));
43
    }
44
45
    public function testSet()
46
    {
47
        $this->cache->set('footest', 'cdeb68b68f311608163d0d2f451ac96a', [], 300)
48
            ->shouldBeCalled();
49
50
        $this->store->set('foo', 'test', new \DateTime('+5 minutes'));
51
    }
52
}
53