xref: /PHP-7.1/ext/mbstring/tests/bug43998.phpt (revision 113213f0)
1--TEST--
2Test mb_strtolower() function : Two error messages returned for incorrect encoding for mb_strto[upper|lower]
3--SKIPIF--
4<?php
5extension_loaded('mbstring') or die('skip');
6function_exists('mb_strtolower') or die("skip mb_strtolower() is not available in this build");
7?>
8--FILE--
9<?php
10/* Prototype  : string mb_strto[lower|upper](string $sourcestring [, string $encoding])
11 * Description: Returns a [lower|upper]cased version of $sourcestring
12 * Source code: ext/mbstring/mbstring.c
13 */
14
15/*
16 * Two error messages returned for incorrect encoding for mb_strto[upper|lower]
17 * Bug now appears to be fixed
18 */
19
20$sourcestring = 'Hello, World';
21
22$inputs = array(12345, 12.3456789000E-10, true, false, "");
23$iterator = 1;
24foreach($inputs as $input) {
25  echo "\n-- Iteration $iterator --\n";
26  var_dump( mb_strtolower($sourcestring, $input) );
27  var_dump( mb_strtoupper($sourcestring, $input) );
28  $iterator++;
29};
30?>
31--EXPECTF--
32-- Iteration 1 --
33
34Warning: mb_strtolower(): Unknown encoding "12345" in %s on line %d
35bool(false)
36
37Warning: mb_strtoupper(): Unknown encoding "12345" in %s on line %d
38bool(false)
39
40-- Iteration 2 --
41
42Warning: mb_strtolower(): Unknown encoding "1.23456789E-9" in %s on line %d
43bool(false)
44
45Warning: mb_strtoupper(): Unknown encoding "1.23456789E-9" in %s on line %d
46bool(false)
47
48-- Iteration 3 --
49
50Warning: mb_strtolower(): Unknown encoding "1" in %s on line %d
51bool(false)
52
53Warning: mb_strtoupper(): Unknown encoding "1" in %s on line %d
54bool(false)
55
56-- Iteration 4 --
57
58Warning: mb_strtolower(): Unknown encoding "" in %s on line %d
59bool(false)
60
61Warning: mb_strtoupper(): Unknown encoding "" in %s on line %d
62bool(false)
63
64-- Iteration 5 --
65
66Warning: mb_strtolower(): Unknown encoding "" in %s on line %d
67bool(false)
68
69Warning: mb_strtoupper(): Unknown encoding "" in %s on line %d
70bool(false)
71