session_encode_error.phpt 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. --TEST--
  2. Test session_encode() function : basic functionality
  3. --SKIPIF--
  4. <?php include('skipif.inc'); ?>
  5. --FILE--
  6. <?php
  7. ob_start();
  8. /*
  9. * Prototype : string session_encode(void)
  10. * Description : Encodes the current session data as a string
  11. * Source code : ext/session/session.c
  12. */
  13. echo "*** Testing session_encode() : basic functionality ***\n";
  14. // Get an unset variable
  15. $unset_var = 10;
  16. unset($unset_var);
  17. class classA
  18. {
  19. public function __toString() {
  20. return "Hello World!";
  21. }
  22. }
  23. $heredoc = <<<EOT
  24. Hello World!
  25. EOT;
  26. $fp = fopen(__FILE__, "r");
  27. // Unexpected values to be passed as arguments
  28. $inputs = array(
  29. // Integer data
  30. /*1*/ 0,
  31. 1,
  32. 12345,
  33. -2345,
  34. // Float data
  35. /*5*/ 10.5,
  36. -10.5,
  37. 12.3456789000e10,
  38. 12.3456789000E-10,
  39. .5,
  40. // Null data
  41. /*10*/ NULL,
  42. null,
  43. // Boolean data
  44. /*12*/ true,
  45. false,
  46. TRUE,
  47. FALSE,
  48. // Empty strings
  49. /*16*/ "",
  50. '',
  51. // Invalid string data
  52. /*18*/ "Nothing",
  53. 'Nothing',
  54. $heredoc,
  55. // Object data
  56. /*21*/ new classA(),
  57. // Undefined data
  58. /*22*/ @$undefined_var,
  59. // Unset data
  60. /*23*/ @$unset_var,
  61. // Resource variable
  62. /*24*/ $fp
  63. );
  64. session_start();
  65. $iterator = 1;
  66. foreach($inputs as $input) {
  67. echo "\n-- Iteration $iterator --\n";
  68. var_dump(session_encode($input));
  69. $iterator++;
  70. };
  71. session_destroy();
  72. fclose($fp);
  73. echo "Done";
  74. ob_end_flush();
  75. ?>
  76. --EXPECTF--
  77. *** Testing session_encode() : basic functionality ***
  78. -- Iteration 1 --
  79. Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d
  80. NULL
  81. -- Iteration 2 --
  82. Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d
  83. NULL
  84. -- Iteration 3 --
  85. Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d
  86. NULL
  87. -- Iteration 4 --
  88. Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d
  89. NULL
  90. -- Iteration 5 --
  91. Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d
  92. NULL
  93. -- Iteration 6 --
  94. Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d
  95. NULL
  96. -- Iteration 7 --
  97. Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d
  98. NULL
  99. -- Iteration 8 --
  100. Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d
  101. NULL
  102. -- Iteration 9 --
  103. Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d
  104. NULL
  105. -- Iteration 10 --
  106. Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d
  107. NULL
  108. -- Iteration 11 --
  109. Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d
  110. NULL
  111. -- Iteration 12 --
  112. Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d
  113. NULL
  114. -- Iteration 13 --
  115. Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d
  116. NULL
  117. -- Iteration 14 --
  118. Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d
  119. NULL
  120. -- Iteration 15 --
  121. Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d
  122. NULL
  123. -- Iteration 16 --
  124. Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d
  125. NULL
  126. -- Iteration 17 --
  127. Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d
  128. NULL
  129. -- Iteration 18 --
  130. Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d
  131. NULL
  132. -- Iteration 19 --
  133. Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d
  134. NULL
  135. -- Iteration 20 --
  136. Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d
  137. NULL
  138. -- Iteration 21 --
  139. Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d
  140. NULL
  141. -- Iteration 22 --
  142. Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d
  143. NULL
  144. -- Iteration 23 --
  145. Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d
  146. NULL
  147. -- Iteration 24 --
  148. Warning: session_encode() expects exactly 0 parameters, 1 given in %s on line %d
  149. NULL
  150. Done