Annotation of embedaddon/php/ext/mbstring/tests/mb_http_output.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: mb_http_output()  
                      3: --SKIPIF--
                      4: <?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
                      5: --FILE--
                      6: <?php
                      7: //TODO: Add more encoding. Wrong paramter type test.
                      8: //$debug = true;
                      9: ini_set('include_path', dirname(__FILE__));
                     10: include_once('common.inc');
                     11: 
                     12: // Set HTTP output encoding to ASCII
                     13: $r = mb_http_output('ASCII');
                     14: ($r === TRUE) ? print "OK_ASCII_SET\n" : print "NG_ASCII_SET\n";
                     15: $enc = mb_http_output();
                     16: print "$enc\n";
                     17: 
                     18: // Set HTTP output encoding to SJIS
                     19: $r = mb_http_output('SJIS');
                     20: ($r === TRUE) ? print "OK_SJIS_SET\n" : print "NG_SJIS_SET\n";
                     21: $enc = mb_http_output();
                     22: print "$enc\n";
                     23: 
                     24: // Set HTTP output encoding to JIS
                     25: $r = mb_http_output('JIS');
                     26: ($r === TRUE) ? print "OK_JIS_SET\n" : print "NG_JIS_SET\n";
                     27: $enc = mb_http_output();
                     28: print "$enc\n";
                     29: 
                     30: // Set HTTP output encoding to UTF8
                     31: $r = mb_http_output('UTF-8');
                     32: ($r === TRUE) ? print "OK_UTF-8_SET\n" : print "NG_UTF-8_SET\n";
                     33: $enc = mb_http_output();
                     34: print "$enc\n";
                     35: 
                     36: // Set HTTP output encoding to EUC-JP
                     37: $r = mb_http_output('EUC-JP');
                     38: ($r === TRUE) ? print "OK_EUC-JP_SET\n" : print "NG_EUC-JP_SET\n";
                     39: $enc = mb_http_output();
                     40: print "$enc\n";
                     41: 
                     42: // Invalid parameters
                     43: print "== INVALID PARAMETER ==\n";
                     44: 
                     45: // Note: Bad string raise Warning. Bad Type raise Notice (Type Conversion) and Warning....
                     46: $r = mb_http_output('BAD_NAME');
                     47: ($r === FALSE) ? print "OK_BAD_SET\n" : print "NG_BAD_SET\n";
                     48: $enc = mb_http_output();
                     49: print "$enc\n";
                     50: 
                     51: $r = mb_http_output($t_ary);
                     52: ($r === FALSE) ? print "OK_BAD_ARY_SET\n" : print "NG_BAD_ARY_SET\n";
                     53: $enc = mb_http_output();
                     54: print "$enc\n";
                     55: 
                     56: $r = mb_http_output($t_obj);
                     57: ($r === FALSE) ? print "OK_BAD_OBJ_SET\n" : print "NG_BAD_OBJ_SET\n";
                     58: $enc = mb_http_output();
                     59: print "$enc\n";
                     60: 
                     61: ?>
                     62: 
                     63: --EXPECT--
                     64: OK_ASCII_SET
                     65: ASCII
                     66: OK_SJIS_SET
                     67: SJIS
                     68: OK_JIS_SET
                     69: JIS
                     70: OK_UTF-8_SET
                     71: UTF-8
                     72: OK_EUC-JP_SET
                     73: EUC-JP
                     74: == INVALID PARAMETER ==
                     75: ERR: Warning
                     76: OK_BAD_SET
                     77: EUC-JP
                     78: ERR: Warning
                     79: OK_BAD_ARY_SET
                     80: EUC-JP
                     81: ERR: Warning
                     82: OK_BAD_OBJ_SET
                     83: EUC-JP
                     84: 

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