MediaWiki
REL1_21
|
00001 <?php 00002 00003 class GlobalTest extends MediaWikiTestCase { 00004 protected function setUp() { 00005 parent::setUp(); 00006 00007 $readOnlyFile = tempnam( wfTempDir(), "mwtest_readonly" ); 00008 unlink( $readOnlyFile ); 00009 00010 $this->setMwGlobals( array( 00011 'wgReadOnlyFile' => $readOnlyFile, 00012 'wgUrlProtocols' => array( 00013 'http://', 00014 'https://', 00015 'mailto:', 00016 '//', 00017 'file://', # Non-default 00018 ), 00019 ) ); 00020 } 00021 00022 protected function tearDown() { 00023 global $wgReadOnlyFile; 00024 00025 if ( file_exists( $wgReadOnlyFile ) ) { 00026 unlink( $wgReadOnlyFile ); 00027 } 00028 00029 parent::tearDown(); 00030 } 00031 00033 public function testWfArrayDiff2( $a, $b, $expected ) { 00034 $this->assertEquals( 00035 wfArrayDiff2( $a, $b ), $expected 00036 ); 00037 } 00038 00039 // @todo Provide more tests 00040 public static function provideForWfArrayDiff2() { 00041 // $a $b $expected 00042 return array( 00043 array( 00044 array( 'a', 'b' ), 00045 array( 'a', 'b' ), 00046 array(), 00047 ), 00048 array( 00049 array( array( 'a' ), array( 'a', 'b', 'c' ) ), 00050 array( array( 'a' ), array( 'a', 'b' ) ), 00051 array( 1 => array( 'a', 'b', 'c' ) ), 00052 ), 00053 ); 00054 } 00055 00056 function testRandom() { 00057 # This could hypothetically fail, but it shouldn't ;) 00058 $this->assertFalse( 00059 wfRandom() == wfRandom() ); 00060 } 00061 00062 function testUrlencode() { 00063 $this->assertEquals( 00064 "%E7%89%B9%E5%88%A5:Contributions/Foobar", 00065 wfUrlencode( "\xE7\x89\xB9\xE5\x88\xA5:Contributions/Foobar" ) ); 00066 } 00067 00068 function testExpandIRI() { 00069 $this->assertEquals( 00070 "https://te.wikibooks.org/wiki/ఉబుంటు_వాడుకరి_మార్గదర్శని", 00071 wfExpandIRI( "https://te.wikibooks.org/wiki/%E0%B0%89%E0%B0%AC%E0%B1%81%E0%B0%82%E0%B0%9F%E0%B1%81_%E0%B0%B5%E0%B0%BE%E0%B0%A1%E0%B1%81%E0%B0%95%E0%B0%B0%E0%B0%BF_%E0%B0%AE%E0%B0%BE%E0%B0%B0%E0%B1%8D%E0%B0%97%E0%B0%A6%E0%B0%B0%E0%B1%8D%E0%B0%B6%E0%B0%A8%E0%B0%BF" ) ); 00072 } 00073 00074 function testReadOnlyEmpty() { 00075 global $wgReadOnly; 00076 $wgReadOnly = null; 00077 00078 $this->assertFalse( wfReadOnly() ); 00079 $this->assertFalse( wfReadOnly() ); 00080 } 00081 00082 function testReadOnlySet() { 00083 global $wgReadOnly, $wgReadOnlyFile; 00084 00085 $f = fopen( $wgReadOnlyFile, "wt" ); 00086 fwrite( $f, 'Message' ); 00087 fclose( $f ); 00088 $wgReadOnly = null; # Check on $wgReadOnlyFile 00089 00090 $this->assertTrue( wfReadOnly() ); 00091 $this->assertTrue( wfReadOnly() ); # Check cached 00092 00093 unlink( $wgReadOnlyFile ); 00094 $wgReadOnly = null; # Clean cache 00095 00096 $this->assertFalse( wfReadOnly() ); 00097 $this->assertFalse( wfReadOnly() ); 00098 } 00099 00100 function testQuotedPrintable() { 00101 $this->assertEquals( 00102 "=?UTF-8?Q?=C4=88u=20legebla=3F?=", 00103 UserMailer::quotedPrintable( "\xc4\x88u legebla?", "UTF-8" ) ); 00104 } 00105 00106 function testTime() { 00107 $start = wfTime(); 00108 $this->assertInternalType( 'float', $start ); 00109 $end = wfTime(); 00110 $this->assertTrue( $end > $start, "Time is running backwards!" ); 00111 } 00112 00113 public static function provideArrayToCGI() { 00114 return array( 00115 array( array(), '' ), // empty 00116 array( array( 'foo' => 'bar' ), 'foo=bar' ), // string test 00117 array( array( 'foo' => '' ), 'foo=' ), // empty string test 00118 array( array( 'foo' => 1 ), 'foo=1' ), // number test 00119 array( array( 'foo' => true ), 'foo=1' ), // true test 00120 array( array( 'foo' => false ), '' ), // false test 00121 array( array( 'foo' => null ), '' ), // null test 00122 array( array( 'foo' => 'A&B=5+6@!"\'' ), 'foo=A%26B%3D5%2B6%40%21%22%27' ), // urlencoding test 00123 array( array( 'foo' => 'bar', 'baz' => 'is', 'asdf' => 'qwerty' ), 'foo=bar&baz=is&asdf=qwerty' ), // multi-item test 00124 array( array( 'foo' => array( 'bar' => 'baz' ) ), 'foo%5Bbar%5D=baz' ), 00125 array( array( 'foo' => array( 'bar' => 'baz', 'qwerty' => 'asdf' ) ), 'foo%5Bbar%5D=baz&foo%5Bqwerty%5D=asdf' ), 00126 array( array( 'foo' => array( 'bar', 'baz' ) ), 'foo%5B0%5D=bar&foo%5B1%5D=baz' ), 00127 array( array( 'foo' => array( 'bar' => array( 'bar' => 'baz' ) ) ), 'foo%5Bbar%5D%5Bbar%5D=baz' ), 00128 ); 00129 } 00130 00134 function testArrayToCGI( $array, $result ) { 00135 $this->assertEquals( $result, wfArrayToCgi( $array ) ); 00136 } 00137 00138 00139 function testArrayToCGI2() { 00140 $this->assertEquals( 00141 "baz=bar&foo=bar", 00142 wfArrayToCgi( 00143 array( 'baz' => 'bar' ), 00144 array( 'foo' => 'bar', 'baz' => 'overridden value' ) ) ); 00145 } 00146 00147 public static function provideCgiToArray() { 00148 return array( 00149 array( '', array() ), // empty 00150 array( 'foo=bar', array( 'foo' => 'bar' ) ), // string 00151 array( 'foo=', array( 'foo' => '' ) ), // empty string 00152 array( 'foo', array( 'foo' => '' ) ), // missing = 00153 array( 'foo=bar&qwerty=asdf', array( 'foo' => 'bar', 'qwerty' => 'asdf' ) ), // multiple value 00154 array( 'foo=A%26B%3D5%2B6%40%21%22%27', array( 'foo' => 'A&B=5+6@!"\'' ) ), // urldecoding test 00155 array( 'foo%5Bbar%5D=baz', array( 'foo' => array( 'bar' => 'baz' ) ) ), 00156 array( 'foo%5Bbar%5D=baz&foo%5Bqwerty%5D=asdf', array( 'foo' => array( 'bar' => 'baz', 'qwerty' => 'asdf' ) ) ), 00157 array( 'foo%5B0%5D=bar&foo%5B1%5D=baz', array( 'foo' => array( 0 => 'bar', 1 => 'baz' ) ) ), 00158 array( 'foo%5Bbar%5D%5Bbar%5D=baz', array( 'foo' => array( 'bar' => array( 'bar' => 'baz' ) ) ) ), 00159 ); 00160 } 00161 00165 function testCgiToArray( $cgi, $result ) { 00166 $this->assertEquals( $result, wfCgiToArray( $cgi ) ); 00167 } 00168 00169 public static function provideCgiRoundTrip() { 00170 return array( 00171 array( '' ), 00172 array( 'foo=bar' ), 00173 array( 'foo=' ), 00174 array( 'foo=bar&baz=biz' ), 00175 array( 'foo=A%26B%3D5%2B6%40%21%22%27' ), 00176 array( 'foo%5Bbar%5D=baz' ), 00177 array( 'foo%5B0%5D=bar&foo%5B1%5D=baz' ), 00178 array( 'foo%5Bbar%5D%5Bbar%5D=baz' ), 00179 ); 00180 } 00181 00185 function testCgiRoundTrip( $cgi ) { 00186 $this->assertEquals( $cgi, wfArrayToCgi( wfCgiToArray( $cgi ) ) ); 00187 } 00188 00189 function testMimeTypeMatch() { 00190 $this->assertEquals( 00191 'text/html', 00192 mimeTypeMatch( 'text/html', 00193 array( 'application/xhtml+xml' => 1.0, 00194 'text/html' => 0.7, 00195 'text/plain' => 0.3 ) ) ); 00196 $this->assertEquals( 00197 'text/*', 00198 mimeTypeMatch( 'text/html', 00199 array( 'image/*' => 1.0, 00200 'text/*' => 0.5 ) ) ); 00201 $this->assertEquals( 00202 '*/*', 00203 mimeTypeMatch( 'text/html', 00204 array( '*/*' => 1.0 ) ) ); 00205 $this->assertNull( 00206 mimeTypeMatch( 'text/html', 00207 array( 'image/png' => 1.0, 00208 'image/svg+xml' => 0.5 ) ) ); 00209 } 00210 00211 function testNegotiateType() { 00212 $this->assertEquals( 00213 'text/html', 00214 wfNegotiateType( 00215 array( 'application/xhtml+xml' => 1.0, 00216 'text/html' => 0.7, 00217 'text/plain' => 0.5, 00218 'text/*' => 0.2 ), 00219 array( 'text/html' => 1.0 ) ) ); 00220 $this->assertEquals( 00221 'application/xhtml+xml', 00222 wfNegotiateType( 00223 array( 'application/xhtml+xml' => 1.0, 00224 'text/html' => 0.7, 00225 'text/plain' => 0.5, 00226 'text/*' => 0.2 ), 00227 array( 'application/xhtml+xml' => 1.0, 00228 'text/html' => 0.5 ) ) ); 00229 $this->assertEquals( 00230 'text/html', 00231 wfNegotiateType( 00232 array( 'text/html' => 1.0, 00233 'text/plain' => 0.5, 00234 'text/*' => 0.5, 00235 'application/xhtml+xml' => 0.2 ), 00236 array( 'application/xhtml+xml' => 1.0, 00237 'text/html' => 0.5 ) ) ); 00238 $this->assertEquals( 00239 'text/html', 00240 wfNegotiateType( 00241 array( 'text/*' => 1.0, 00242 'image/*' => 0.7, 00243 '*/*' => 0.3 ), 00244 array( 'application/xhtml+xml' => 1.0, 00245 'text/html' => 0.5 ) ) ); 00246 $this->assertNull( 00247 wfNegotiateType( 00248 array( 'text/*' => 1.0 ), 00249 array( 'application/xhtml+xml' => 1.0 ) ) ); 00250 } 00251 00252 function testFallbackMbstringFunctions() { 00253 00254 if ( !extension_loaded( 'mbstring' ) ) { 00255 $this->markTestSkipped( "The mb_string functions must be installed to test the fallback functions" ); 00256 } 00257 00258 $sampleUTF = "Östergötland_coat_of_arms.png"; 00259 00260 00261 //mb_substr 00262 $substr_params = array( 00263 array( 0, 0 ), 00264 array( 5, -4 ), 00265 array( 33 ), 00266 array( 100, -5 ), 00267 array( -8, 10 ), 00268 array( 1, 1 ), 00269 array( 2, -1 ) 00270 ); 00271 00272 foreach ( $substr_params as $param_set ) { 00273 $old_param_set = $param_set; 00274 array_unshift( $param_set, $sampleUTF ); 00275 00276 $this->assertEquals( 00277 MWFunction::callArray( 'mb_substr', $param_set ), 00278 MWFunction::callArray( 'Fallback::mb_substr', $param_set ), 00279 'Fallback mb_substr with params ' . implode( ', ', $old_param_set ) 00280 ); 00281 } 00282 00283 00284 //mb_strlen 00285 $this->assertEquals( 00286 mb_strlen( $sampleUTF ), 00287 Fallback::mb_strlen( $sampleUTF ), 00288 'Fallback mb_strlen' 00289 ); 00290 00291 00292 //mb_str(r?)pos 00293 $strpos_params = array( 00294 //array( 'ter' ), 00295 //array( 'Ö' ), 00296 //array( 'Ö', 3 ), 00297 //array( 'oat_', 100 ), 00298 //array( 'c', -10 ), 00299 //Broken for now 00300 ); 00301 00302 foreach ( $strpos_params as $param_set ) { 00303 $old_param_set = $param_set; 00304 array_unshift( $param_set, $sampleUTF ); 00305 00306 $this->assertEquals( 00307 MWFunction::callArray( 'mb_strpos', $param_set ), 00308 MWFunction::callArray( 'Fallback::mb_strpos', $param_set ), 00309 'Fallback mb_strpos with params ' . implode( ', ', $old_param_set ) 00310 ); 00311 00312 $this->assertEquals( 00313 MWFunction::callArray( 'mb_strrpos', $param_set ), 00314 MWFunction::callArray( 'Fallback::mb_strrpos', $param_set ), 00315 'Fallback mb_strrpos with params ' . implode( ', ', $old_param_set ) 00316 ); 00317 } 00318 00319 } 00320 00321 00322 function testDebugFunctionTest() { 00323 00324 global $wgDebugLogFile, $wgDebugTimestamps; 00325 00326 $old_log_file = $wgDebugLogFile; 00327 $wgDebugLogFile = tempnam( wfTempDir(), 'mw-' ); 00328 # @todo FIXME: $wgDebugTimestamps should be tested 00329 $old_wgDebugTimestamps = $wgDebugTimestamps; 00330 $wgDebugTimestamps = false; 00331 00332 00333 wfDebug( "This is a normal string" ); 00334 $this->assertEquals( "This is a normal string", file_get_contents( $wgDebugLogFile ) ); 00335 unlink( $wgDebugLogFile ); 00336 00337 wfDebug( "This is nöt an ASCII string" ); 00338 $this->assertEquals( "This is nöt an ASCII string", file_get_contents( $wgDebugLogFile ) ); 00339 unlink( $wgDebugLogFile ); 00340 00341 00342 wfDebug( "\00305This has böth UTF and control chars\003" ); 00343 $this->assertEquals( " 05This has böth UTF and control chars ", file_get_contents( $wgDebugLogFile ) ); 00344 unlink( $wgDebugLogFile ); 00345 00346 wfDebugMem(); 00347 $this->assertGreaterThan( 5000, preg_replace( '/\D/', '', file_get_contents( $wgDebugLogFile ) ) ); 00348 unlink( $wgDebugLogFile ); 00349 00350 wfDebugMem( true ); 00351 $this->assertGreaterThan( 5000000, preg_replace( '/\D/', '', file_get_contents( $wgDebugLogFile ) ) ); 00352 unlink( $wgDebugLogFile ); 00353 00354 00355 $wgDebugLogFile = $old_log_file; 00356 $wgDebugTimestamps = $old_wgDebugTimestamps; 00357 } 00358 00359 function testClientAcceptsGzipTest() { 00360 00361 $settings = array( 00362 'gzip' => true, 00363 'bzip' => false, 00364 '*' => false, 00365 'compress, gzip' => true, 00366 'gzip;q=1.0' => true, 00367 'foozip' => false, 00368 'foo*zip' => false, 00369 'gzip;q=abcde' => true, //is this REALLY valid? 00370 'gzip;q=12345678.9' => true, 00371 ' gzip' => true, 00372 ); 00373 00374 if ( isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) { 00375 $old_server_setting = $_SERVER['HTTP_ACCEPT_ENCODING']; 00376 } 00377 00378 foreach ( $settings as $encoding => $expect ) { 00379 $_SERVER['HTTP_ACCEPT_ENCODING'] = $encoding; 00380 00381 $this->assertEquals( $expect, wfClientAcceptsGzip( true ), 00382 "'$encoding' => " . wfBoolToStr( $expect ) ); 00383 } 00384 00385 if ( isset( $old_server_setting ) ) { 00386 $_SERVER['HTTP_ACCEPT_ENCODING'] = $old_server_setting; 00387 } 00388 } 00389 00390 function testSwapVarsTest() { 00391 $var1 = 1; 00392 $var2 = 2; 00393 00394 $this->assertEquals( $var1, 1, 'var1 is set originally' ); 00395 $this->assertEquals( $var2, 2, 'var1 is set originally' ); 00396 00397 swap( $var1, $var2 ); 00398 00399 $this->assertEquals( $var1, 2, 'var1 is swapped' ); 00400 $this->assertEquals( $var2, 1, 'var2 is swapped' ); 00401 00402 } 00403 00404 function testWfPercentTest() { 00405 00406 $pcts = array( 00407 array( 6 / 7, '0.86%', 2, false ), 00408 array( 3 / 3, '1%' ), 00409 array( 22 / 7, '3.14286%', 5 ), 00410 array( 3 / 6, '0.5%' ), 00411 array( 1 / 3, '0%', 0 ), 00412 array( 10 / 3, '0%', -1 ), 00413 array( 3 / 4 / 5, '0.1%', 1 ), 00414 array( 6 / 7 * 8, '6.8571428571%', 10 ), 00415 ); 00416 00417 foreach ( $pcts as $pct ) { 00418 if ( !isset( $pct[2] ) ) { 00419 $pct[2] = 2; 00420 } 00421 if ( !isset( $pct[3] ) ) { 00422 $pct[3] = true; 00423 } 00424 00425 $this->assertEquals( wfPercent( $pct[0], $pct[2], $pct[3] ), $pct[1], $pct[1] ); 00426 } 00427 } 00428 00433 public function testWfShorthandToInteger( $shorthand, $expected ) { 00434 $this->assertEquals( $expected, 00435 wfShorthandToInteger( $shorthand ) 00436 ); 00437 } 00438 00440 public static function provideShorthand() { 00441 return array( 00442 # Null, empty ... 00443 array( '', -1 ), 00444 array( ' ', -1 ), 00445 array( null, -1 ), 00446 00447 # Failures returns 0 :( 00448 array( 'ABCDEFG', 0 ), 00449 array( 'Ak', 0 ), 00450 00451 # Int, strings with spaces 00452 array( 1, 1 ), 00453 array( ' 1 ', 1 ), 00454 array( 1023, 1023 ), 00455 array( ' 1023 ', 1023 ), 00456 00457 # kilo, Mega, Giga 00458 array( '1k', 1024 ), 00459 array( '1K', 1024 ), 00460 array( '1m', 1024 * 1024 ), 00461 array( '1M', 1024 * 1024 ), 00462 array( '1g', 1024 * 1024 * 1024 ), 00463 array( '1G', 1024 * 1024 * 1024 ), 00464 00465 # Negatives 00466 array( -1, -1 ), 00467 array( -500, -500 ), 00468 array( '-500', -500 ), 00469 array( '-1k', -1024 ), 00470 00471 # Zeroes 00472 array( '0', 0 ), 00473 array( '0k', 0 ), 00474 array( '0M', 0 ), 00475 array( '0G', 0 ), 00476 array( '-0', 0 ), 00477 array( '-0k', 0 ), 00478 array( '-0M', 0 ), 00479 array( '-0G', 0 ), 00480 ); 00481 } 00482 00493 public function testMerge( $old, $mine, $yours, $expectedMergeResult, $expectedText ) { 00494 $this->checkHasDiff3(); 00495 00496 $mergedText = null; 00497 $isMerged = wfMerge( $old, $mine, $yours, $mergedText ); 00498 00499 $msg = 'Merge should be a '; 00500 $msg .= $expectedMergeResult ? 'success' : 'failure'; 00501 $this->assertEquals( $expectedMergeResult, $isMerged, $msg ); 00502 00503 if ( $isMerged ) { 00504 // Verify the merged text 00505 $this->assertEquals( $expectedText, $mergedText, 00506 'is merged text as expected?' ); 00507 } 00508 } 00509 00510 public static function provideMerge() { 00511 $EXPECT_MERGE_SUCCESS = true; 00512 $EXPECT_MERGE_FAILURE = false; 00513 00514 return array( 00515 // #0: clean merge 00516 array( 00517 // old: 00518 "one one one\n" . // trimmed 00519 "\n" . 00520 "two two two", 00521 00522 // mine: 00523 "one one one ONE ONE\n" . 00524 "\n" . 00525 "two two two\n", // with tailing whitespace 00526 00527 // yours: 00528 "one one one\n" . 00529 "\n" . 00530 "two two TWO TWO", // trimmed 00531 00532 // ok: 00533 $EXPECT_MERGE_SUCCESS, 00534 00535 // result: 00536 "one one one ONE ONE\n" . 00537 "\n" . 00538 "two two TWO TWO\n", // note: will always end in a newline 00539 ), 00540 00541 // #1: conflict, fail 00542 array( 00543 // old: 00544 "one one one", // trimmed 00545 00546 // mine: 00547 "one one one ONE ONE\n" . 00548 "\n" . 00549 "bla bla\n" . 00550 "\n", // with tailing whitespace 00551 00552 // yours: 00553 "one one one\n" . 00554 "\n" . 00555 "two two", // trimmed 00556 00557 $EXPECT_MERGE_FAILURE, 00558 00559 // result: 00560 null, 00561 ), 00562 ); 00563 } 00564 00568 function testMakeUrlIndexes( $url, $expected ) { 00569 $index = wfMakeUrlIndexes( $url ); 00570 $this->assertEquals( $expected, $index, "wfMakeUrlIndexes(\"$url\")" ); 00571 } 00572 00573 function provideMakeUrlIndexes() { 00574 return array( 00575 array( 00576 // just a regular :) 00577 'https://bugzilla.wikimedia.org/show_bug.cgi?id=28627', 00578 array( 'https://org.wikimedia.bugzilla./show_bug.cgi?id=28627' ) 00579 ), 00580 array( 00581 // mailtos are handled special 00582 // is this really right though? that final . probably belongs earlier? 00583 'mailto:[email protected]', 00584 array( 'mailto:org.wikimedia@wiki.' ) 00585 ), 00586 00587 // file URL cases per bug 28627... 00588 array( 00589 // three slashes: local filesystem path Unix-style 00590 'file:///whatever/you/like.txt', 00591 array( 'file://./whatever/you/like.txt' ) 00592 ), 00593 array( 00594 // three slashes: local filesystem path Windows-style 00595 'file:///c:/whatever/you/like.txt', 00596 array( 'file://./c:/whatever/you/like.txt' ) 00597 ), 00598 array( 00599 // two slashes: UNC filesystem path Windows-style 00600 'file://intranet/whatever/you/like.txt', 00601 array( 'file://intranet./whatever/you/like.txt' ) 00602 ), 00603 // Multiple-slash cases that can sorta work on Mozilla 00604 // if you hack it just right are kinda pathological, 00605 // and unreliable cross-platform or on IE which means they're 00606 // unlikely to appear on intranets. 00607 // 00608 // Those will survive the algorithm but with results that 00609 // are less consistent. 00610 00611 // protocol-relative URL cases per bug 29854... 00612 array( 00613 '//bugzilla.wikimedia.org/show_bug.cgi?id=28627', 00614 array( 00615 'http://org.wikimedia.bugzilla./show_bug.cgi?id=28627', 00616 'https://org.wikimedia.bugzilla./show_bug.cgi?id=28627' 00617 ) 00618 ), 00619 ); 00620 } 00621 00625 function testWfMatchesDomainList( $url, $domains, $expected, $description ) { 00626 $actual = wfMatchesDomainList( $url, $domains ); 00627 $this->assertEquals( $expected, $actual, $description ); 00628 } 00629 00630 function provideWfMatchesDomainList() { 00631 $a = array(); 00632 $protocols = array( 'HTTP' => 'http:', 'HTTPS' => 'https:', 'protocol-relative' => '' ); 00633 foreach ( $protocols as $pDesc => $p ) { 00634 $a = array_merge( $a, array( 00635 array( "$p//www.example.com", array(), false, "No matches for empty domains array, $pDesc URL" ), 00636 array( "$p//www.example.com", array( 'www.example.com' ), true, "Exact match in domains array, $pDesc URL" ), 00637 array( "$p//www.example.com", array( 'example.com' ), true, "Match without subdomain in domains array, $pDesc URL" ), 00638 array( "$p//www.example2.com", array( 'www.example.com', 'www.example2.com', 'www.example3.com' ), true, "Exact match with other domains in array, $pDesc URL" ), 00639 array( "$p//www.example2.com", array( 'example.com', 'example2.com', 'example3,com' ), true, "Match without subdomain with other domains in array, $pDesc URL" ), 00640 array( "$p//www.example4.com", array( 'example.com', 'example2.com', 'example3,com' ), false, "Domain not in array, $pDesc URL" ), 00641 00642 // FIXME: This is a bug in wfMatchesDomainList(). If and when this is fixed, update this test case 00643 array( "$p//nds-nl.wikipedia.org", array( 'nl.wikipedia.org' ), true, "Substrings of domains match while they shouldn't, $pDesc URL" ), 00644 ) ); 00645 } 00646 return $a; 00647 } 00648 00652 function testWfShellMaintenanceCmd( $script, $parameters, $options, $expected, $description ) { 00653 if ( wfIsWindows() ) { 00654 // Approximation that's good enough for our purposes just now 00655 $expected = str_replace( "'", '"', $expected ); 00656 } 00657 $actual = wfShellMaintenanceCmd( $script, $parameters, $options ); 00658 $this->assertEquals( $expected, $actual, $description ); 00659 } 00660 00661 function provideWfShellMaintenanceCmdList() { 00662 global $wgPhpCli; 00663 return array( 00664 array( 'eval.php', array( '--help', '--test' ), array(), 00665 "'$wgPhpCli' 'eval.php' '--help' '--test'", 00666 "Called eval.php --help --test" ), 00667 array( 'eval.php', array( '--help', '--test space' ), array( 'php' => 'php5' ), 00668 "'php5' 'eval.php' '--help' '--test space'", 00669 "Called eval.php --help --test with php option" ), 00670 array( 'eval.php', array( '--help', '--test', 'X' ), array( 'wrapper' => 'MWScript.php' ), 00671 "'$wgPhpCli' 'MWScript.php' 'eval.php' '--help' '--test' 'X'", 00672 "Called eval.php --help --test with wrapper option" ), 00673 array( 'eval.php', array( '--help', '--test', 'y' ), array( 'php' => 'php5', 'wrapper' => 'MWScript.php' ), 00674 "'php5' 'MWScript.php' 'eval.php' '--help' '--test' 'y'", 00675 "Called eval.php --help --test with wrapper and php option" ), 00676 ); 00677 } 00678 /* TODO: many more! */ 00679 }