Index: trunk/phase3/tests/phpunit/includes/GlobalTest.php |
— | — | @@ -394,6 +394,76 @@ |
395 | 395 | "wfBaseName('$from') => '$to'" ); |
396 | 396 | } |
397 | 397 | } |
| 398 | + |
| 399 | + |
| 400 | + function testFallbackMbstringFunctions() { |
| 401 | + |
| 402 | + if( !extension_loaded( 'mbstring' ) ) { |
| 403 | + $this->markTestSkipped( "The mb_string functions must be installed to test the fallback functions" ); |
| 404 | + } |
| 405 | + |
| 406 | + $sampleUTF = "Östergötland_coat_of_arms.png"; |
| 407 | + |
| 408 | + |
| 409 | + //mb_substr |
| 410 | + $substr_params = array( |
| 411 | + array( 0, 0 ), |
| 412 | + array( 5, -4 ), |
| 413 | + array( 33 ), |
| 414 | + array( 100, -5 ), |
| 415 | + array( -8, 10 ), |
| 416 | + array( 1, 1 ), |
| 417 | + array( 2, -1 ) |
| 418 | + ); |
| 419 | + |
| 420 | + foreach( $substr_params as $param_set ) { |
| 421 | + $old_param_set = $param_set; |
| 422 | + array_unshift( $param_set, $sampleUTF ); |
| 423 | + |
| 424 | + $this->assertEquals( |
| 425 | + call_user_func_array( 'mb_substr', $param_set ), |
| 426 | + call_user_func_array( 'fallback_mb_substr', $param_set ), |
| 427 | + 'Fallback mb_substr with params ' . implode( ', ', $old_param_set ) |
| 428 | + ); |
| 429 | + } |
| 430 | + |
| 431 | + |
| 432 | + //mb_strlen |
| 433 | + $this->assertEquals( |
| 434 | + mb_strlen( $sampleUTF ), |
| 435 | + fallback_mb_strlen( $sampleUTF ), |
| 436 | + 'Fallback mb_strlen' |
| 437 | + ); |
| 438 | + |
| 439 | + |
| 440 | + //mb_str(r?)pos |
| 441 | + $strpos_params = array( |
| 442 | + //array( 'ter' ), |
| 443 | + //array( 'Ö' ), |
| 444 | + //array( 'Ö', 3 ), |
| 445 | + //array( 'oat_', 100 ), |
| 446 | + //array( 'c', -10 ), |
| 447 | + //Broken for now |
| 448 | + ); |
| 449 | + |
| 450 | + foreach( $strpos_params as $param_set ) { |
| 451 | + $old_param_set = $param_set; |
| 452 | + array_unshift( $param_set, $sampleUTF ); |
| 453 | + |
| 454 | + $this->assertEquals( |
| 455 | + call_user_func_array( 'mb_strpos', $param_set ), |
| 456 | + call_user_func_array( 'fallback_mb_strpos', $param_set ), |
| 457 | + 'Fallback mb_strpos with params ' . implode( ', ', $old_param_set ) |
| 458 | + ); |
| 459 | + |
| 460 | + $this->assertEquals( |
| 461 | + call_user_func_array( 'mb_strrpos', $param_set ), |
| 462 | + call_user_func_array( 'fallback_mb_strrpos', $param_set ), |
| 463 | + 'Fallback mb_strrpos with params ' . implode( ', ', $old_param_set ) |
| 464 | + ); |
| 465 | + } |
| 466 | + |
| 467 | + } |
398 | 468 | |
399 | 469 | /* TODO: many more! */ |
400 | 470 | } |