blob: de4d182a2f6b4261b8508329dd3d00b7dcca3077 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
<?php
namespace Guzzle\Tests\Plugin\Cache;
use Guzzle\Http\Message\Request;
use Guzzle\Http\Message\Response;
use Guzzle\Plugin\Cache\DefaultCanCacheStrategy;
/**
* @covers Guzzle\Plugin\Cache\DefaultCanCacheStrategy
*/
class DefaultCanCacheStrategyTest extends \Guzzle\Tests\GuzzleTestCase
{
public function testReturnsRequestcanCacheRequest()
{
$strategy = new DefaultCanCacheStrategy();
$request = new Request('GET', 'http://foo.com');
$this->assertTrue($strategy->canCacheRequest($request));
}
public function testDoesNotCacheNoStore()
{
$strategy = new DefaultCanCacheStrategy();
$request = new Request('GET', 'http://foo.com', array('cache-control' => 'no-store'));
$this->assertFalse($strategy->canCacheRequest($request));
}
public function testCanCacheResponse()
{
$response = $this->getMockBuilder('Guzzle\Http\Message\Response')
->setMethods(array('canCache'))
->setConstructorArgs(array(200))
->getMock();
$response->expects($this->once())
->method('canCache')
->will($this->returnValue(true));
$strategy = new DefaultCanCacheStrategy();
$this->assertTrue($strategy->canCacheResponse($response));
}
}
|