1--TEST--
2mb_check_encoding() with invalid encodings
3--SKIPIF--
4<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
5--FILE--
6<?php
7
8$str = "Normal string";
9$arr = [1234, 12.34, TRUE, FALSE, NULL, $str, 'key'=>$str, $str=>'val'];
10
11echo 'Using "BAD" as encoding' . \PHP_EOL;
12try {
13    var_dump(mb_check_encoding($str, 'BAD'));
14} catch (\ValueError $e) {
15    echo $e->getMessage() . \PHP_EOL;
16}
17try {
18    var_dump(mb_check_encoding($arr, 'BAD'));
19} catch (\ValueError $e) {
20    echo $e->getMessage() . \PHP_EOL;
21}
22
23echo 'Using "pass" as encoding' . \PHP_EOL;
24try {
25    var_dump(mb_check_encoding($str, 'pass'));
26} catch (\ValueError $e) {
27    echo $e->getMessage() . \PHP_EOL;
28}
29try {
30    var_dump(mb_check_encoding($arr, 'pass'));
31} catch (\ValueError $e) {
32    echo $e->getMessage() . \PHP_EOL;
33}
34
35?>
36--EXPECT--
37Using "BAD" as encoding
38mb_check_encoding(): Argument #2 ($encoding) must be a valid encoding, "BAD" given
39mb_check_encoding(): Argument #2 ($encoding) must be a valid encoding, "BAD" given
40Using "pass" as encoding
41mb_check_encoding(): Argument #2 ($encoding) must be a valid encoding, "pass" given
42mb_check_encoding(): Argument #2 ($encoding) must be a valid encoding, "pass" given
43