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