1
0
mirror of https://github.com/php/php-src.git synced 2026-04-05 07:02:33 +02:00
Files
archived-php-src/ext/mbstring/tests/mb_substitute_character_basic.phpt
George Peter Banyard 7dd332f110 Refactor mb_substitute_character()
Using the new Fast ZPP API for string|int|null

This also fixes Bug #79448 which was too disruptive to fix in PHP 7.x
2020-05-11 17:30:01 +02:00

48 lines
1.3 KiB
PHP

--TEST--
Test mb_substitute_character() function : basic functionality
--SKIPIF--
<?php
extension_loaded('mbstring') or die('skip');
?>
--FILE--
<?php
/* Prototype : mixed mb_substitute_character([mixed substchar])
* Description: Sets the current substitute_character or returns the current substitute_character
* Source code: ext/mbstring/mbstring.c
* Alias to functions:
*/
echo "*** Testing mb_substitute_character() : basic functionality ***\n";
// Initialise all required variables
var_dump( mb_substitute_character() );
var_dump( mb_substitute_character(66) );
var_dump( mb_substitute_character() );
var_dump( mb_substitute_character(1234) );
var_dump( mb_substitute_character() );
var_dump( mb_substitute_character('none') );
var_dump( mb_substitute_character() );
// Check string case insensitivity
var_dump( mb_substitute_character('LoNg') );
var_dump( mb_substitute_character() );
try {
var_dump( mb_substitute_character("b") );
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
?>
--EXPECT--
*** Testing mb_substitute_character() : basic functionality ***
int(63)
bool(true)
int(66)
bool(true)
int(1234)
bool(true)
string(4) "none"
bool(true)
string(4) "long"
mb_substitute_character(): Argument #1 ($substitute_character) must be 'none', 'long', 'entity' or a valid codepoint