xref: /PHP-8.3/ext/mbstring/tests/bug43998.phpt (revision a06d015e)
1--TEST--
2Test mb_strtolower() function : Two error messages returned for incorrect encoding for mb_strto[upper|lower]
3--EXTENSIONS--
4mbstring
5--FILE--
6<?php
7/*
8 * Two error messages returned for incorrect encoding for mb_strto[upper|lower]
9 * Bug now appears to be fixed
10 */
11
12$sourcestring = 'Hello, World';
13
14$inputs = array(12345, 12.3456789000E-10, true, false, "");
15$iterator = 1;
16foreach($inputs as $input) {
17    echo "\n-- Iteration $iterator --\n";
18        try {
19            var_dump( mb_strtolower($sourcestring, $input) );
20        } catch (\ValueError $e) {
21            echo $e->getMessage() . \PHP_EOL;
22        }
23        try {
24            var_dump( mb_strtoupper($sourcestring, $input) );
25        } catch (\ValueError $e) {
26            echo $e->getMessage() . \PHP_EOL;
27        }
28  $iterator++;
29}
30
31?>
32--EXPECT--
33-- Iteration 1 --
34mb_strtolower(): Argument #2 ($encoding) must be a valid encoding, "12345" given
35mb_strtoupper(): Argument #2 ($encoding) must be a valid encoding, "12345" given
36
37-- Iteration 2 --
38mb_strtolower(): Argument #2 ($encoding) must be a valid encoding, "1.23456789E-9" given
39mb_strtoupper(): Argument #2 ($encoding) must be a valid encoding, "1.23456789E-9" given
40
41-- Iteration 3 --
42mb_strtolower(): Argument #2 ($encoding) must be a valid encoding, "1" given
43mb_strtoupper(): Argument #2 ($encoding) must be a valid encoding, "1" given
44
45-- Iteration 4 --
46mb_strtolower(): Argument #2 ($encoding) must be a valid encoding, "" given
47mb_strtoupper(): Argument #2 ($encoding) must be a valid encoding, "" given
48
49-- Iteration 5 --
50mb_strtolower(): Argument #2 ($encoding) must be a valid encoding, "" given
51mb_strtoupper(): Argument #2 ($encoding) must be a valid encoding, "" given
52