Files
php-memcached/tests/keys.phpt
Xinchen Hui 8b27e5a079 Merge branch 'master' into php7
Conflicts:
	php_memcached.c
	php_memcached_session.c
2016-07-23 11:33:53 +08:00

50 lines
1.3 KiB
PHP

--TEST--
Test different kind of keys
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname (__FILE__) . '/config.inc';
$binary = memc_get_instance (array (
Memcached::OPT_BINARY_PROTOCOL => true,
));
$ascii = memc_get_instance ();
$ascii->setOption(Memcached::OPT_VERIFY_KEY, 1);
var_dump ($binary->set ('binary key with spaces', 'this is a test'));
var_dump ($binary->getResultCode () == Memcached::RES_SUCCESS);
var_dump ($binary->set ('binarykeywithnewline' . PHP_EOL, 'this is a test'));
var_dump ($binary->getResultCode () == Memcached::RES_BAD_KEY_PROVIDED);
var_dump ($ascii->set ('ascii key with spaces', 'this is a test'));
var_dump ($ascii->getResultCode () == Memcached::RES_BAD_KEY_PROVIDED);
var_dump ($binary->set ('asciikeywithnewline' . PHP_EOL, 'this is a test'));
var_dump ($binary->getResultCode () == Memcached::RES_BAD_KEY_PROVIDED);
var_dump ($ascii->set (''/*empty key*/, 'this is a test'));
var_dump ($ascii->getResultCode () == Memcached::RES_BAD_KEY_PROVIDED);
var_dump ($ascii->set (str_repeat ('1234567890', 512), 'this is a test'));
var_dump ($ascii->getResultCode () == Memcached::RES_BAD_KEY_PROVIDED);
echo "OK" . PHP_EOL;
--EXPECT--
bool(true)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
bool(false)
bool(true)
OK