CacheAdapterTest::testStoreItem()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 12
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * File: CacheAdapterTest.php
4
 *
5
 * @author      Maciej Sławik <[email protected]>
6
 * Github:      https://github.com/maciejslawik
7
 */
8
9
namespace MSlwk\Otomoto\Middleware\Test\Unit\Adapter;
10
11
use MSlwk\Otomoto\Middleware\Cache\Adapter\CacheAdapter;
12
use PHPUnit\Framework\TestCase;
13
use Stash\Interfaces\ItemInterface;
14
use Stash\Interfaces\PoolInterface;
15
16
/**
17
 * Class CacheAdapterTest
18
 * @package MSlwk\Otomoto\Middleware\Test\Unit\Adapter
19
 */
20
class CacheAdapterTest extends TestCase
21
{
22
    /**
23
     * @test
24
     */
25
    public function testStoreItem()
26
    {
27
        $pool = $this->getMockBuilder(PoolInterface::class)
28
            ->getMock();
29
        $pool->expects($this->once())
30
            ->method('save');
31
32
        $item = $this->getMockBuilder(ItemInterface::class)
33
            ->getMock();
34
35
        $cacheAdapter = new CacheAdapter($pool);
36
        $cacheAdapter->store($item);
37
    }
38
39
    /**
40
     * @test
41
     */
42
    public function testRetrieveItem()
43
    {
44
        $item = $this->getMockBuilder(ItemInterface::class)
45
            ->getMock();
46
47
        $pool = $this->getMockBuilder(PoolInterface::class)
48
            ->getMock();
49
        $pool->expects($this->once())
50
            ->method('getItem')
51
            ->will($this->returnValue($item));
52
53
        $cacheAdapter = new CacheAdapter($pool);
54
55
        $this->assertInstanceOf(ItemInterface::class, $cacheAdapter->retrieve('test_path'));
56
    }
57
}
58