* This test StringUtils::isUtf8 whenever we have mbstring extension
* loaded.
*
- * @cover StringUtils::isUtf8
+ * @covers StringUtils::isUtf8
* @dataProvider provideStringsForIsUtf8Check
*/
- function testIsUtf8WithMbstring($expected, $string ) {
- if( !function_exists( 'mb_check_encoding' ) ) {
+ function testIsUtf8WithMbstring( $expected, $string ) {
+ if ( !function_exists( 'mb_check_encoding' ) ) {
$this->markTestSkipped( 'Test requires the mbstring PHP extension' );
}
$this->assertEquals( $expected,
* implementation used as a fallback when mb_check_encoding() is
* not available.
*
- * @cover StringUtils::isUtf8
+ * @covers StringUtils::isUtf8
* @dataProvider provideStringsForIsUtf8Check
*/
- function testIsUtf8WithPhpFallbackImplementation($expected, $string ) {
+ function testIsUtf8WithPhpFallbackImplementation( $expected, $string ) {
$this->assertEquals( $expected,
StringUtils::isUtf8( $string, /** disable mbstring: */ true ),
'Testing string "' . $this->escaped( $string ) . '" with pure PHP implementation'
*/
function escaped( $string ) {
$escaped = '';
- for($i=0; $i<strlen($string);$i++) {
+ $length = strlen( $string );
+ for ( $i = 0; $i < $length; $i++ ) {
$char = $string[$i];
- $val = ord($char);
- if( $val > 127 ) {
- $escaped .='\x' . dechex($val);
+ $val = ord( $char );
+ if ( $val > 127 ) {
+ $escaped .= '\x' . dechex( $val );
} else {
$escaped .= $char;
}
* Markus Kuhn:
* http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt
*/
- function provideStringsForIsUtf8Check() {
+ public static function provideStringsForIsUtf8Check() {
// Expected return values for StringUtils::isUtf8()
$PASS = true;
$FAIL = false;