Annotation of embedaddon/php/ext/session/tests/session_name_error.phpt, revision 1.1.1.2

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";
1.1.1.2 ! misho      89:     var_dump($input, session_name($input));
1.1       misho      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 --
1.1.1.2 ! misho     101: 
        !           102: Warning: session_name(): session.name cannot be a numeric or empty '0' in %s on line %d
        !           103: int(0)
1.1       misho     104: string(9) "PHPSESSID"
                    105: 
                    106: -- Iteration 2 --
1.1.1.2 ! misho     107: 
        !           108: Warning: session_name(): session.name cannot be a numeric or empty '1' in %s on line %d
        !           109: int(1)
        !           110: string(9) "PHPSESSID"
1.1       misho     111: 
                    112: -- Iteration 3 --
1.1.1.2 ! misho     113: 
        !           114: Warning: session_name(): session.name cannot be a numeric or empty '12345' in %s on line %d
        !           115: int(12345)
        !           116: string(9) "PHPSESSID"
1.1       misho     117: 
                    118: -- Iteration 4 --
1.1.1.2 ! misho     119: 
        !           120: Warning: session_name(): session.name cannot be a numeric or empty '-2345' in %s on line %d
        !           121: int(-2345)
        !           122: string(9) "PHPSESSID"
1.1       misho     123: 
                    124: -- Iteration 5 --
1.1.1.2 ! misho     125: 
        !           126: Warning: session_name(): session.name cannot be a numeric or empty '10.5' in %s on line %d
        !           127: float(10.5)
        !           128: string(9) "PHPSESSID"
1.1       misho     129: 
                    130: -- Iteration 6 --
1.1.1.2 ! misho     131: 
        !           132: Warning: session_name(): session.name cannot be a numeric or empty '-10.5' in %s on line %d
        !           133: float(-10.5)
        !           134: string(9) "PHPSESSID"
1.1       misho     135: 
                    136: -- Iteration 7 --
1.1.1.2 ! misho     137: 
        !           138: Warning: session_name(): session.name cannot be a numeric or empty '123456789000' in %s on line %d
        !           139: float(123456789000)
        !           140: string(9) "PHPSESSID"
1.1       misho     141: 
                    142: -- Iteration 8 --
1.1.1.2 ! misho     143: 
        !           144: Warning: session_name(): session.name cannot be a numeric or empty '1.23456789E-9' in %s on line %d
        !           145: float(1.23456789E-9)
        !           146: string(9) "PHPSESSID"
1.1       misho     147: 
                    148: -- Iteration 9 --
1.1.1.2 ! misho     149: 
        !           150: Warning: session_name(): session.name cannot be a numeric or empty '0.5' in %s on line %d
        !           151: float(0.5)
        !           152: string(9) "PHPSESSID"
1.1       misho     153: 
                    154: -- Iteration 10 --
1.1.1.2 ! misho     155: 
        !           156: Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
        !           157: NULL
        !           158: string(9) "PHPSESSID"
1.1       misho     159: 
                    160: -- Iteration 11 --
1.1.1.2 ! misho     161: 
        !           162: Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
        !           163: NULL
        !           164: string(9) "PHPSESSID"
1.1       misho     165: 
                    166: -- Iteration 12 --
1.1.1.2 ! misho     167: 
        !           168: Warning: session_name(): session.name cannot be a numeric or empty '1' in %s on line %d
        !           169: bool(true)
        !           170: string(9) "PHPSESSID"
1.1       misho     171: 
                    172: -- Iteration 13 --
1.1.1.2 ! misho     173: 
        !           174: Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
        !           175: bool(false)
        !           176: string(9) "PHPSESSID"
1.1       misho     177: 
                    178: -- Iteration 14 --
1.1.1.2 ! misho     179: 
        !           180: Warning: session_name(): session.name cannot be a numeric or empty '1' in %s on line %d
        !           181: bool(true)
        !           182: string(9) "PHPSESSID"
1.1       misho     183: 
                    184: -- Iteration 15 --
1.1.1.2 ! misho     185: 
        !           186: Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
        !           187: bool(false)
        !           188: string(9) "PHPSESSID"
1.1       misho     189: 
                    190: -- Iteration 16 --
1.1.1.2 ! misho     191: 
        !           192: Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
1.1       misho     193: string(0) ""
1.1.1.2 ! misho     194: string(9) "PHPSESSID"
1.1       misho     195: 
                    196: -- Iteration 17 --
1.1.1.2 ! misho     197: 
        !           198: Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
1.1       misho     199: string(0) ""
1.1.1.2 ! misho     200: string(9) "PHPSESSID"
1.1       misho     201: 
                    202: -- Iteration 18 --
1.1.1.2 ! misho     203: string(7) "Nothing"
        !           204: string(9) "PHPSESSID"
1.1       misho     205: 
                    206: -- Iteration 19 --
                    207: string(7) "Nothing"
1.1.1.2 ! misho     208: string(7) "Nothing"
1.1       misho     209: 
                    210: -- Iteration 20 --
1.1.1.2 ! misho     211: string(12) "Hello World!"
1.1       misho     212: string(7) "Nothing"
                    213: 
                    214: -- Iteration 21 --
1.1.1.2 ! misho     215: object(classA)#1 (0) {
        !           216: }
1.1       misho     217: string(12) "Hello World!"
                    218: 
                    219: -- Iteration 22 --
1.1.1.2 ! misho     220: 
        !           221: Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
        !           222: NULL
1.1       misho     223: string(12) "Hello World!"
                    224: 
                    225: -- Iteration 23 --
1.1.1.2 ! misho     226: 
        !           227: Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
        !           228: NULL
        !           229: string(12) "Hello World!"
1.1       misho     230: 
                    231: -- Iteration 24 --
                    232: 
                    233: Warning: session_name() expects parameter 1 to be string, resource given in %s on line %d
1.1.1.2 ! misho     234: resource(5) of type (stream)
1.1       misho     235: NULL
1.1.1.2 ! misho     236: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>