xref: /PHP-5.5/ext/sysvmsg/tests/005.phpt (revision 3be50a26)
1--TEST--
2sysvmsg functions on non-existing queue
3--SKIPIF--
4<?php if (!extension_loaded("sysvmsg")) die("skip sysvmsg extension is not available")?>
5--FILE--
6<?php
7
8$tests = array(null, 'foo');
9
10foreach ($tests as $q) {
11
12    if ($q === null) {
13	do {
14	    $id = ftok(__FILE__, chr(mt_rand(0, 255)));
15	} while (msg_queue_exists($id));
16
17	$q = msg_get_queue($id) or die("Failed to create queue");
18	msg_remove_queue($q) or die("Failed to close queue");
19    }
20
21    echo "Using '$q' as queue resource:\n";
22
23    $errno = 0;
24
25    var_dump(msg_set_queue($q, array('msg_qbytes' => 1)));
26
27    var_dump(msg_stat_queue($q));
28
29    var_dump(msg_receive($q, 0, $null, 1, $msg, true, 0, $errno));
30    var_dump($errno != 0);
31    // again, but triggering an E_WARNING
32    var_dump(msg_receive($q, 0, $null, 0, $msg));
33
34    var_dump(msg_send($q, 1, 'foo', true, true, $errno));
35    var_dump($errno != 0);
36}
37
38echo "Done\n";
39?>
40--EXPECTF--
41Using 'Resource id #4' as queue resource:
42bool(false)
43bool(false)
44bool(false)
45bool(true)
46
47Warning: msg_receive(): maximum size of the message has to be greater than zero in %s on line %d
48bool(false)
49
50Warning: msg_send(): msgsnd failed: Invalid argument in %s on line %d
51bool(false)
52bool(true)
53Using 'foo' as queue resource:
54
55Warning: msg_set_queue() expects parameter 1 to be resource, string given in %s on line %d
56bool(false)
57
58Warning: msg_stat_queue() expects parameter 1 to be resource, string given in %s on line %d
59bool(false)
60
61Warning: msg_receive() expects parameter 1 to be resource, string given in %s on line %d
62bool(false)
63bool(false)
64
65Warning: msg_receive() expects parameter 1 to be resource, string given in %s on line %d
66bool(false)
67
68Warning: msg_send() expects parameter 1 to be resource, string given in %s on line %d
69bool(false)
70bool(false)
71Done
72