File: callback_exception_2.phpt

package info (click to toggle)
php-memcached 3.2.0%2B2.2.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,568 kB
  • sloc: ansic: 9,752; xml: 1,350; php: 478; pascal: 123; sh: 12; makefile: 5
file content (54 lines) | stat: -rw-r--r-- 976 bytes parent folder | download | duplicates (5)
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
--TEST--
Callback initializer throws and dies
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php 

function init_cb($m, $id) {
	echo "ran throwing cb\n";
	var_dump($m->isPersistent());
	throw new RuntimeException('Cb exception');
}

function init_cb_die($m, $id) {
	echo "ran quitting cb\n";
	die("quit in cb");
}

error_reporting(0);

echo "cb with exception\n";
try {
	$m1 = new Memcached(null, 'init_cb');
} catch (RuntimeException $e) {
	echo $e->getMessage(), "\n";
}

echo "cb persistent with exception\n";
try {
	$m2 = new Memcached('foo', 'init_cb');
} catch (RuntimeException $e) {
	echo $e->getMessage(), "\n";
}

echo "cb persistent dies\n";
try {
	$m3 = new Memcached('bar', 'init_cb_die');
} catch (RuntimeException $e) {
	echo $e->getMessage(), "\n";
}
echo "not run\n";

--EXPECT--
cb with exception
ran throwing cb
bool(false)
Cb exception
cb persistent with exception
ran throwing cb
bool(true)
Cb exception
cb persistent dies
ran quitting cb
quit in cb