|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the FOSHttpCacheBundle package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace FOS\HttpCacheBundle\Tests\Functional\Test; |
|
13
|
|
|
|
|
14
|
|
|
use FOS\HttpCacheBundle\Test\ProxyTestCase; |
|
15
|
|
|
|
|
16
|
|
|
class ProxyTestCaseTest extends ProxyTestCase |
|
17
|
|
|
{ |
|
18
|
|
|
protected function setUp() |
|
19
|
|
|
{ |
|
20
|
|
|
static::getContainer()->mock( |
|
|
|
|
|
|
21
|
|
|
'fos_http_cache.test.default_proxy_server', |
|
22
|
|
|
'\FOS\HttpCache\Test\Proxy\VarnishProxy' |
|
23
|
|
|
); |
|
24
|
|
|
|
|
25
|
|
|
parent::setUp(); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function testGetHttpClient() |
|
29
|
|
|
{ |
|
30
|
|
|
$client = $this->getHttpClient(); |
|
31
|
|
|
|
|
32
|
|
|
$this->assertInstanceOf('\Guzzle\Http\Client', $client); |
|
33
|
|
|
$this->assertEquals('http://localhost:8080', $client->getBaseUrl()); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
View Code Duplication |
public function testAssertHit() |
|
|
|
|
|
|
37
|
|
|
{ |
|
38
|
|
|
$response = $this->getResponseMock() |
|
|
|
|
|
|
39
|
|
|
->shouldReceive('hasHeader')->with('X-Cache')->once()->andReturn(true) |
|
40
|
|
|
->shouldReceive('getHeader')->with('X-Cache')->once()->andReturn('HIT') |
|
41
|
|
|
->getMock(); |
|
42
|
|
|
|
|
43
|
|
|
$this->assertHit($response); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
View Code Duplication |
public function testAssertMiss() |
|
|
|
|
|
|
47
|
|
|
{ |
|
48
|
|
|
$response = $this->getResponseMock() |
|
|
|
|
|
|
49
|
|
|
->shouldReceive('hasHeader')->with('X-Cache')->once()->andReturn(true) |
|
50
|
|
|
->shouldReceive('getHeader')->with('X-Cache')->once()->andReturn('MISS') |
|
51
|
|
|
->getMock(); |
|
52
|
|
|
|
|
53
|
|
|
$this->assertMiss($response); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
protected function getResponseMock() |
|
57
|
|
|
{ |
|
58
|
|
|
return \Mockery::mock( |
|
59
|
|
|
'\Guzzle\Http\Message\Response[hasHeader,getHeader]', |
|
60
|
|
|
array(null) |
|
61
|
|
|
); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.