Skip to content

Commit a453546

Browse files
committed
Test user flags with compression
1 parent ccb7e3b commit a453546

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

tests/user-flags.phpt

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@ Memcached user flags
55
--FILE--
66
<?php
77

8-
function check_flag ($flags, $flag)
8+
function check_flags ($flags, $expected_flags)
99
{
10-
return (bool) (($flags & $flag) == $flag);
10+
foreach ($expected_flags as $f) {
11+
if (($flags & $f) != $f) {
12+
echo "Flag {$f} is not set" . PHP_EOL;
13+
return;
14+
}
15+
}
16+
echo "Flags OK" . PHP_EOL;
1117
}
1218

1319
define ('FLAG_1', 1);
@@ -30,11 +36,7 @@ $m->set ($key, '1', 10, FLAG_1 | FLAG_4 | FLAG_64);
3036
$udf_flags = 0;
3137
$value = $m->get ($key, null, $x, $udf_flags);
3238

33-
var_dump (check_flag ($udf_flags, FLAG_1));
34-
var_dump (check_flag ($udf_flags, FLAG_2));
35-
var_dump (check_flag ($udf_flags, FLAG_4));
36-
var_dump (check_flag ($udf_flags, FLAG_32));
37-
var_dump (check_flag ($udf_flags, FLAG_64));
39+
check_flags ($udf_flags, array (FLAG_1, FLAG_4, FLAG_64));
3840

3941
echo "stored without flags" . PHP_EOL;
4042
$m->set ($key, '1');
@@ -43,17 +45,24 @@ $value = $m->get ($key, null, $x, $udf_flags);
4345
var_dump ($udf_flags == 0);
4446
$m->set ($key, '1', 10, FLAG_TOO_LARGE);
4547

48+
$m->setOption(Memcached::OPT_COMPRESSION, true);
49+
$m->setOption(Memcached::OPT_COMPRESSION_TYPE, Memcached::COMPRESSION_FASTLZ);
50+
51+
$m->set ($key, str_repeat ("abcdef1234567890", 200), 10, FLAG_1 | FLAG_4 | FLAG_64);
52+
53+
$udf_flags = 0;
54+
$value_back = $m->get($key, null, null, $udf_flags);
55+
56+
check_flags ($udf_flags, array (FLAG_1, FLAG_4, FLAG_64));
57+
4658
echo "DONE TEST\n";
4759
?>
4860
--EXPECTF--
4961
stored with flags
50-
bool(true)
51-
bool(false)
52-
bool(true)
53-
bool(false)
54-
bool(true)
62+
Flags OK
5563
stored without flags
5664
bool(true)
5765

5866
Warning: Memcached::set(): udf_flags will be limited to 65535 in %s on line %d
67+
Flags OK
5968
DONE TEST

0 commit comments

Comments
 (0)