Skip to content

Commit 941ae83

Browse files
committed
add stats/version tests
1 parent f064f6c commit 941ae83

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

tests/memcachedserver.phpt

+28-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
--TEST--
2-
Memcached::get() with cache callback
2+
MemcachedServer
33
--SKIPIF--
44
<?php
55
if (!extension_loaded("memcached")) {
66
die("skip memcached is not loaded\n");
77
}
8+
if (!class_exists("MemcachedServer")) {
9+
die("skip memcached not built with libmemcachedprotocol support\n");
10+
}
811
?>
912
--FILE--
1013
<?php
@@ -31,8 +34,9 @@ var_dump($cache->get('get_this'));
3134
$cache->set ('set_key', 'value 1', 100);
3235
$cache->replace ('replace_key', 'value 2', 200);
3336

34-
// TODO var_dump($cache->getVersion());
35-
// TODO var_dump($cache->getStats());
37+
var_dump($cache->getVersion());
38+
var_dump($cache->getStats());
39+
var_dump($cache->getStats("foobar"));
3640

3741
$cache->quit();
3842

@@ -55,5 +59,26 @@ client_id=[%s]: Noop
5559
string(20) "Hello to you client!"
5660
client_id=[%s]: Set key=[set_key], value=[value 1], flags=[0], expiration=[100], cas=[0]
5761
client_id=[%s]: Replace key=[replace_key], value=[value 2], flags=[0], expiration=[200], cas=[0]
62+
client_id=[%s]: Version
63+
array(1) {
64+
["127.0.0.1:3434"]=>
65+
string(5) "1.1.1"
66+
}
67+
client_id=[%s]: Stat key=[]
68+
array(1) {
69+
["127.0.0.1:3434"]=>
70+
array(1) {
71+
[""]=>
72+
string(15) "Stat reply for "
73+
}
74+
}
75+
client_id=[%s]: Stat key=[foobar]
76+
array(1) {
77+
["127.0.0.1:3434"]=>
78+
array(1) {
79+
["foobar"]=>
80+
string(21) "Stat reply for foobar"
81+
}
82+
}
5883
client_id=[%s]: Client quit
5984
Done

tests/server.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function ($client_id, $key, &$value) {
8686
$server->on (Memcached::ON_VERSION,
8787
function ($client_id, &$value) {
8888
echo "client_id=[$client_id]: Version" . PHP_EOL;
89-
$value = "Stat reply";
89+
$value = "1.1.1";
9090
return Memcached::RESPONSE_SUCCESS;
9191
});
9292

0 commit comments

Comments
 (0)