-
Notifications
You must be signed in to change notification settings - Fork 175
/
onLog.phpt
51 lines (47 loc) · 1.06 KB
/
onLog.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
48
49
50
51
--TEST--
Mosquitto\Client::onLog()
--SKIPIF--
if (!extension_loaded('mosquitto')) die('skip - Mosquitto extension not available');
--FILE--
<?php
include(dirname(__DIR__) . '/setup.php');
function logger() {
var_dump(func_get_args());
}
try {
$client = new Mosquitto\Client;
$client->onLog('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());
}
$client = new Mosquitto\Client;
$client->onLog('logger');
var_dump($client);
$client->connect(TEST_MQTT_HOST);
$client->loop(50);
$client->loop(50);
?>
--EXPECTF--
%ACaught TypeError with code 0 and message: %s
object(Mosquitto\Client)#%d (%d) {
}
array(2) {
[0]=>
int(16)
[1]=>
string(%d) "Client %s sending CONNECT"
}
array(2) {
[0]=>
int(16)
[1]=>
string(%d) "Client %s received CONNACK"
}
array(2) {
[0]=>
int(16)
[1]=>
string(%d) "Client %s sending DISCONNECT"
}