PATH:
opt
/
cpanel
/
ea-php71
/
root
/
usr
/
share
/
tests
/
pecl
/
memcache
/
tests
--TEST-- memcache->addServer() with server failure callback --SKIPIF-- <?php include 'connect.inc'; if (!isset($host2)) die('skip $host2 not set'); ?> --FILE-- <?php include 'connect.inc'; function _callback_server_failure($host, $tcp_port, $udp_port, $error, $errnum) { var_dump($host); var_dump($tcp_port); var_dump($udp_port); var_dump($error); var_dump($errnum); global $memcache; $memcache->setServerParams($host, $tcp_port, 1, -1, false, '_callback_server_failure'); } // Test function callback using addServer() $memcache = new Memcache(); $memcache->addServer($nonExistingHost, $nonExistingPort, false, 1, 1, 15, true, '_callback_server_failure'); $result1 = $memcache->set('test_key', 'test-032-01'); var_dump($result1); class MemcachedFailureHandler { function _callback_server_failure($host, $tcp_port, $udp_port, $error, $errnum) { var_dump($host); var_dump($tcp_port); var_dump($udp_port); var_dump($error); var_dump($errnum); } } // Test OO callback using setServerParams() $memcache = new Memcache(); $memcache->addServer($nonExistingHost, $nonExistingPort, false); $result2 = $memcache->setServerParams($nonExistingHost, $nonExistingPort, 1, 15, true, array(new MemcachedFailureHandler(), '_callback_server_failure')); var_dump($result2); $result3 = $memcache->set('test_key', 'test-032-01'); var_dump($result3); // Test giving non-existing callback to addServer() $memcache = new Memcache(); $result4 = @$memcache->addServer($nonExistingHost, $nonExistingPort, false, 1, 1, 15, true, 'non_existing_user_function'); var_dump($result4); // Test giving non-existing callback to setServerParams() $memcache = new Memcache(); $memcache->addServer($nonExistingHost, $nonExistingPort, false); $result5 = @$memcache->setServerParams($nonExistingHost, $nonExistingPort, 1, 15, true, 'non_existing_user_function'); var_dump($result5); // Test self-referencing callback class MyMemcache extends Memcache { function _callback_server_failure($host, $tcp_port, $udp_port, $error, $errnum) { var_dump($host); } } $memcache = new MyMemcache(); $memcache->addServer($nonExistingHost, $nonExistingPort, false); $result6 = $memcache->setServerParams($nonExistingHost, $nonExistingPort, 1, 15, true, array($memcache, '_callback_server_failure')); $result7 = @$memcache->set('test_key', 'test-032-01'); var_dump($result6); var_dump($result7); // Test resetting callback to null $memcache = new Memcache(); $memcache->addServer($nonExistingHost, $nonExistingPort, false, 1, 1, 15, true, '_callback_server_failure'); $result8 = $memcache->setServerParams($nonExistingHost, $nonExistingPort, 1, 15, true, null); $result9 = @$memcache->set('test_key', 'test-032-01'); var_dump($result8); var_dump($result9); // Test MemcachePool::setFailureCallback() function _callback_server_failure2($host, $tcp_port, $udp_port, $error, $errnum) { var_dump($error); } $memcache = new MemcachePool(); $memcache->addServer($nonExistingHost, $nonExistingPort); $result8 = $memcache->setFailureCallback('_callback_server_failure2'); $result9 = @$memcache->set('test_key', 'test-032-01'); var_dump($result8); var_dump($result9); $result8 = $memcache->setFailureCallback(null); $result9 = @$memcache->set('test_key', 'test-032-01'); var_dump($result8); var_dump($result9); // Test refcount function test_connect() { global $mc, $nonExistingHost, $nonExistingPort; $mc = new Memcache(); $mc->addServer($nonExistingHost, $nonExistingPort, false, 1, 1, 15, true, '_callback_server_failure2'); } test_connect(); $result10 = $mc->set('test_key', 'test-032-02'); var_dump($result10); ?> --EXPECTF-- string(%d) "%s" int(%d) int(%d) string(%d) "Connection %s" int(%d) bool(false) bool(true) string(%d) "%s" int(%d) int(%d) string(%d) "Connection %s" int(%d) bool(false) bool(false) bool(false) string(%d) "%s" bool(true) bool(false) bool(true) bool(false) string(%d) "%s" bool(true) bool(false) bool(true) bool(false) string(%d) "Connection %s" bool(false)
[-] 027a.phpt
[edit]
[-] 022.phpt
[edit]
[-] 013.phpt
[edit]
[-] connect.inc
[edit]
[-] 039.phpt
[edit]
[-] 012.phpt
[edit]
[-] 100a.phpt
[edit]
[+]
..
[-] 003.phpt
[edit]
[-] 058.phpt
[edit]
[-] 048.phpt
[edit]
[-] 038.phpt
[edit]
[-] 019.phpt
[edit]
[-] 021.phpt
[edit]
[-] githubbug13.phpt
[edit]
[-] 100.phpt
[edit]
[-] 042.phpt
[edit]
[-] 008.phpt
[edit]
[-] memcache.sh
[edit]
[-] 025.phpt
[edit]
[-] 046.phpt
[edit]
[-] 043.phpt
[edit]
[-] pecl16536.phpt
[edit]
[-] 002.phpt
[edit]
[-] 019a.phpt
[edit]
[-] 055.phpt
[edit]
[-] 009.phpt
[edit]
[-] 015.phpt
[edit]
[-] 031.phpt
[edit]
[-] pecl17566.phpt
[edit]
[-] 010.phpt
[edit]
[-] 024a.phpt
[edit]
[-] pecl63142.phpt
[edit]
[-] 044.phpt
[edit]
[-] pecl11221.phpt
[edit]
[-] 027.phpt
[edit]
[-] 037.phpt
[edit]
[-] 053.phpt
[edit]
[-] 041.phpt
[edit]
[-] pecl17518.phpt
[edit]
[-] 007.phpt
[edit]
[-] 023.phpt
[edit]
[-] 033.phpt
[edit]
[-] 028.phpt
[edit]
[-] 032.phpt
[edit]
[-] 056.phpt
[edit]
[-] 100b.phpt
[edit]
[-] 029.phpt
[edit]
[-] 017.phpt
[edit]
[-] 052.phpt
[edit]
[-] 054.phpt
[edit]
[-] 040.phpt
[edit]
[-] 036b.phpt
[edit]
[-] bug73539.phpt
[edit]
[-] 057.phpt
[edit]
[-] pecl16442.phpt
[edit]
[-] 051.phpt
[edit]
[-] 014.phpt
[edit]
[-] 030.phpt
[edit]
[-] 004.phpt
[edit]
[-] 026.phpt
[edit]
[-] 005.phpt
[edit]
[-] 049.phpt
[edit]
[-] 022a.phpt
[edit]
[-] 036.phpt
[edit]
[-] 047.phpt
[edit]
[-] 035.phpt
[edit]
[-] 024.phpt
[edit]
[-] 034.phpt
[edit]
[-] 016.phpt
[edit]
[-] 011.phpt
[edit]
[-] 045.phpt
[edit]
[-] 001.phpt
[edit]
[-] 006.phpt
[edit]
[-] 020.phpt
[edit]
[-] 018.phpt
[edit]
[-] 050.phpt
[edit]