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