-
Notifications
You must be signed in to change notification settings - Fork 147
/
onUnsubscribe.phpt
47 lines (40 loc) · 1.04 KB
/
onUnsubscribe.phpt
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
--TEST--
Mosquitto\Client::onUnsubscribe()
--SKIPIF--
if (!extension_loaded('mosquitto')) die('skip - Mosquitto extension not available');
--FILE--
<?php
include(dirname(__DIR__) . '/setup.php');
try {
$client = new Mosquitto\Client;
$client->onUnsubscribe('foo');
} catch (TypeError $e) {
printf("Caught %s with code %d and message: %s\n", get_class($e), $e->getCode(), $e->getMessage());
} catch (Mosquitto\Exception $e) {
printf("Caught TypeError with code %d and message: %s\n", get_class($e), $e->getCode(), $e->getMessage());
}
unset($client);
$client = new Mosquitto\Client;
$client->onUnsubscribe(function() use ($client) {
$client->disconnect();
});
$client->onConnect(function() use ($client) {
$client->subscribe('#', 0);
});
$client->onSubscribe(function() use ($client) {
var_dump(func_get_args());
$client->unsubscribe('#');
});
$client->connect(TEST_MQTT_HOST);
$client->loopForever();
?>
--EXPECTF--
%ACaught TypeError with code 0 and message: %s
array(3) {
[0]=>
int(1)
[1]=>
int(1)
[2]=>
int(0)
}