mirror of
https://github.com/php/php-src.git
synced 2026-04-21 06:51:18 +02:00
Add assertions to check the return value is not NULL as this indicates a bug. Add identical assertion to mb_strtoupper and mb_strtolower. This means these functions can't return false anymore, ammend stubs accordingly.
35 lines
1.2 KiB
PHP
35 lines
1.2 KiB
PHP
--TEST--
|
|
Calling mb_convert_case() with an invalid casing mode
|
|
--SKIPIF--
|
|
<?php require 'skipif.inc'; ?>
|
|
--FILE--
|
|
<?php
|
|
|
|
var_dump(mb_convert_case('foo BAR Spaß', MB_CASE_UPPER));
|
|
var_dump(mb_convert_case('foo BAR Spaß', MB_CASE_LOWER));
|
|
var_dump(mb_convert_case('foo BAR Spaß', MB_CASE_TITLE));
|
|
var_dump(mb_convert_case('foo BAR Spaß', MB_CASE_FOLD));
|
|
var_dump(mb_convert_case('foo BAR Spaß', MB_CASE_UPPER_SIMPLE));
|
|
var_dump(mb_convert_case('foo BAR Spaß', MB_CASE_LOWER_SIMPLE));
|
|
var_dump(mb_convert_case('foo BAR Spaß', MB_CASE_TITLE_SIMPLE));
|
|
var_dump(mb_convert_case('foo BAR Spaß', MB_CASE_FOLD_SIMPLE));
|
|
|
|
// Invalid mode
|
|
try {
|
|
var_dump(mb_convert_case('foo BAR Spaß', 100));
|
|
} catch (\ValueError $e) {
|
|
echo $e->getMessage() . \PHP_EOL;
|
|
}
|
|
|
|
?>
|
|
--EXPECT--
|
|
string(13) "FOO BAR SPASS"
|
|
string(13) "foo bar spaß"
|
|
string(13) "Foo Bar Spaß"
|
|
string(13) "foo bar spass"
|
|
string(13) "FOO BAR SPAß"
|
|
string(13) "foo bar spaß"
|
|
string(13) "Foo Bar Spaß"
|
|
string(13) "foo bar spaß"
|
|
mb_convert_case(): Argument #2 ($mode) must be one of MB_CASE_UPPER, MB_CASE_LOWER, MB_CASE_TITLE, MB_CASE_FOLD, MB_CASE_UPPER_SIMPLE, MB_CASE_LOWER_SIMPLE, MB_CASE_TITLE_SIMPLE, or MB_CASE_FOLD_SIMPLE
|