Annotation of embedaddon/php/ext/standard/tests/url/base64_decode_variation_002.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test base64_decode() function : usage variations   - unexpected types for arg 2
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : proto string base64_decode(string str[, bool strict])
                      6:  * Description: Decodes string using MIME base64 algorithm 
                      7:  * Source code: ext/standard/base64.c
                      8:  * Alias to functions: 
                      9:  */
                     10: 
                     11: function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
                     12:        echo "Error: $err_no - $err_msg, $filename($linenum)\n";
                     13: }
                     14: set_error_handler('test_error_handler');
                     15: 
                     16: echo "*** Testing base64_decode() : usage variations ***\n";
                     17: 
                     18: // Initialise function arguments not being substituted (if any)
                     19: $str = 'aGVsbG8gd29ybGQh!';
                     20: 
                     21: //getting the resource
                     22: $file_handle = fopen(__FILE__, "r");
                     23: 
                     24: //get an unset variable
                     25: $unset_var = 10;
                     26: unset ($unset_var);
                     27: 
                     28: //array of values to iterate over
                     29: $values =  array (
                     30:        // int data
                     31:        "0" =>  0,
                     32:        "1" =>  1,
                     33:        "12345" =>  12345,
                     34:        "-2345" =>  -2345,
                     35:                
                     36:        // float data
                     37:     "10.5" =>  10.5,
                     38:        "-10.5" => -10.5,
                     39:        "10.1234567e10" =>      10.1234567e10,
                     40:        "10.7654321E-10" => 10.7654321E-10,
                     41:        ".5" => .5,
                     42:                
                     43:     // array data
                     44:     "array()" =>   array(),
                     45:        "array(0)" =>  array(0),
                     46:        "array(1)" =>  array(1),
                     47:        "array(1, 2)" => array(1, 2),
                     48:        "array('color' => 'red', 'item' => 'pen'" => array('color' => 'red', 'item' => 'pen'),
                     49:                
                     50:        // null data
                     51:        "NULL" => NULL,
                     52:        "null" => null,
                     53:                
                     54:        // boolean data
                     55:        "true" => true,
                     56:        "false" => false,
                     57:        "TRUE" => TRUE,
                     58:        "FALSE" => FALSE,
                     59:                
                     60:        // empty data
                     61:        "\"\"" => "",
                     62:        "''" => '',
                     63:                
                     64:        // object data
                     65:        "stdClass object" => new stdclass(),
                     66:                
                     67:        // undefined data
                     68:     "undefined variable" => $undefined_var,
                     69:                
                     70:        // unset data
                     71:        "unset variable" => $unset_var,
                     72:        
                     73:        // resource data
                     74:        "resource" => $file_handle
                     75: );
                     76: 
                     77: // loop through each element of the array for strict argument
                     78: 
                     79: foreach($values as $key=>$value) {
                     80:     echo "\n-- Arg value $key --\n";
                     81:     var_dump(base64_decode($str, $value));
                     82: };
                     83: 
                     84: ?>
                     85: ===Done===
                     86: --EXPECTF--
                     87: *** Testing base64_decode() : usage variations ***
                     88: Error: 8 - Undefined variable: undefined_var, %s(%d)
                     89: Error: 8 - Undefined variable: unset_var, %s(%d)
                     90: 
                     91: -- Arg value 0 --
                     92: string(12) "hello world!"
                     93: 
                     94: -- Arg value 1 --
                     95: bool(false)
                     96: 
                     97: -- Arg value 12345 --
                     98: bool(false)
                     99: 
                    100: -- Arg value -2345 --
                    101: bool(false)
                    102: 
                    103: -- Arg value 10.5 --
                    104: bool(false)
                    105: 
                    106: -- Arg value -10.5 --
                    107: bool(false)
                    108: 
                    109: -- Arg value 10.1234567e10 --
                    110: bool(false)
                    111: 
                    112: -- Arg value 10.7654321E-10 --
                    113: bool(false)
                    114: 
                    115: -- Arg value .5 --
                    116: bool(false)
                    117: 
                    118: -- Arg value array() --
                    119: Error: 2 - base64_decode() expects parameter 2 to be boolean, array given, %s(%d)
                    120: NULL
                    121: 
                    122: -- Arg value array(0) --
                    123: Error: 2 - base64_decode() expects parameter 2 to be boolean, array given, %s(%d)
                    124: NULL
                    125: 
                    126: -- Arg value array(1) --
                    127: Error: 2 - base64_decode() expects parameter 2 to be boolean, array given, %s(%d)
                    128: NULL
                    129: 
                    130: -- Arg value array(1, 2) --
                    131: Error: 2 - base64_decode() expects parameter 2 to be boolean, array given, %s(%d)
                    132: NULL
                    133: 
                    134: -- Arg value array('color' => 'red', 'item' => 'pen' --
                    135: Error: 2 - base64_decode() expects parameter 2 to be boolean, array given, %s(%d)
                    136: NULL
                    137: 
                    138: -- Arg value NULL --
                    139: string(12) "hello world!"
                    140: 
                    141: -- Arg value null --
                    142: string(12) "hello world!"
                    143: 
                    144: -- Arg value true --
                    145: bool(false)
                    146: 
                    147: -- Arg value false --
                    148: string(12) "hello world!"
                    149: 
                    150: -- Arg value TRUE --
                    151: bool(false)
                    152: 
                    153: -- Arg value FALSE --
                    154: string(12) "hello world!"
                    155: 
                    156: -- Arg value "" --
                    157: string(12) "hello world!"
                    158: 
                    159: -- Arg value '' --
                    160: string(12) "hello world!"
                    161: 
                    162: -- Arg value stdClass object --
                    163: Error: 2 - base64_decode() expects parameter 2 to be boolean, object given, %s(%d)
                    164: NULL
                    165: 
                    166: -- Arg value undefined variable --
                    167: string(12) "hello world!"
                    168: 
                    169: -- Arg value unset variable --
                    170: string(12) "hello world!"
                    171: 
                    172: -- Arg value resource --
                    173: Error: 2 - base64_decode() expects parameter 2 to be boolean, resource given, %s(%d)
                    174: NULL
                    175: ===Done===

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