1--TEST--
2Test shuffle() function : usage variation - arrays with diff heredoc strings
3--FILE--
4<?php
5/*
6* Test behaviour of shuffle() when an array of heredoc strings is passed to
7* 'array_arg' argument of the function
8*/
9
10echo "*** Testing shuffle() : with array containing heredoc strings ***\n";
11
12// defining different heredoc strings
13$empty_heredoc = <<<EOT
14EOT;
15
16$heredoc_with_newline = <<<EOT
17\n
18EOT;
19
20$heredoc_with_characters = <<<EOT
21first line of heredoc string
22second line of heredoc string
23third line of heredocstring
24EOT;
25
26$heredoc_with_newline_and_tabs = <<<EOT
27hello\tworld\nhello\nworld\n
28EOT;
29
30$heredoc_with_alphanumerics = <<<EOT
31hello123world456
321234hello\t1234
33EOT;
34
35$heredoc_with_embedded_nulls = <<<EOT
36hello\0world\0hello
37\0hello\0
38EOT;
39
40// defining array with values as heredoc strings
41$heredoc_array = array(
42  $empty_heredoc,
43  $heredoc_with_newline,
44  $heredoc_with_characters,
45  $heredoc_with_newline_and_tabs,
46  $heredoc_with_alphanumerics,
47  $heredoc_with_embedded_nulls
48);
49
50// defining array with keys as heredoc strings
51$heredoc_asso_array = array(
52  $empty_heredoc => "heredoc1",
53  $heredoc_with_newline => "heredoc2",
54  $heredoc_with_characters => "heredoc3",
55  $heredoc_with_newline_and_tabs => "heredoc3",
56  $heredoc_with_alphanumerics => "heredoc4",
57  $heredoc_with_embedded_nulls => "heredoc5"
58);
59
60// test shuffle() with array containing heredoc strings as values
61echo "\n-- with array of heredoc strings --\n";
62var_dump( shuffle($heredoc_array) );
63echo "\nThe output array is:\n";
64var_dump( $heredoc_array );
65
66// test shuffle() with array containing heredoc strings as its keys
67echo "\n-- with array having heredoc strings as keys --\n";
68var_dump( shuffle($heredoc_asso_array) );
69echo "\nThe output array is:\n";
70var_dump( $heredoc_asso_array );
71
72echo "Done";
73?>
74--EXPECTREGEX--
75\*\*\* Testing shuffle\(\) : with array containing heredoc strings \*\*\*
76
77-- with array of heredoc strings --
78bool\(true\)
79
80The output array is:
81array\(6\) {
82  \[0\]=>
83  string\([0-9]*\) "[0-9 a-z \n \0 \t]*"
84  \[1\]=>
85  string\([0-9]*\) "[0-9 a-z \n \0 \t]*"
86  \[2\]=>
87  string\([0-9]*\) "[0-9 a-z \n \0 \t]*"
88  \[3\]=>
89  string\([0-9]*\) "[0-9 a-z \n \0 \t]*"
90  \[4\]=>
91  string\([0-9]*\) "[0-9 a-z \n \0 \t]*"
92  \[5\]=>
93  string\([0-9]*\) "[0-9 a-z \n \0 \t]*"
94}
95
96-- with array having heredoc strings as keys --
97bool\(true\)
98
99The output array is:
100array\(6\) {
101  \[0\]=>
102  string\(8\) "[heredoc 1-5]*"
103  \[1\]=>
104  string\(8\) "[heredoc 1-5]*"
105  \[2\]=>
106  string\(8\) "[heredoc 1-5]*"
107  \[3\]=>
108  string\(8\) "[heredoc 1-5]*"
109  \[4\]=>
110  string\(8\) "[heredoc 1-5]*"
111  \[5\]=>
112  string\(8\) "[heredoc 1-5]*"
113}
114Done
115