-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMemcacheTest.php
More file actions
executable file
·124 lines (109 loc) · 3.15 KB
/
Copy pathMemcacheTest.php
File metadata and controls
executable file
·124 lines (109 loc) · 3.15 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
include_once(Kohana::find_file('tests/cache/arithmetic', 'CacheArithmeticMethods'));
/**
* @package Kohana/Cache/Memcache
* @group kohana
* @group kohana.cache
* @category Test
* @author Kohana Team
* @copyright (c) 2009-2012 Kohana Team
* @license http://kohanaphp.com/license
*/
class Kohana_CacheArithmeticMemcacheTest extends Kohana_CacheArithmeticMethodsTest {
/**
* This method MUST be implemented by each driver to setup the `Cache`
* instance for each test.
*
* This method should do the following tasks for each driver test:
*
* - Test the Cache instance driver is available, skip test otherwise
* - Setup the Cache instance
* - Call the parent setup method, `parent::setUp()`
*
* @return void
*/
public function setUp()
{
parent::setUp();
if ( ! extension_loaded('memcache'))
{
$this->markTestSkipped('Memcache PHP Extension is not available');
}
if ( ! $config = Kohana::$config->load('cache.memcache'))
{
Kohana::$config->load('cache')
->set(
'memcache',
array(
'driver' => 'memcache',
'default_expire' => 3600,
'compression' => FALSE, // Use Zlib compression (can cause issues with integers)
'servers' => array(
'local' => array(
'host' => 'localhost', // Memcache Server
'port' => 11211, // Memcache port number
'persistent' => FALSE, // Persistent connection
'weight' => 1,
'timeout' => 1,
'retry_interval' => 15,
'status' => TRUE,
),
),
'instant_death' => TRUE,
)
);
$config = Kohana::$config->load('cache.memcache');
}
$memcache = new Memcache;
if ( ! $memcache->connect($config['servers']['local']['host'],
$config['servers']['local']['port']))
{
$this->markTestSkipped('Unable to connect to memcache server @ '.
$config['servers']['local']['host'].':'.
$config['servers']['local']['port']);
}
if ($memcache->getVersion() === FALSE)
{
$this->markTestSkipped('Memcache server @ '.
$config['servers']['local']['host'].':'.
$config['servers']['local']['port'].
' not responding!');
}
unset($memcache);
$this->cache(Cache::instance('memcache'));
}
/**
* Tests that multiple values set with Memcache do not cause unexpected
* results. For accurate results, this should be run with a memcache
* configuration that includes multiple servers.
*
* This is to test #4110
*
* @link http://dev.kohanaframework.org/issues/4110
* @return void
*/
public function test_multiple_set()
{
$cache = $this->cache();
$id_set = 'set_id';
$ttl = 300;
$data = array(
'foobar',
0,
1.0,
new stdClass,
array('foo', 'bar' => 1),
TRUE,
NULL,
FALSE
);
$previous_set = $cache->get($id_set, NULL);
foreach ($data as $value)
{
// Use Equals over Sames as Objects will not be equal
$this->assertEquals($previous_set, $cache->get($id_set, NULL));
$cache->set($id_set, $value, $ttl);
$previous_set = $value;
}
}
} // End Kohana_CacheArithmeticMemcacheTest