forked from phadej/php-memcached
-
Notifications
You must be signed in to change notification settings - Fork 2
/
types.phpt
72 lines (58 loc) · 1.48 KB
/
types.phpt
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
--TEST--
Memcached store & fetch type and value correctness
--SKIPIF--
<?php if (!extension_loaded("memcached")) print "skip"; ?>
--FILE--
<?php
$m = new Memcached();
$m->addServer('127.0.0.1', 11211, 1);
class testclass {
}
$data = array(
array('boolean_true', true),
array('boolean_false', false),
array('string', "just a string"),
array('string_empty', ""),
array('integer_positive_integer', 10),
array('integer_negative_integer', -10),
array('integer_zero_integer', 0),
array('float_positive1', 3.912131),
array('float_positive2', 1.2131E+501),
array('float_positive2', 1.2131E+52),
array('float_negative', -42.123312),
array('float_zero', 0.0),
array('null', null),
array('array_empty', array()),
array('array', array(1,2,3,"foo")),
array('object_array_empty', (object)array()),
array('object_array', (object)array(1,2,3)),
array('object_dummy', new testclass()),
);
foreach ($data as $key => $value) {
$m->delete($key);
}
foreach ($data as $types) {
$m->set($types[0], $types[1]);
$actual = $m->get($types[0]);
if ($types[1] !== $actual) {
if (is_object($types[1])
&& $types[1] == $actual
&& get_class($types[1]) == get_class($actual)) {
continue;
}
echo "=== $types[0] ===\n";
echo "Expected: ";
var_dump($types[1]);
echo "Actual: ";
var_dump($actual);
}
}
$m->flush();
if (($actual = $m->get("sdfjhw38rwdenfoqu29eiajfroehr8jaiodfhjaoierhjadf")) !== false) {
echo "Expected: null";
echo "Actual: " . gettype($actual);
}
echo "OK\n";
?>
--EXPECT--
OK