Completed
Push — 6.13 ( 299dc7...bbf433 )
by
unknown
46:15 queued 21:37
created

testCreateProxyCacheResolver()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20

Duplication

Lines 20
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 20
loc 20
rs 9.6
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
namespace eZ\Bundle\EzPublishCoreBundle\Tests\Imagine\Cache;
8
9
use eZ\Bundle\EzPublishCoreBundle\Imagine\Cache\Resolver\RelativeResolver;
10
use eZ\Bundle\EzPublishCoreBundle\Imagine\Cache\ResolverFactory;
11
use eZ\Publish\Core\MVC\ConfigResolverInterface;
12
use Liip\ImagineBundle\Imagine\Cache\Resolver\ProxyResolver;
13
use Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface;
14
use PHPUnit\Framework\TestCase;
15
16
class ResolverFactoryTest extends TestCase
17
{
18
    /**
19
     * @var \PHPUnit_Framework_MockObject_MockObject|\eZ\Publish\Core\MVC\ConfigResolverInterface
20
     */
21
    private $configResolver;
22
23
    /**
24
     * @var \PHPUnit_Framework_MockObject_MockObject|\Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface
25
     */
26
    private $resolver;
27
28
    /**
29
     * @var \eZ\Bundle\EzPublishCoreBundle\Imagine\Cache\ResolverFactory
30
     */
31
    private $factory;
32
33
    protected function setUp()
34
    {
35
        parent::setUp();
36
        $this->configResolver = $this->getMockBuilder(ConfigResolverInterface::class)->getMock();
37
        $this->resolver = $this->getMockBuilder(ResolverInterface::class)->getMock();
38
        $this->factory = new ResolverFactory(
39
            $this->configResolver,
40
            $this->resolver,
41
            ProxyResolver::class,
42
            RelativeResolver::class
43
        );
44
    }
45
46 View Code Duplication
    public function testCreateProxyCacheResolver()
47
    {
48
        $this->configResolver
49
            ->expects($this->at(0))
50
            ->method('hasParameter')
51
            ->with('image_host')
52
            ->willReturn(true);
53
54
        $host = 'http://ez.no';
55
56
        $this->configResolver
57
            ->expects($this->at(1))
58
            ->method('getParameter')
59
            ->with('image_host')
60
            ->willReturn($host);
61
62
        $expected = new ProxyResolver($this->resolver, [$host]);
63
64
        $this->assertEquals($expected, $this->factory->createCacheResolver());
65
    }
66
67 View Code Duplication
    public function testCreateRelativeCacheResolver()
68
    {
69
        $this->configResolver
70
            ->expects($this->at(0))
71
            ->method('hasParameter')
72
            ->with('image_host')
73
            ->willReturn(true);
74
75
        $host = '/';
76
77
        $this->configResolver
78
            ->expects($this->at(1))
79
            ->method('getParameter')
80
            ->with('image_host')
81
            ->willReturn($host);
82
83
        $expected = new RelativeResolver($this->resolver);
84
85
        $this->assertEquals($expected, $this->factory->createCacheResolver());
86
    }
87
}
88