Annotation of embedaddon/php/ext/mbstring/tests/mb_decode_mimeheader_variation1.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test mb_decode_mimeheader() function : usage variation 
        !             3: --CREDITS--
        !             4: D. Kesley
        !             5: --SKIPIF--
        !             6: <?php
        !             7: extension_loaded('mbstring') or die('skip');
        !             8: function_exists('mb_decode_mimeheader') or die("skip mb_decode_mimeheader() is not available in this build");
        !             9: ?>
        !            10: --FILE--
        !            11: <?php
        !            12: /* Prototype  : string mb_decode_mimeheader(string string)
        !            13:  * Description: Decodes the MIME "encoded-word" in the string 
        !            14:  * Source code: ext/mbstring/mbstring.c
        !            15:  * Alias to functions: 
        !            16:  */
        !            17: 
        !            18: echo "*** Testing mb_decode_mimeheader() : usage variation ***\n";
        !            19: 
        !            20: // Define error handler
        !            21: function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
        !            22:        if (error_reporting() != 0) {
        !            23:                // report non-silenced errors
        !            24:                echo "Error: $err_no - $err_msg, $filename($linenum)\n";
        !            25:        }
        !            26: }
        !            27: set_error_handler('test_error_handler');
        !            28: 
        !            29: // Initialise function arguments not being substituted (if any)
        !            30: 
        !            31: //get an unset variable
        !            32: $unset_var = 10;
        !            33: unset ($unset_var);
        !            34: 
        !            35: // define some classes
        !            36: class classWithToString
        !            37: {
        !            38:        public function __toString() {
        !            39:                return "Class A object";
        !            40:        }
        !            41: }
        !            42: 
        !            43: class classWithoutToString
        !            44: {
        !            45: }
        !            46: 
        !            47: // heredoc string
        !            48: $heredoc = <<<EOT
        !            49: hello world
        !            50: EOT;
        !            51: 
        !            52: // get a resource variable
        !            53: $fp = fopen(__FILE__, "r");
        !            54: 
        !            55: // add arrays
        !            56: $index_array = array (1, 2, 3);
        !            57: $assoc_array = array ('one' => 1, 'two' => 2);
        !            58: 
        !            59: //array of values to iterate over
        !            60: $inputs = array(
        !            61: 
        !            62:       // int data
        !            63:       'int 0' => 0,
        !            64:       'int 1' => 1,
        !            65:       'int 12345' => 12345,
        !            66:       'int -12345' => -2345,
        !            67: 
        !            68:       // float data
        !            69:       'float 10.5' => 10.5,
        !            70:       'float -10.5' => -10.5,
        !            71:       'float 12.3456789000e10' => 12.3456789000e10,
        !            72:       'float -12.3456789000e10' => -12.3456789000e10,
        !            73:       'float .5' => .5,
        !            74: 
        !            75:       // array data
        !            76:       'empty array' => array(),
        !            77:       'int indexed array' => $index_array,
        !            78:       'associative array' => $assoc_array,
        !            79:       'nested arrays' => array('foo', $index_array, $assoc_array),
        !            80: 
        !            81:       // null data
        !            82:       'uppercase NULL' => NULL,
        !            83:       'lowercase null' => null,
        !            84: 
        !            85:       // boolean data
        !            86:       'lowercase true' => true,
        !            87:       'lowercase false' =>false,
        !            88:       'uppercase TRUE' =>TRUE,
        !            89:       'uppercase FALSE' =>FALSE,
        !            90: 
        !            91:       // empty data
        !            92:       'empty string DQ' => "",
        !            93:       'empty string SQ' => '',
        !            94: 
        !            95:       // object data
        !            96:       'instance of classWithToString' => new classWithToString(),
        !            97:       'instance of classWithoutToString' => new classWithoutToString(),
        !            98: 
        !            99:       // undefined data
        !           100:       'undefined var' => @$undefined_var,
        !           101: 
        !           102:       // unset data
        !           103:       'unset var' => @$unset_var,
        !           104:       
        !           105:       // resource variable
        !           106:       'resource' => $fp      
        !           107: );
        !           108: 
        !           109: // loop through each element of the array for string
        !           110: 
        !           111: foreach($inputs as $key =>$value) {
        !           112:       echo "\n--$key--\n";
        !           113:       var_dump( mb_decode_mimeheader($value) );
        !           114: };
        !           115: 
        !           116: fclose($fp);
        !           117: 
        !           118: ?>
        !           119: ===DONE===
        !           120: --EXPECTF--
        !           121: *** Testing mb_decode_mimeheader() : usage variation ***
        !           122: 
        !           123: --int 0--
        !           124: string(1) "0"
        !           125: 
        !           126: --int 1--
        !           127: string(1) "1"
        !           128: 
        !           129: --int 12345--
        !           130: string(5) "12345"
        !           131: 
        !           132: --int -12345--
        !           133: string(5) "-2345"
        !           134: 
        !           135: --float 10.5--
        !           136: string(4) "10.5"
        !           137: 
        !           138: --float -10.5--
        !           139: string(5) "-10.5"
        !           140: 
        !           141: --float 12.3456789000e10--
        !           142: string(12) "123456789000"
        !           143: 
        !           144: --float -12.3456789000e10--
        !           145: string(13) "-123456789000"
        !           146: 
        !           147: --float .5--
        !           148: string(3) "0.5"
        !           149: 
        !           150: --empty array--
        !           151: Error: 2 - mb_decode_mimeheader() expects parameter 1 to be string, array given, %s(%d)
        !           152: NULL
        !           153: 
        !           154: --int indexed array--
        !           155: Error: 2 - mb_decode_mimeheader() expects parameter 1 to be string, array given, %s(%d)
        !           156: NULL
        !           157: 
        !           158: --associative array--
        !           159: Error: 2 - mb_decode_mimeheader() expects parameter 1 to be string, array given, %s(%d)
        !           160: NULL
        !           161: 
        !           162: --nested arrays--
        !           163: Error: 2 - mb_decode_mimeheader() expects parameter 1 to be string, array given, %s(%d)
        !           164: NULL
        !           165: 
        !           166: --uppercase NULL--
        !           167: string(0) ""
        !           168: 
        !           169: --lowercase null--
        !           170: string(0) ""
        !           171: 
        !           172: --lowercase true--
        !           173: string(1) "1"
        !           174: 
        !           175: --lowercase false--
        !           176: string(0) ""
        !           177: 
        !           178: --uppercase TRUE--
        !           179: string(1) "1"
        !           180: 
        !           181: --uppercase FALSE--
        !           182: string(0) ""
        !           183: 
        !           184: --empty string DQ--
        !           185: string(0) ""
        !           186: 
        !           187: --empty string SQ--
        !           188: string(0) ""
        !           189: 
        !           190: --instance of classWithToString--
        !           191: string(14) "Class A object"
        !           192: 
        !           193: --instance of classWithoutToString--
        !           194: Error: 2 - mb_decode_mimeheader() expects parameter 1 to be string, object given, %s(%d)
        !           195: NULL
        !           196: 
        !           197: --undefined var--
        !           198: string(0) ""
        !           199: 
        !           200: --unset var--
        !           201: string(0) ""
        !           202: 
        !           203: --resource--
        !           204: Error: 2 - mb_decode_mimeheader() expects parameter 1 to be string, resource given, %s(%d)
        !           205: NULL
        !           206: ===DONE===

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