File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / mbstring / tests / mb_detect_order.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:47:57 2012 UTC (12 years, 5 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, v5_3_10, HEAD
php

--TEST--
mb_detect_order()  
--SKIPIF--
<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
--INI--
mbstring.language=Japanese
--FILE--
<?php
//$debug = true;
ini_set('include_path', dirname(__FILE__));
include_once('common.inc');


// Set order to "auto"
$r = mb_detect_order('auto');
($r === TRUE) ? print "OK_AUTO\n" : print "NG_AUTO\n";
print implode(', ', mb_detect_order()) . "\n";


// Set order by string
$r = mb_detect_order('SJIS,EUC-JP,JIS,UTF-8');
($r === TRUE) ? print "OK_STR\n" : print "NG_STR\n";
print implode(', ', mb_detect_order()) . "\n";


// Set order by array
$a[] = 'ASCII';
$a[] = 'JIS';
$a[] = 'EUC-JP';
$a[] = 'UTF-8';
$r = mb_detect_order($a);
($r === TRUE) ? print "OK_ARRAY\n" : print "NG_ARRAY\n";
print implode(', ', mb_detect_order()) . "\n";

// Set invalid encoding. Should fail.
print "== INVALID PARAMETER ==\n";

$r = mb_detect_order('BAD_NAME');
($r === FALSE) ? print "OK_BAD_STR\n" : print "NG_BAD_STR\n";
print implode(', ', mb_detect_order()) . "\n";

$a[] = 'BAD_NAME';
$r = mb_detect_order($a);
($r ===	FALSE) ? print "OK_BAD_ARRAY\n" : print "NG_BAD_ARRAY\n";
print implode(', ', mb_detect_order()) . "\n";

?>

--EXPECT--
OK_AUTO
ASCII, JIS, UTF-8, EUC-JP, SJIS
OK_STR
SJIS, EUC-JP, JIS, UTF-8
OK_ARRAY
ASCII, JIS, EUC-JP, UTF-8
== INVALID PARAMETER ==
OK_BAD_STR
ASCII, JIS, EUC-JP, UTF-8
OK_BAD_ARRAY
ASCII, JIS, EUC-JP, UTF-8


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