Annotation of embedaddon/php/ext/session/tests/session_save_path_error.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test session_save_path() function : error functionality
! 3: --INI--
! 4: session.gc_probability=0
! 5: session.save_path=
! 6: session.name=PHPSESSID
! 7: --SKIPIF--
! 8: <?php include('skipif.inc'); ?>
! 9: --FILE--
! 10: <?php
! 11:
! 12: ob_start();
! 13:
! 14: /*
! 15: * Prototype : string session_save_path([string $path])
! 16: * Description : Get and/or set the current session save path
! 17: * Source code : ext/session/session.c
! 18: */
! 19:
! 20: echo "*** Testing session_save_path() : error functionality ***\n";
! 21:
! 22: // Get an unset variable
! 23: $unset_var = 10;
! 24: unset($unset_var);
! 25:
! 26: class classA
! 27: {
! 28: public function __toString() {
! 29: return "Hello World!";
! 30: }
! 31: }
! 32:
! 33: $heredoc = <<<EOT
! 34: Hello World!
! 35: EOT;
! 36:
! 37: $fp = fopen(__FILE__, "r");
! 38:
! 39: // Unexpected values to be passed as arguments
! 40: $inputs = array(
! 41:
! 42: // Integer data
! 43: /*1*/ 0,
! 44: 1,
! 45: 12345,
! 46: -2345,
! 47:
! 48: // Float data
! 49: /*5*/ 10.5,
! 50: -10.5,
! 51: 12.3456789000e10,
! 52: 12.3456789000E-10,
! 53: .5,
! 54:
! 55: // Null data
! 56: /*10*/ NULL,
! 57: null,
! 58:
! 59: // Boolean data
! 60: /*12*/ true,
! 61: false,
! 62: TRUE,
! 63: FALSE,
! 64:
! 65: // Empty strings
! 66: /*16*/ "",
! 67: '',
! 68:
! 69: // Invalid string data
! 70: /*18*/ "Nothing",
! 71: 'Nothing',
! 72: $heredoc,
! 73:
! 74: // Object data
! 75: /*21*/ new classA(),
! 76:
! 77: // Undefined data
! 78: /*22*/ @$undefined_var,
! 79:
! 80: // Unset data
! 81: /*23*/ @$unset_var,
! 82:
! 83: // Resource variable
! 84: /*24*/ $fp
! 85: );
! 86:
! 87: session_start();
! 88:
! 89: $iterator = 1;
! 90: foreach($inputs as $input) {
! 91: echo "\n-- Iteration $iterator --\n";
! 92: var_dump(session_save_path($input));
! 93: $iterator++;
! 94: };
! 95:
! 96: session_destroy();
! 97: fclose($fp);
! 98: echo "Done";
! 99: ob_end_flush();
! 100: ?>
! 101: --EXPECTF--
! 102: *** Testing session_save_path() : error functionality ***
! 103:
! 104: -- Iteration 1 --
! 105: string(0) ""
! 106:
! 107: -- Iteration 2 --
! 108: string(1) "0"
! 109:
! 110: -- Iteration 3 --
! 111: string(1) "1"
! 112:
! 113: -- Iteration 4 --
! 114: string(5) "12345"
! 115:
! 116: -- Iteration 5 --
! 117: string(5) "-2345"
! 118:
! 119: -- Iteration 6 --
! 120: string(4) "10.5"
! 121:
! 122: -- Iteration 7 --
! 123: string(5) "-10.5"
! 124:
! 125: -- Iteration 8 --
! 126: string(12) "123456789000"
! 127:
! 128: -- Iteration 9 --
! 129: string(13) "1.23456789E-9"
! 130:
! 131: -- Iteration 10 --
! 132: string(3) "0.5"
! 133:
! 134: -- Iteration 11 --
! 135: string(0) ""
! 136:
! 137: -- Iteration 12 --
! 138: string(0) ""
! 139:
! 140: -- Iteration 13 --
! 141: string(1) "1"
! 142:
! 143: -- Iteration 14 --
! 144: string(0) ""
! 145:
! 146: -- Iteration 15 --
! 147: string(1) "1"
! 148:
! 149: -- Iteration 16 --
! 150: string(0) ""
! 151:
! 152: -- Iteration 17 --
! 153: string(0) ""
! 154:
! 155: -- Iteration 18 --
! 156: string(0) ""
! 157:
! 158: -- Iteration 19 --
! 159: string(7) "Nothing"
! 160:
! 161: -- Iteration 20 --
! 162: string(7) "Nothing"
! 163:
! 164: -- Iteration 21 --
! 165: string(12) "Hello World!"
! 166:
! 167: -- Iteration 22 --
! 168: string(12) "Hello World!"
! 169:
! 170: -- Iteration 23 --
! 171: string(0) ""
! 172:
! 173: -- Iteration 24 --
! 174:
! 175: Warning: session_save_path() expects parameter 1 to be string, resource given in %s on line %d
! 176: NULL
! 177: Done
! 178:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>