MediaWiki
REL1_22
|
00001 <?php 00002 00006 class FallbackTest extends MediaWikiTestCase { 00007 00008 public function testFallbackMbstringFunctions() { 00009 00010 if ( !extension_loaded( 'mbstring' ) ) { 00011 $this->markTestSkipped( "The mb_string functions must be installed to test the fallback functions" ); 00012 } 00013 00014 $sampleUTF = "Östergötland_coat_of_arms.png"; 00015 00016 //mb_substr 00017 $substr_params = array( 00018 array( 0, 0 ), 00019 array( 5, -4 ), 00020 array( 33 ), 00021 array( 100, -5 ), 00022 array( -8, 10 ), 00023 array( 1, 1 ), 00024 array( 2, -1 ) 00025 ); 00026 00027 foreach ( $substr_params as $param_set ) { 00028 $old_param_set = $param_set; 00029 array_unshift( $param_set, $sampleUTF ); 00030 00031 $this->assertEquals( 00032 call_user_func_array( 'mb_substr', $param_set ), 00033 call_user_func_array( 'Fallback::mb_substr', $param_set ), 00034 'Fallback mb_substr with params ' . implode( ', ', $old_param_set ) 00035 ); 00036 } 00037 00038 //mb_strlen 00039 $this->assertEquals( 00040 mb_strlen( $sampleUTF ), 00041 Fallback::mb_strlen( $sampleUTF ), 00042 'Fallback mb_strlen' 00043 ); 00044 00045 //mb_str(r?)pos 00046 $strpos_params = array( 00047 //array( 'ter' ), 00048 //array( 'Ö' ), 00049 //array( 'Ö', 3 ), 00050 //array( 'oat_', 100 ), 00051 //array( 'c', -10 ), 00052 //Broken for now 00053 ); 00054 00055 foreach ( $strpos_params as $param_set ) { 00056 $old_param_set = $param_set; 00057 array_unshift( $param_set, $sampleUTF ); 00058 00059 $this->assertEquals( 00060 call_user_func_array( 'mb_strpos', $param_set ), 00061 call_user_func_array( 'Fallback::mb_strpos', $param_set ), 00062 'Fallback mb_strpos with params ' . implode( ', ', $old_param_set ) 00063 ); 00064 00065 $this->assertEquals( 00066 call_user_func_array( 'mb_strrpos', $param_set ), 00067 call_user_func_array( 'Fallback::mb_strrpos', $param_set ), 00068 'Fallback mb_strrpos with params ' . implode( ', ', $old_param_set ) 00069 ); 00070 } 00071 } 00072 00073 }