xref: /PHP-7.3/ext/imap/tests/bug80215.phpt (revision 62a2387a)
1--TEST--
2Bug #80215 (imap_mail_compose() may modify by-val parameters)
3--SKIPIF--
4<?php
5if (!extension_loaded('imap')) die('skip imap extension not available');
6?>
7--FILE--
8<?php
9$envelope = [
10    "from" => 1,
11    "to" => 2,
12    "custom_headers" => [3],
13];
14$body = [[
15    "contents.data" => 4,
16    "type.parameters" => ['foo' => 5],
17    "disposition" => ['bar' => 6],
18], [
19    "contents.data" => 7,
20    "type.parameters" => ['foo' => 8],
21    "disposition" => ['bar' => 9],
22]];
23imap_mail_compose($envelope, $body);
24var_dump($envelope, $body);
25?>
26--EXPECT--
27array(3) {
28  ["from"]=>
29  int(1)
30  ["to"]=>
31  int(2)
32  ["custom_headers"]=>
33  array(1) {
34    [0]=>
35    int(3)
36  }
37}
38array(2) {
39  [0]=>
40  array(3) {
41    ["contents.data"]=>
42    int(4)
43    ["type.parameters"]=>
44    array(1) {
45      ["foo"]=>
46      int(5)
47    }
48    ["disposition"]=>
49    array(1) {
50      ["bar"]=>
51      int(6)
52    }
53  }
54  [1]=>
55  array(3) {
56    ["contents.data"]=>
57    int(7)
58    ["type.parameters"]=>
59    array(1) {
60      ["foo"]=>
61      int(8)
62    }
63    ["disposition"]=>
64    array(1) {
65      ["bar"]=>
66      int(9)
67    }
68  }
69}
70