1--TEST--
2mb_detect_order()
3--SKIPIF--
4<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
5--INI--
6mbstring.language=Japanese
7--FILE--
8<?php
9//$debug = true;
10ini_set('include_path', dirname(__FILE__));
11include_once('common.inc');
12
13
14// Set order to "auto"
15$r = mb_detect_order('auto');
16($r === TRUE) ? print "OK_AUTO\n" : print "NG_AUTO\n";
17print implode(', ', mb_detect_order()) . "\n";
18
19
20// Set order by string
21$r = mb_detect_order('SJIS,EUC-JP,JIS,UTF-8');
22($r === TRUE) ? print "OK_STR\n" : print "NG_STR\n";
23print implode(', ', mb_detect_order()) . "\n";
24
25
26// Set order by array
27$a[] = 'ASCII';
28$a[] = 'JIS';
29$a[] = 'EUC-JP';
30$a[] = 'UTF-8';
31$r = mb_detect_order($a);
32($r === TRUE) ? print "OK_ARRAY\n" : print "NG_ARRAY\n";
33print implode(', ', mb_detect_order()) . "\n";
34
35// Set invalid encoding. Should fail.
36print "== INVALID PARAMETER ==\n";
37
38$r = mb_detect_order('BAD_NAME');
39($r === FALSE) ? print "OK_BAD_STR\n" : print "NG_BAD_STR\n";
40print implode(', ', mb_detect_order()) . "\n";
41
42$a[] = 'BAD_NAME';
43$r = mb_detect_order($a);
44($r ===	FALSE) ? print "OK_BAD_ARRAY\n" : print "NG_BAD_ARRAY\n";
45print implode(', ', mb_detect_order()) . "\n";
46
47?>
48--EXPECT--
49OK_AUTO
50ASCII, JIS, UTF-8, EUC-JP, SJIS
51OK_STR
52SJIS, EUC-JP, JIS, UTF-8
53OK_ARRAY
54ASCII, JIS, EUC-JP, UTF-8
55== INVALID PARAMETER ==
56OK_BAD_STR
57ASCII, JIS, EUC-JP, UTF-8
58OK_BAD_ARRAY
59ASCII, JIS, EUC-JP, UTF-8
60