Import: Handle uploads with sha1 starting with 0 properly
[mediawiki.git] / tests / phpunit / includes / FallbackTest.php
blob0a1b7d0ccfe8eade2e69b7c2b02ade1f7ca92a83
1 <?php
3 /**
4 * @covers Fallback
5 */
6 class FallbackTest extends MediaWikiTestCase {
7 public function testFallbackMbstringFunctions() {
8 if ( !extension_loaded( 'mbstring' ) ) {
9 $this->markTestSkipped(
10 "The mb_string functions must be installed to test the fallback functions"
14 $sampleUTF = "Östergötland_coat_of_arms.png";
16 // mb_substr
17 $substr_params = array(
18 array( 0, 0 ),
19 array( 5, -4 ),
20 array( 33 ),
21 array( 100, -5 ),
22 array( -8, 10 ),
23 array( 1, 1 ),
24 array( 2, -1 )
27 foreach ( $substr_params as $param_set ) {
28 $old_param_set = $param_set;
29 array_unshift( $param_set, $sampleUTF );
31 $this->assertEquals(
32 call_user_func_array( 'mb_substr', $param_set ),
33 call_user_func_array( 'Fallback::mb_substr', $param_set ),
34 'Fallback mb_substr with params ' . implode( ', ', $old_param_set )
38 // mb_strlen
39 $this->assertEquals(
40 mb_strlen( $sampleUTF ),
41 Fallback::mb_strlen( $sampleUTF ),
42 'Fallback mb_strlen'
45 // mb_str(r?)pos
46 $strpos_params = array(
47 // array( 'ter' ),
48 // array( 'Ö' ),
49 // array( 'Ö', 3 ),
50 // array( 'oat_', 100 ),
51 // array( 'c', -10 ),
52 // Broken for now
55 foreach ( $strpos_params as $param_set ) {
56 $old_param_set = $param_set;
57 array_unshift( $param_set, $sampleUTF );
59 $this->assertEquals(
60 call_user_func_array( 'mb_strpos', $param_set ),
61 call_user_func_array( 'Fallback::mb_strpos', $param_set ),
62 'Fallback mb_strpos with params ' . implode( ', ', $old_param_set )
65 $this->assertEquals(
66 call_user_func_array( 'mb_strrpos', $param_set ),
67 call_user_func_array( 'Fallback::mb_strrpos', $param_set ),
68 'Fallback mb_strrpos with params ' . implode( ', ', $old_param_set )