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

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

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