shuffle_variation5.phpt 2.6 KB

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