File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / session / tests / session_encode_error2.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:48:01 2012 UTC (12 years, 4 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, v5_3_10, HEAD
php

    1: --TEST--
    2: Test session_encode() function : error functionality
    3: --SKIPIF--
    4: <?php include('skipif.inc'); ?>
    5: --FILE--
    6: <?php
    7: 
    8: ob_start();
    9: 
   10: /* 
   11:  * Prototype : string session_encode(void)
   12:  * Description : Encodes the current session data as a string
   13:  * Source code : ext/session/session.c 
   14:  */
   15: 
   16: echo "*** Testing session_encode() : error functionality ***\n";
   17: 
   18: // Get an unset variable
   19: $unset_var = 10;
   20: unset($unset_var);
   21: 
   22: class classA
   23: {
   24:     public function __toString() {
   25:         return "Hello World!";
   26:     }
   27: }
   28: 
   29: $heredoc = <<<EOT
   30: Hello World!
   31: EOT;
   32: 
   33: $fp = fopen(__FILE__, "r");
   34: 
   35: // Unexpected values to be passed as arguments
   36: $inputs = array(
   37: 
   38:        // Integer data
   39: /*1*/  0,
   40:        1,
   41:        12345,
   42:        -2345,
   43: 
   44:        // Float data
   45: /*5*/  10.5,
   46:        -10.5,
   47:        12.3456789000e10,
   48:        12.3456789000E-10,
   49:        .5,
   50: 
   51:        // Null data
   52: /*10*/ NULL,
   53:        null,
   54: 
   55:        // Boolean data
   56: /*12*/ true,
   57:        false,
   58:        TRUE,
   59:        FALSE,
   60:        
   61:        // Empty strings
   62: /*16*/ "",
   63:        '',
   64: 
   65:        // Invalid string data
   66: /*18*/ "Nothing",
   67:        'Nothing',
   68:        $heredoc,
   69:        
   70:        // Object data
   71: /*21*/ new classA(),
   72: 
   73:        // Undefined data
   74: /*22*/ @$undefined_var,
   75: 
   76:        // Unset data
   77: /*23*/ @$unset_var,
   78: 
   79:        // Resource variable
   80: /*24*/ $fp
   81: );
   82: 
   83: $iterator = 1;
   84: foreach($inputs as $input) {
   85:     echo "\n-- Iteration $iterator --\n";
   86:     var_dump(session_start());
   87:     $_SESSION[$input] = "Hello World!";
   88:     var_dump(session_encode());
   89:     var_dump(session_destroy());
   90:     $iterator++;
   91: };
   92: 
   93: fclose($fp);
   94: echo "Done";
   95: ob_end_flush();
   96: ?>
   97: --EXPECTF--
   98: *** Testing session_encode() : error functionality ***
   99: 
  100: -- Iteration 1 --
  101: bool(true)
  102: 
  103: Notice: session_encode(): Skipping numeric key 0 in %s on line %d
  104: bool(false)
  105: bool(true)
  106: 
  107: -- Iteration 2 --
  108: bool(true)
  109: 
  110: Notice: session_encode(): Skipping numeric key 1 in %s on line %d
  111: bool(false)
  112: bool(true)
  113: 
  114: -- Iteration 3 --
  115: bool(true)
  116: 
  117: Notice: session_encode(): Skipping numeric key 12345 in %s on line %d
  118: bool(false)
  119: bool(true)
  120: 
  121: -- Iteration 4 --
  122: bool(true)
  123: 
  124: Notice: session_encode(): Skipping numeric key -2345 in %s on line %d
  125: bool(false)
  126: bool(true)
  127: 
  128: -- Iteration 5 --
  129: bool(true)
  130: 
  131: Notice: session_encode(): Skipping numeric key 10 in %s on line %d
  132: bool(false)
  133: bool(true)
  134: 
  135: -- Iteration 6 --
  136: bool(true)
  137: 
  138: Notice: session_encode(): Skipping numeric key -10 in %s on line %d
  139: bool(false)
  140: bool(true)
  141: 
  142: -- Iteration 7 --
  143: bool(true)
  144: 
  145: Notice: session_encode(): Skipping numeric key %s in %s on line %d
  146: bool(false)
  147: bool(true)
  148: 
  149: -- Iteration 8 --
  150: bool(true)
  151: 
  152: Notice: session_encode(): Skipping numeric key 0 in %s on line %d
  153: bool(false)
  154: bool(true)
  155: 
  156: -- Iteration 9 --
  157: bool(true)
  158: 
  159: Notice: session_encode(): Skipping numeric key 0 in %s on line %d
  160: bool(false)
  161: bool(true)
  162: 
  163: -- Iteration 10 --
  164: bool(true)
  165: string(21) "|s:12:"Hello World!";"
  166: bool(true)
  167: 
  168: -- Iteration 11 --
  169: bool(true)
  170: string(21) "|s:12:"Hello World!";"
  171: bool(true)
  172: 
  173: -- Iteration 12 --
  174: bool(true)
  175: 
  176: Notice: session_encode(): Skipping numeric key 1 in %s on line %d
  177: bool(false)
  178: bool(true)
  179: 
  180: -- Iteration 13 --
  181: bool(true)
  182: 
  183: Notice: session_encode(): Skipping numeric key 0 in %s on line %d
  184: bool(false)
  185: bool(true)
  186: 
  187: -- Iteration 14 --
  188: bool(true)
  189: 
  190: Notice: session_encode(): Skipping numeric key 1 in %s on line %d
  191: bool(false)
  192: bool(true)
  193: 
  194: -- Iteration 15 --
  195: bool(true)
  196: 
  197: Notice: session_encode(): Skipping numeric key 0 in %s on line %d
  198: bool(false)
  199: bool(true)
  200: 
  201: -- Iteration 16 --
  202: bool(true)
  203: string(21) "|s:12:"Hello World!";"
  204: bool(true)
  205: 
  206: -- Iteration 17 --
  207: bool(true)
  208: string(21) "|s:12:"Hello World!";"
  209: bool(true)
  210: 
  211: -- Iteration 18 --
  212: bool(true)
  213: string(28) "Nothing|s:12:"Hello World!";"
  214: bool(true)
  215: 
  216: -- Iteration 19 --
  217: bool(true)
  218: string(28) "Nothing|s:12:"Hello World!";"
  219: bool(true)
  220: 
  221: -- Iteration 20 --
  222: bool(true)
  223: bool(false)
  224: bool(true)
  225: 
  226: -- Iteration 21 --
  227: bool(true)
  228: 
  229: Warning: Illegal offset type in %s on line 82
  230: bool(false)
  231: bool(true)
  232: 
  233: -- Iteration 22 --
  234: bool(true)
  235: string(21) "|s:12:"Hello World!";"
  236: bool(true)
  237: 
  238: -- Iteration 23 --
  239: bool(true)
  240: string(21) "|s:12:"Hello World!";"
  241: bool(true)
  242: 
  243: -- Iteration 24 --
  244: bool(true)
  245: 
  246: Strict Standards: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
  247: 
  248: Notice: session_encode(): Skipping numeric key %d in %s on line %d
  249: bool(false)
  250: bool(true)
  251: Done

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