|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Sonata Project package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Thomas Rabaix <[email protected]> |
|
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 Sonata\CacheBundle\Tests\Adapter; |
|
13
|
|
|
|
|
14
|
|
|
use Sonata\CacheBundle\Adapter\ApcCache; |
|
15
|
|
|
|
|
16
|
|
|
class ApcCacheTest extends \PHPUnit_Framework_TestCase |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* @var \Symfony\Component\Routing\RouterInterface |
|
20
|
|
|
*/ |
|
21
|
|
|
private $router; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var ApcCache |
|
25
|
|
|
*/ |
|
26
|
|
|
private $cache; |
|
27
|
|
|
|
|
28
|
|
|
public function setUp() |
|
29
|
|
|
{ |
|
30
|
|
|
if (!function_exists('apc_store')) { |
|
31
|
|
|
$this->markTestSkipped('APC is not installed'); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
if (ini_get('apc.enable_cli') == 0) { |
|
35
|
|
|
$this->markTestSkipped('APC is not enabled in cli, please add apc.enable_cli=On into the apc.ini file'); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
$this->router = $this->getMock('Symfony\Component\Routing\RouterInterface'); |
|
39
|
|
|
|
|
40
|
|
|
$this->cache = new ApcCache($this->router, 'token', 'prefix_', array(), array()); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function testInitCache() |
|
44
|
|
|
{ |
|
45
|
|
|
$this->assertTrue($this->cache->flush(array())); |
|
46
|
|
|
$this->assertTrue($this->cache->flushAll()); |
|
47
|
|
|
|
|
48
|
|
|
$cacheElement = $this->cache->set(array('id' => 7), 'data'); |
|
49
|
|
|
|
|
50
|
|
|
$this->assertInstanceOf('Sonata\Cache\CacheElement', $cacheElement); |
|
51
|
|
|
|
|
52
|
|
|
$this->assertTrue($this->cache->has(array('id' => 7))); |
|
53
|
|
|
|
|
54
|
|
|
$this->assertFalse($this->cache->has(array('id' => 8))); |
|
55
|
|
|
|
|
56
|
|
|
$cacheElement = $this->cache->get(array('id' => 7)); |
|
57
|
|
|
|
|
58
|
|
|
$this->assertInstanceOf('Sonata\Cache\CacheElement', $cacheElement); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function testGetUrl() |
|
62
|
|
|
{ |
|
63
|
|
|
$this->router |
|
|
|
|
|
|
64
|
|
|
->expects($this->once()) |
|
65
|
|
|
->method('generate') |
|
66
|
|
|
->with($this->equalTo('sonata_cache_apc'), $this->equalTo(array('token' => 'token'))) |
|
67
|
|
|
->will($this->returnValue('/sonata/cache/apc/token')); |
|
68
|
|
|
|
|
69
|
|
|
$method = new \ReflectionMethod($this->cache, 'getUrl'); |
|
70
|
|
|
$method->setAccessible(true); |
|
71
|
|
|
|
|
72
|
|
|
$this->assertEquals('/sonata/cache/apc/token', $method->invoke($this->cache)); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|
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.