Annotation of embedaddon/php/ext/iconv/tests/iconv_mime_decode_variation2.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test iconv_mime_decode() function : usage variations - Pass different data types to mode arg
        !             3: --SKIPIF--
        !             4: <?php
        !             5: extension_loaded('iconv') or die('skip');
        !             6: function_exists('iconv_mime_decode') or die("skip iconv_mime_decode() is not available in this build");
        !             7: ?>
        !             8: --FILE--
        !             9: <?php
        !            10: /* Prototype  : string iconv_mime_decode(string encoded_string [, int mode, string charset])
        !            11:  * Description: Decodes a mime header field
        !            12:  * Source code: ext/iconv/iconv.c
        !            13:  */
        !            14: 
        !            15: /*
        !            16:  * Pass different data types to $str argument to see how iconv_mime_decode() behaves
        !            17:  */
        !            18: 
        !            19: echo "*** Testing iconv_mime_decode() : usage variations ***\n";
        !            20: 
        !            21: // Initialise function arguments not being substituted
        !            22: $header = b'Subject: =?UTF-8?B?UHLDvGZ1bmcgUHLDvGZ1bmc=?=';
        !            23: $mode = ICONV_MIME_DECODE_CONTINUE_ON_ERROR;
        !            24: $charset = 'UTF-8';
        !            25: 
        !            26: 
        !            27: //get an unset variable
        !            28: $unset_var = 10;
        !            29: unset ($unset_var);
        !            30: 
        !            31: // get a class
        !            32: class classA
        !            33: {
        !            34:   public function __toString() {
        !            35:     return "Class A object";
        !            36:   }
        !            37: }
        !            38: 
        !            39: // heredoc string
        !            40: $heredoc = <<<EOT
        !            41: hello world
        !            42: EOT;
        !            43: 
        !            44: // get a resource variable
        !            45: $fp = fopen(__FILE__, "r");
        !            46: 
        !            47: // unexpected values to be passed to $str argument
        !            48: $inputs = array(
        !            49: 
        !            50:        // int data
        !            51: /*1*/  0,
        !            52:        1,
        !            53:        12345,
        !            54:        -2345,
        !            55: 
        !            56:        // float data
        !            57: /*5*/  10.5,
        !            58:        -10.5,
        !            59:        12.3456789000e10,
        !            60:        12.3456789000E-10,
        !            61:        .5,
        !            62: 
        !            63:        // null data
        !            64: /*10*/ NULL,
        !            65:        null,
        !            66: 
        !            67:        // boolean data
        !            68: /*12*/ true,
        !            69:        false,
        !            70:        TRUE,
        !            71:        FALSE,
        !            72:        
        !            73:        // empty data
        !            74: /*16*/ "",
        !            75:        '',
        !            76: 
        !            77:        // string data
        !            78: /*18*/ "string",
        !            79:        'string',
        !            80:        $heredoc,
        !            81:        
        !            82:        // object data
        !            83: /*21*/ new classA(),
        !            84: 
        !            85:        // undefined data
        !            86: /*22*/ @$undefined_var,
        !            87: 
        !            88:        // unset data
        !            89: /*23*/ @$unset_var,
        !            90: 
        !            91:        // resource variable
        !            92: /*24*/ $fp
        !            93: );
        !            94: 
        !            95: // loop through each element of $inputs to check the behavior of iconv_mime_decode()
        !            96: $iterator = 1;
        !            97: foreach($inputs as $input) {
        !            98:   echo "\n-- Iteration $iterator --\n";
        !            99:   var_dump( bin2hex(iconv_mime_decode($header, $input, $charset)));
        !           100:   $iterator++;
        !           101: };
        !           102: 
        !           103: fclose($fp);
        !           104: 
        !           105: echo "Done";
        !           106: ?>
        !           107: --EXPECTF--
        !           108: *** Testing iconv_mime_decode() : usage variations ***
        !           109: 
        !           110: -- Iteration 1 --
        !           111: string(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67"
        !           112: 
        !           113: -- Iteration 2 --
        !           114: string(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67"
        !           115: 
        !           116: -- Iteration 3 --
        !           117: string(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67"
        !           118: 
        !           119: -- Iteration 4 --
        !           120: string(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67"
        !           121: 
        !           122: -- Iteration 5 --
        !           123: string(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67"
        !           124: 
        !           125: -- Iteration 6 --
        !           126: string(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67"
        !           127: 
        !           128: -- Iteration 7 --
        !           129: string(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67"
        !           130: 
        !           131: -- Iteration 8 --
        !           132: string(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67"
        !           133: 
        !           134: -- Iteration 9 --
        !           135: string(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67"
        !           136: 
        !           137: -- Iteration 10 --
        !           138: string(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67"
        !           139: 
        !           140: -- Iteration 11 --
        !           141: string(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67"
        !           142: 
        !           143: -- Iteration 12 --
        !           144: string(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67"
        !           145: 
        !           146: -- Iteration 13 --
        !           147: string(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67"
        !           148: 
        !           149: -- Iteration 14 --
        !           150: string(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67"
        !           151: 
        !           152: -- Iteration 15 --
        !           153: string(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67"
        !           154: 
        !           155: -- Iteration 16 --
        !           156: 
        !           157: Warning: iconv_mime_decode() expects parameter 2 to be long, string given in %s on line %d
        !           158: string(0) ""
        !           159: 
        !           160: -- Iteration 17 --
        !           161: 
        !           162: Warning: iconv_mime_decode() expects parameter 2 to be long, string given in %s on line %d
        !           163: string(0) ""
        !           164: 
        !           165: -- Iteration 18 --
        !           166: 
        !           167: Warning: iconv_mime_decode() expects parameter 2 to be long, string given in %s on line %d
        !           168: string(0) ""
        !           169: 
        !           170: -- Iteration 19 --
        !           171: 
        !           172: Warning: iconv_mime_decode() expects parameter 2 to be long, string given in %s on line %d
        !           173: string(0) ""
        !           174: 
        !           175: -- Iteration 20 --
        !           176: 
        !           177: Warning: iconv_mime_decode() expects parameter 2 to be long, string given in %s on line %d
        !           178: string(0) ""
        !           179: 
        !           180: -- Iteration 21 --
        !           181: 
        !           182: Warning: iconv_mime_decode() expects parameter 2 to be long, object given in %s on line %d
        !           183: string(0) ""
        !           184: 
        !           185: -- Iteration 22 --
        !           186: string(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67"
        !           187: 
        !           188: -- Iteration 23 --
        !           189: string(52) "5375626a6563743a205072c3bc66756e67205072c3bc66756e67"
        !           190: 
        !           191: -- Iteration 24 --
        !           192: 
        !           193: Warning: iconv_mime_decode() expects parameter 2 to be long, resource given in %s on line %d
        !           194: string(0) ""
        !           195: Done

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