|
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\Resolver; |
|
8
|
|
|
|
|
9
|
|
|
use eZ\Bundle\EzPublishCoreBundle\Imagine\Cache\Resolver\ProxyResolver; |
|
10
|
|
|
use Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface; |
|
11
|
|
|
use PHPUnit\Framework\TestCase; |
|
12
|
|
|
|
|
13
|
|
|
class ProxyResolverTest extends TestCase |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* @var \PHPUnit_Framework_MockObject_MockObject|\Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface |
|
17
|
|
|
*/ |
|
18
|
|
|
private $resolver; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @var string |
|
22
|
|
|
*/ |
|
23
|
|
|
private $path; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @var string |
|
27
|
|
|
*/ |
|
28
|
|
|
private $filter; |
|
29
|
|
|
|
|
30
|
|
|
protected function setUp() |
|
31
|
|
|
{ |
|
32
|
|
|
parent::setUp(); |
|
33
|
|
|
$this->resolver = $this->getMockBuilder(ResolverInterface::class)->getMock(); |
|
34
|
|
|
$this->path = '7/4/2/0/247-1-eng-GB/img_0885.jpg'; |
|
35
|
|
|
$this->filter = 'medium'; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
View Code Duplication |
public function testResolveUsingProxyHostWithTrailingSlash() |
|
39
|
|
|
{ |
|
40
|
|
|
$hosts = ['http://ezplatform.com/']; |
|
41
|
|
|
$proxyResolver = new ProxyResolver($this->resolver, $hosts); |
|
42
|
|
|
|
|
43
|
|
|
$resolvedPath = 'http://ez.no/var/site/storage/images/_aliases/medium/7/4/2/0/247-1-eng-GB/img_0885.jpg'; |
|
44
|
|
|
|
|
45
|
|
|
$this->resolver |
|
46
|
|
|
->expects($this->once()) |
|
47
|
|
|
->method('resolve') |
|
48
|
|
|
->with($this->path, $this->filter) |
|
49
|
|
|
->willReturn($resolvedPath); |
|
50
|
|
|
|
|
51
|
|
|
$expected = 'http://ezplatform.com/var/site/storage/images/_aliases/medium/7/4/2/0/247-1-eng-GB/img_0885.jpg'; |
|
52
|
|
|
|
|
53
|
|
|
$this->assertEquals($expected, $proxyResolver->resolve($this->path, $this->filter)); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
View Code Duplication |
public function testResolveAndRemovePortUsingProxyHost() |
|
57
|
|
|
{ |
|
58
|
|
|
$hosts = ['http://ez.no']; |
|
59
|
|
|
$proxyResolver = new ProxyResolver($this->resolver, $hosts); |
|
60
|
|
|
|
|
61
|
|
|
$resolvedPath = 'http://ez.no:8060/var/site/storage/images/_aliases/medium/7/4/2/0/247-1-eng-GB/img_0885.jpg'; |
|
62
|
|
|
|
|
63
|
|
|
$this->resolver |
|
64
|
|
|
->expects($this->once()) |
|
65
|
|
|
->method('resolve') |
|
66
|
|
|
->with($this->path, $this->filter) |
|
67
|
|
|
->willReturn($resolvedPath); |
|
68
|
|
|
|
|
69
|
|
|
$expected = 'http://ez.no/var/site/storage/images/_aliases/medium/7/4/2/0/247-1-eng-GB/img_0885.jpg'; |
|
70
|
|
|
|
|
71
|
|
|
$this->assertEquals($expected, $proxyResolver->resolve($this->path, $this->filter)); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
View Code Duplication |
public function testResolveAndRemovePortUsingProxyHostWithTrailingSlash() |
|
75
|
|
|
{ |
|
76
|
|
|
$hosts = ['http://ez.no']; |
|
77
|
|
|
$proxyResolver = new ProxyResolver($this->resolver, $hosts); |
|
78
|
|
|
|
|
79
|
|
|
$resolvedPath = 'http://ezplatform.com:8080/var/site/storage/images/_aliases/medium/7/4/2/0/247-1-eng-GB/img_0885.jpg'; |
|
80
|
|
|
|
|
81
|
|
|
$this->resolver |
|
82
|
|
|
->expects($this->once()) |
|
83
|
|
|
->method('resolve') |
|
84
|
|
|
->with($this->path, $this->filter) |
|
85
|
|
|
->willReturn($resolvedPath); |
|
86
|
|
|
|
|
87
|
|
|
$expected = 'http://ez.no/var/site/storage/images/_aliases/medium/7/4/2/0/247-1-eng-GB/img_0885.jpg'; |
|
88
|
|
|
|
|
89
|
|
|
$this->assertEquals($expected, $proxyResolver->resolve($this->path, $this->filter)); |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|