File: callback_exception.phpt

package info (click to toggle)
php-memcached 3.1.5%2B2.2.0-5%2Bdeb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,952 kB
  • sloc: ansic: 9,587; xml: 1,318; php: 385; pascal: 87; sh: 12; makefile: 5
file content (54 lines) | stat: -rw-r--r-- 903 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--
make sure that callback exception behaves correctly
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php

function throw_something(Memcached $object, $p_id = null)
{
    throw new Exception("from cb");
}

function empty_cb(Memcached $object, $p_id = null)
{
    echo "empty_cb called\n";
}

try {
    $m = new Memcached('test_id', 'throw_something');
    echo "fail\n";
} catch (Exception $e) {
    echo "success\n";
}

try {
    $m = new Memcached('test_id', 'throw_something');
    echo "fail\n";
} catch (Exception $e) {
    echo "success\n";
}

try {
    $m = new Memcached('test_id', 'empty_cb');
    $m = new Memcached('test_id', 'empty_cb');
} catch (Exception $e) {
    echo "fail\n";
}

try {
    $m = new Memcached(null, 'throw_something');
    echo "fail\n";
} catch (Exception $e) {
    echo "success\n";
}

echo "OK\n";

?>
--EXPECT--
success
success
empty_cb called
success
OK