xref: /PHP-8.2/ext/sysvmsg/tests/006.phpt (revision 7f2f0c00)
1--TEST--
2msg_send() data types when not serializing
3--EXTENSIONS--
4sysvmsg
5--FILE--
6<?php
7
8$queue = msg_get_queue (ftok(__FILE__, 'r'), 0600);
9
10$tests = array('foo', 123, PHP_INT_MAX +1, true, 1.01, null, array('bar'));
11
12foreach ($tests as $elem) {
13    echo @"Sending/receiving '$elem':\n";
14    try {
15        var_dump(msg_send($queue, 1, $elem, false));
16    } catch (TypeError $exception) {
17        echo $exception->getMessage() . "\n";
18    }
19
20    unset($msg);
21    var_dump(msg_receive($queue, 1, $msg_type, 1024, $msg, false, MSG_IPC_NOWAIT));
22
23    var_dump($elem == $msg);
24    var_dump($elem === $msg);
25}
26
27if (!msg_remove_queue($queue)) {
28    echo "BAD: queue removal failed\n";
29}
30
31echo "Done\n";
32?>
33--EXPECTF--
34Sending/receiving 'foo':
35bool(true)
36bool(true)
37bool(true)
38bool(true)
39Sending/receiving '123':
40bool(true)
41bool(true)
42bool(true)
43bool(false)
44Sending/receiving '%s':
45bool(true)
46bool(true)
47bool(true)
48bool(false)
49Sending/receiving '1':
50bool(true)
51bool(true)
52bool(true)
53bool(false)
54Sending/receiving '1.01':
55bool(true)
56bool(true)
57bool(true)
58bool(false)
59Sending/receiving '':
60msg_send(): Argument #3 ($message) must be of type string|int|float|bool, null given
61bool(false)
62bool(true)
63bool(false)
64Sending/receiving 'Array':
65msg_send(): Argument #3 ($message) must be of type string|int|float|bool, array given
66bool(false)
67bool(false)
68bool(false)
69Done
70