Skip to content

Commit 2d5d4bf

Browse files
remicolletm6w6
authored andcommitted
add IPv6 test
1 parent 4e7f20c commit 2d5d4bf

File tree

3 files changed

+120
-0
lines changed

3 files changed

+120
-0
lines changed

tests/memcachedserver.phpt

+4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ $cache->replace ('replace_key', 'value 2', 200);
4040

4141
var_dump($cache->getVersion());
4242
var_dump($cache->getStats());
43+
var_dump($cache->getStats("empty"));
4344
var_dump($cache->getStats("foobar"));
4445
var_dump($cache->getStats("scalar"));
4546
var_dump($cache->getStats("numeric array"));
@@ -80,6 +81,9 @@ array(1) {
8081
string(3) "bar"
8182
}
8283
}
84+
client_id=[%s]: Stat key=[empty]
85+
array(0) {
86+
}
8387
client_id=[%s]: Stat key=[foobar]
8488
array(1) {
8589
["127.0.0.1:3434"]=>

tests/memcachedserver6.phpt

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
--TEST--
2+
MemcachedServer
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("memcached")) {
6+
die("skip memcached is not loaded\n");
7+
}
8+
if (!class_exists("MemcachedServer")) {
9+
die("skip memcached not built with libmemcachedprotocol support\n");
10+
}
11+
?>
12+
--FILE--
13+
<?php
14+
include __DIR__ . '/server.inc';
15+
$server = memcached_server_start('server.php', '[::1]', 3434);
16+
17+
$cache = new Memcached();
18+
$cache->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
19+
$cache->setOption(Memcached::OPT_COMPRESSION, false);
20+
$cache->addServer('[::1]', 3434);
21+
22+
$cache->add("add_key", "hello", 500);
23+
$cache->append("append_key", "world");
24+
$cache->prepend("prepend_key", "world");
25+
26+
$cache->increment("incr", 2, 1, 500);
27+
$cache->decrement("decr", 2, 1, 500);
28+
29+
$cache->delete("delete_k");
30+
$cache->flush(1);
31+
32+
var_dump($cache->get('get_this'));
33+
34+
$cache->set ('set_key', 'value 1', 100);
35+
$cache->replace ('replace_key', 'value 2', 200);
36+
37+
var_dump($cache->getVersion());
38+
var_dump($cache->getStats());
39+
var_dump($cache->getStats("empty"));
40+
var_dump($cache->getStats("foobar"));
41+
var_dump($cache->getStats("scalar"));
42+
var_dump($cache->getStats("numeric array"));
43+
44+
$cache->quit();
45+
46+
memcached_server_stop($server);
47+
?>
48+
Done
49+
--EXPECTF--
50+
Listening on [::1]:3434
51+
Incoming connection from [::1]:%s
52+
Incoming connection from [::1]:%s
53+
client_id=[%s]: Add key=[add_key], value=[hello], flags=[0], expiration=[500]
54+
client_id=[%s]: Append key=[append_key], value=[world], cas=[0]
55+
client_id=[%s]: Prepend key=[prepend_key], value=[world], cas=[0]
56+
client_id=[%s]: Incrementing key=[incr], delta=[2], initial=[1], expiration=[500]
57+
client_id=[%s]: Decrementing key=[decr], delta=[2], initial=[1], expiration=[500]
58+
client_id=[%s]: Delete key=[delete_k], cas=[0]
59+
client_id=[%s]: Flush when=[1]
60+
client_id=[%s]: Get key=[get_this]
61+
client_id=[%s]: Noop
62+
string(20) "Hello to you client!"
63+
client_id=[%s]: Set key=[set_key], value=[value 1], flags=[0], expiration=[100], cas=[0]
64+
client_id=[%s]: Replace key=[replace_key], value=[value 2], flags=[0], expiration=[200], cas=[0]
65+
client_id=[%s]: Version
66+
array(1) {
67+
["[::1]:3434"]=>
68+
string(5) "1.1.1"
69+
}
70+
client_id=[%s]: Stat key=[]
71+
array(1) {
72+
["[::1]:3434"]=>
73+
array(2) {
74+
["key"]=>
75+
string(0) ""
76+
["foo"]=>
77+
string(3) "bar"
78+
}
79+
}
80+
client_id=[%s]: Stat key=[empty]
81+
array(0) {
82+
}
83+
client_id=[%s]: Stat key=[foobar]
84+
array(1) {
85+
["[::1]:3434"]=>
86+
array(2) {
87+
["key"]=>
88+
string(6) "foobar"
89+
["foo"]=>
90+
string(3) "bar"
91+
}
92+
}
93+
client_id=[%s]: Stat key=[scalar]
94+
array(1) {
95+
["[::1]:3434"]=>
96+
array(1) {
97+
[0]=>
98+
string(%d) "you want it, you get it"
99+
}
100+
}
101+
client_id=[%s]: Stat key=[numeric array]
102+
array(1) {
103+
["[::1]:3434"]=>
104+
array(3) {
105+
[-1]=>
106+
string(3) "one"
107+
[0]=>
108+
string(3) "two"
109+
[1]=>
110+
string(5) "three"
111+
}
112+
}
113+
client_id=[%s]: Client quit
114+
Done

tests/server.php

+2
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ function ($client_id, $key, array &$values) {
8484
$values = "you want it, you get it";
8585
} elseif ($key === "numeric array") {
8686
$values = [-1 => "one", "two", "three"];
87+
} elseif ($key === "empty") {
88+
$values = [];
8789
} else {
8890
$values["key"] = $key;
8991
$values["foo"] = "bar";

0 commit comments

Comments
 (0)