session_start_error.phpt 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. --TEST--
  2. Test session_start() function : error functionality
  3. --SKIPIF--
  4. <?php include('skipif.inc'); ?>
  5. --FILE--
  6. <?php
  7. ob_start();
  8. /*
  9. * Prototype : bool session_start(void)
  10. * Description : Initialize session data
  11. * Source code : ext/session/session.c
  12. */
  13. echo "*** Testing session_start() : error 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. $iterator = 1;
  65. foreach($inputs as $input) {
  66. echo "\n-- Iteration $iterator --\n";
  67. var_dump(session_start($input));
  68. var_dump(session_destroy());
  69. $iterator++;
  70. };
  71. fclose($fp);
  72. echo "Done";
  73. ob_end_flush();
  74. ?>
  75. --EXPECTF--
  76. *** Testing session_start() : error functionality ***
  77. -- Iteration 1 --
  78. bool(true)
  79. bool(true)
  80. -- Iteration 2 --
  81. bool(true)
  82. bool(true)
  83. -- Iteration 3 --
  84. bool(true)
  85. bool(true)
  86. -- Iteration 4 --
  87. bool(true)
  88. bool(true)
  89. -- Iteration 5 --
  90. bool(true)
  91. bool(true)
  92. -- Iteration 6 --
  93. bool(true)
  94. bool(true)
  95. -- Iteration 7 --
  96. bool(true)
  97. bool(true)
  98. -- Iteration 8 --
  99. bool(true)
  100. bool(true)
  101. -- Iteration 9 --
  102. bool(true)
  103. bool(true)
  104. -- Iteration 10 --
  105. bool(true)
  106. bool(true)
  107. -- Iteration 11 --
  108. bool(true)
  109. bool(true)
  110. -- Iteration 12 --
  111. bool(true)
  112. bool(true)
  113. -- Iteration 13 --
  114. bool(true)
  115. bool(true)
  116. -- Iteration 14 --
  117. bool(true)
  118. bool(true)
  119. -- Iteration 15 --
  120. bool(true)
  121. bool(true)
  122. -- Iteration 16 --
  123. bool(true)
  124. bool(true)
  125. -- Iteration 17 --
  126. bool(true)
  127. bool(true)
  128. -- Iteration 18 --
  129. bool(true)
  130. bool(true)
  131. -- Iteration 19 --
  132. bool(true)
  133. bool(true)
  134. -- Iteration 20 --
  135. bool(true)
  136. bool(true)
  137. -- Iteration 21 --
  138. bool(true)
  139. bool(true)
  140. -- Iteration 22 --
  141. bool(true)
  142. bool(true)
  143. -- Iteration 23 --
  144. bool(true)
  145. bool(true)
  146. -- Iteration 24 --
  147. bool(true)
  148. bool(true)
  149. Done