MediaWiki  REL1_20
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 testExpandIRI() {
00059                 $this->assertEquals(
00060                         "https://te.wikibooks.org/wiki/ఉబుంటు_వాడుకరి_మార్గదర్శని",
00061                         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" ) );
00062         }
00063 
00064         function testReadOnlyEmpty() {
00065                 global $wgReadOnly;
00066                 $wgReadOnly = null;
00067 
00068                 $this->assertFalse( wfReadOnly() );
00069                 $this->assertFalse( wfReadOnly() );
00070         }
00071 
00072         function testReadOnlySet() {
00073                 global $wgReadOnly, $wgReadOnlyFile;
00074 
00075                 $f = fopen( $wgReadOnlyFile, "wt" );
00076                 fwrite( $f, 'Message' );
00077                 fclose( $f );
00078                 $wgReadOnly = null; # Check on $wgReadOnlyFile
00079 
00080                 $this->assertTrue( wfReadOnly() );
00081                 $this->assertTrue( wfReadOnly() ); # Check cached
00082 
00083                 unlink( $wgReadOnlyFile );
00084                 $wgReadOnly = null; # Clean cache
00085 
00086                 $this->assertFalse( wfReadOnly() );
00087                 $this->assertFalse( wfReadOnly() );
00088         }
00089 
00090         function testQuotedPrintable() {
00091                 $this->assertEquals(
00092                         "=?UTF-8?Q?=C4=88u=20legebla=3F?=",
00093                         UserMailer::quotedPrintable( "\xc4\x88u legebla?", "UTF-8" ) );
00094         }
00095 
00096         function testTime() {
00097                 $start = wfTime();
00098                 $this->assertInternalType( 'float', $start );
00099                 $end = wfTime();
00100                 $this->assertTrue( $end > $start, "Time is running backwards!" );
00101         }
00102 
00103         function dataArrayToCGI() {
00104                 return array(
00105                         array( array(), '' ), // empty
00106                         array( array( 'foo' => 'bar' ), 'foo=bar' ), // string test
00107                         array( array( 'foo' => '' ), 'foo=' ), // empty string test
00108                         array( array( 'foo' => 1 ), 'foo=1' ), // number test
00109                         array( array( 'foo' => true ), 'foo=1' ), // true test
00110                         array( array( 'foo' => false ), '' ), // false test
00111                         array( array( 'foo' => null ), '' ), // null test
00112                         array( array( 'foo' => 'A&B=5+6@!"\'' ), 'foo=A%26B%3D5%2B6%40%21%22%27' ), // urlencoding test
00113                         array( array( 'foo' => 'bar', 'baz' => 'is', 'asdf' => 'qwerty' ), 'foo=bar&baz=is&asdf=qwerty' ), // multi-item test
00114                         array( array( 'foo' => array( 'bar' => 'baz' ) ), 'foo%5Bbar%5D=baz' ),
00115                         array( array( 'foo' => array( 'bar' => 'baz', 'qwerty' => 'asdf' ) ), 'foo%5Bbar%5D=baz&foo%5Bqwerty%5D=asdf' ),
00116                         array( array( 'foo' => array( 'bar', 'baz' ) ), 'foo%5B0%5D=bar&foo%5B1%5D=baz' ),
00117                         array( array( 'foo' => array( 'bar' => array( 'bar' => 'baz' ) ) ), 'foo%5Bbar%5D%5Bbar%5D=baz' ),
00118                 );
00119         }
00120 
00124         function testArrayToCGI( $array, $result ) {
00125                 $this->assertEquals( $result, wfArrayToCGI( $array ) );
00126         }
00127 
00128 
00129         function testArrayToCGI2() {
00130                 $this->assertEquals(
00131                         "baz=bar&foo=bar",
00132                         wfArrayToCGI(
00133                                 array( 'baz' => 'bar' ),
00134                                 array( 'foo' => 'bar', 'baz' => 'overridden value' ) ) );
00135         }
00136 
00137         function dataCgiToArray() {
00138                 return array(
00139                         array( '', array() ), // empty
00140                         array( 'foo=bar', array( 'foo' => 'bar' ) ), // string
00141                         array( 'foo=', array( 'foo' => '' ) ), // empty string
00142                         array( 'foo', array( 'foo' => '' ) ), // missing =
00143                         array( 'foo=bar&qwerty=asdf', array( 'foo' => 'bar', 'qwerty' => 'asdf' ) ), // multiple value
00144                         array( 'foo=A%26B%3D5%2B6%40%21%22%27', array( 'foo' => 'A&B=5+6@!"\'' ) ), // urldecoding test
00145                         array( 'foo%5Bbar%5D=baz', array( 'foo' => array( 'bar' => 'baz' ) ) ),
00146                         array( 'foo%5Bbar%5D=baz&foo%5Bqwerty%5D=asdf', array( 'foo' => array( 'bar' => 'baz', 'qwerty' => 'asdf' ) ) ),
00147                         array( 'foo%5B0%5D=bar&foo%5B1%5D=baz', array( 'foo' => array( 0 => 'bar', 1 => 'baz' ) ) ),
00148                         array( 'foo%5Bbar%5D%5Bbar%5D=baz', array( 'foo' => array( 'bar' => array( 'bar' => 'baz' ) ) ) ),
00149                 );
00150         }
00151 
00155         function testCgiToArray( $cgi, $result ) {
00156                 $this->assertEquals( $result, wfCgiToArray( $cgi ) );
00157         }
00158 
00159         function dataCgiRoundTrip() {
00160                 return array(
00161                         array( '' ),
00162                         array( 'foo=bar' ),
00163                         array( 'foo=' ),
00164                         array( 'foo=bar&baz=biz' ),
00165                         array( 'foo=A%26B%3D5%2B6%40%21%22%27' ),
00166                         array( 'foo%5Bbar%5D=baz' ),
00167                         array( 'foo%5B0%5D=bar&foo%5B1%5D=baz' ),
00168                         array( 'foo%5Bbar%5D%5Bbar%5D=baz' ),
00169                 );
00170         }
00171 
00175         function testCgiRoundTrip( $cgi ) {
00176                 $this->assertEquals( $cgi, wfArrayToCGI( wfCgiToArray( $cgi ) ) );
00177         }
00178 
00179         function testMimeTypeMatch() {
00180                 $this->assertEquals(
00181                         'text/html',
00182                         mimeTypeMatch( 'text/html',
00183                                 array( 'application/xhtml+xml' => 1.0,
00184                                        'text/html'             => 0.7,
00185                                        'text/plain'            => 0.3 ) ) );
00186                 $this->assertEquals(
00187                         'text/*',
00188                         mimeTypeMatch( 'text/html',
00189                                 array( 'image/*' => 1.0,
00190                                        'text/*'  => 0.5 ) ) );
00191                 $this->assertEquals(
00192                         '*/*',
00193                         mimeTypeMatch( 'text/html',
00194                                 array( '*/*' => 1.0 ) ) );
00195                 $this->assertNull(
00196                         mimeTypeMatch( 'text/html',
00197                                 array( 'image/png'     => 1.0,
00198                                        'image/svg+xml' => 0.5 ) ) );
00199         }
00200 
00201         function testNegotiateType() {
00202                 $this->assertEquals(
00203                         'text/html',
00204                         wfNegotiateType(
00205                                 array( 'application/xhtml+xml' => 1.0,
00206                                        'text/html'             => 0.7,
00207                                        'text/plain'            => 0.5,
00208                                        'text/*'                => 0.2 ),
00209                                 array( 'text/html'             => 1.0 ) ) );
00210                 $this->assertEquals(
00211                         'application/xhtml+xml',
00212                         wfNegotiateType(
00213                                 array( 'application/xhtml+xml' => 1.0,
00214                                        'text/html'             => 0.7,
00215                                        'text/plain'            => 0.5,
00216                                        'text/*'                => 0.2 ),
00217                                 array( 'application/xhtml+xml' => 1.0,
00218                                        'text/html'             => 0.5 ) ) );
00219                 $this->assertEquals(
00220                         'text/html',
00221                         wfNegotiateType(
00222                                 array( 'text/html'             => 1.0,
00223                                        'text/plain'            => 0.5,
00224                                        'text/*'                => 0.5,
00225                                        'application/xhtml+xml' => 0.2 ),
00226                                 array( 'application/xhtml+xml' => 1.0,
00227                                        'text/html'             => 0.5 ) ) );
00228                 $this->assertEquals(
00229                         'text/html',
00230                         wfNegotiateType(
00231                                 array( 'text/*'                => 1.0,
00232                                        'image/*'               => 0.7,
00233                                        '*/*'                   => 0.3 ),
00234                                 array( 'application/xhtml+xml' => 1.0,
00235                                        'text/html'             => 0.5 ) ) );
00236                 $this->assertNull(
00237                         wfNegotiateType(
00238                                 array( 'text/*'                => 1.0 ),
00239                                 array( 'application/xhtml+xml' => 1.0 ) ) );
00240         }
00241         
00242         function testFallbackMbstringFunctions() {
00243                 
00244                 if( !extension_loaded( 'mbstring' ) ) {
00245                         $this->markTestSkipped( "The mb_string functions must be installed to test the fallback functions" );
00246                 }
00247                 
00248                 $sampleUTF = "Östergötland_coat_of_arms.png";
00249                 
00250                 
00251                 //mb_substr
00252                 $substr_params = array(
00253                         array( 0, 0 ),
00254                         array( 5, -4 ),
00255                         array( 33 ),
00256                         array( 100, -5 ),
00257                         array( -8, 10 ),
00258                         array( 1, 1 ),
00259                         array( 2, -1 )
00260                 );
00261                 
00262                 foreach( $substr_params as $param_set ) {
00263                         $old_param_set = $param_set;
00264                         array_unshift( $param_set, $sampleUTF );
00265                         
00266                         $this->assertEquals(
00267                                 MWFunction::callArray( 'mb_substr', $param_set ),
00268                                 MWFunction::callArray( 'Fallback::mb_substr', $param_set ),
00269                                 'Fallback mb_substr with params ' . implode( ', ', $old_param_set )
00270                         );                      
00271                 }
00272                 
00273                 
00274                 //mb_strlen
00275                 $this->assertEquals(
00276                         mb_strlen( $sampleUTF ),
00277                         Fallback::mb_strlen( $sampleUTF ),
00278                         'Fallback mb_strlen'
00279                 );                      
00280                 
00281                 
00282                 //mb_str(r?)pos
00283                 $strpos_params = array(
00284                         //array( 'ter' ),
00285                         //array( 'Ö' ),
00286                         //array( 'Ö', 3 ),
00287                         //array( 'oat_', 100 ),
00288                         //array( 'c', -10 ),
00289                         //Broken for now
00290                 );
00291                 
00292                 foreach( $strpos_params as $param_set ) {
00293                         $old_param_set = $param_set;
00294                         array_unshift( $param_set, $sampleUTF );
00295                         
00296                         $this->assertEquals(
00297                                 MWFunction::callArray( 'mb_strpos', $param_set ),
00298                                 MWFunction::callArray( 'Fallback::mb_strpos', $param_set ),
00299                                 'Fallback mb_strpos with params ' . implode( ', ', $old_param_set )
00300                         );              
00301                         
00302                         $this->assertEquals(
00303                                 MWFunction::callArray( 'mb_strrpos', $param_set ),
00304                                 MWFunction::callArray( 'Fallback::mb_strrpos', $param_set ),
00305                                 'Fallback mb_strrpos with params ' . implode( ', ', $old_param_set )
00306                         );      
00307                 }
00308                 
00309         }
00310         
00311         
00312         function testDebugFunctionTest() {
00313         
00314                 global $wgDebugLogFile, $wgDebugTimestamps;
00315                 
00316                 $old_log_file = $wgDebugLogFile;
00317                 $wgDebugLogFile = tempnam( wfTempDir(), 'mw-' );
00318                 # @todo FIXME: This setting should be tested
00319                 $wgDebugTimestamps = false;
00320                 
00321                 
00322                 
00323                 wfDebug( "This is a normal string" );
00324                 $this->assertEquals( "This is a normal string", file_get_contents( $wgDebugLogFile ) );
00325                 unlink( $wgDebugLogFile );
00326                 
00327                 
00328                 wfDebug( "This is nöt an ASCII string" );
00329                 $this->assertEquals( "This is nöt an ASCII string", file_get_contents( $wgDebugLogFile ) );
00330                 unlink( $wgDebugLogFile );
00331                 
00332                 
00333                 wfDebug( "\00305This has böth UTF and control chars\003" );
00334                 $this->assertEquals( " 05This has böth UTF and control chars ", file_get_contents( $wgDebugLogFile ) );
00335                 unlink( $wgDebugLogFile );
00336 
00337                 wfDebugMem();
00338                 $this->assertGreaterThan( 5000, preg_replace( '/\D/', '', file_get_contents( $wgDebugLogFile ) ) );
00339                 unlink( $wgDebugLogFile );
00340                 
00341                 wfDebugMem(true);
00342                 $this->assertGreaterThan( 5000000, preg_replace( '/\D/', '', file_get_contents( $wgDebugLogFile ) ) );
00343                 unlink( $wgDebugLogFile );
00344                 
00345                 
00346                 
00347                 $wgDebugLogFile = $old_log_file;
00348                 
00349         }
00350         
00351         function testClientAcceptsGzipTest() {
00352                 
00353                 $settings = array(
00354                         'gzip' => true,
00355                         'bzip' => false,
00356                         '*' => false,
00357                         'compress, gzip' => true,
00358                         'gzip;q=1.0' => true,
00359                         'foozip' => false,
00360                         'foo*zip' => false,
00361                         'gzip;q=abcde' => true, //is this REALLY valid?
00362                         'gzip;q=12345678.9' => true,
00363                         ' gzip' => true,
00364                 );
00365                 
00366                 if( isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) $old_server_setting = $_SERVER['HTTP_ACCEPT_ENCODING'];
00367                 
00368                 foreach ( $settings as $encoding => $expect ) {
00369                         $_SERVER['HTTP_ACCEPT_ENCODING'] = $encoding;
00370                         
00371                         $this->assertEquals( $expect, wfClientAcceptsGzip( true ),
00372                                 "'$encoding' => " . wfBoolToStr( $expect ) );
00373                 }
00374                 
00375                 if( isset( $old_server_setting ) ) $_SERVER['HTTP_ACCEPT_ENCODING'] = $old_server_setting;
00376 
00377         }
00378         
00379         
00380         
00381         function testSwapVarsTest() {
00382         
00383 
00384                 $var1 = 1;
00385                 $var2 = 2;
00386 
00387                 $this->assertEquals( $var1, 1, 'var1 is set originally' );
00388                 $this->assertEquals( $var2, 2, 'var1 is set originally' );
00389 
00390                 swap( $var1, $var2 );
00391 
00392                 $this->assertEquals( $var1, 2, 'var1 is swapped' );
00393                 $this->assertEquals( $var2, 1, 'var2 is swapped' );
00394 
00395         }
00396 
00397 
00398         function testWfPercentTest() {
00399 
00400                 $pcts = array(
00401                         array( 6/7, '0.86%', 2, false ),
00402                         array( 3/3, '1%' ),
00403                         array( 22/7, '3.14286%', 5 ),
00404                         array( 3/6, '0.5%' ),
00405                         array( 1/3, '0%', 0 ),
00406                         array( 10/3, '0%', -1 ),
00407                         array( 3/4/5, '0.1%', 1 ),
00408                         array( 6/7*8, '6.8571428571%', 10 ),
00409                 );
00410                 
00411                 foreach( $pcts as $pct ) {
00412                         if( !isset( $pct[2] ) ) $pct[2] = 2;
00413                         if( !isset( $pct[3] ) ) $pct[3] = true;
00414                         
00415                         $this->assertEquals( wfPercent( $pct[0], $pct[2], $pct[3] ), $pct[1], $pct[1] );
00416                 }
00417 
00418         }
00419 
00420 
00421         function testInStringTest() {
00422         
00423                 $this->assertTrue( in_string( 'foo', 'foobar' ), 'foo is in foobar' );
00424                 $this->assertFalse( in_string( 'Bar', 'foobar' ), 'Case-sensitive by default' );
00425                 $this->assertTrue( in_string( 'Foo', 'foobar', true ), 'Case-insensitive when asked' );
00426         
00427         }
00428 
00433         public function testWfShorthandToInteger( $shorthand, $expected ) {
00434                 $this->assertEquals( $expected,
00435                         wfShorthandToInteger( $shorthand )
00436                 );      
00437         }
00438 
00440         public 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 
00486         function testMakeUrlIndexes( $url, $expected ) {
00487                 $index = wfMakeUrlIndexes( $url );
00488                 $this->assertEquals( $expected, $index, "wfMakeUrlIndexes(\"$url\")" );
00489         }
00490 
00491         function provideMakeUrlIndexes() {
00492                 return array(
00493                         array(
00494                                 // just a regular :)
00495                                 'https://bugzilla.wikimedia.org/show_bug.cgi?id=28627',
00496                                 array( 'https://org.wikimedia.bugzilla./show_bug.cgi?id=28627' )
00497                         ),
00498                         array(
00499                                 // mailtos are handled special
00500                                 // is this really right though? that final . probably belongs earlier?
00501                                 'mailto:[email protected]',
00502                                 array( 'mailto:org.wikimedia@wiki.' )
00503                         ),
00504 
00505                         // file URL cases per bug 28627...
00506                         array(
00507                                 // three slashes: local filesystem path Unix-style
00508                                 'file:///whatever/you/like.txt',
00509                                 array( 'file://./whatever/you/like.txt' )
00510                         ),
00511                         array(
00512                                 // three slashes: local filesystem path Windows-style
00513                                 'file:///c:/whatever/you/like.txt',
00514                                 array( 'file://./c:/whatever/you/like.txt' )
00515                         ),
00516                         array(
00517                                 // two slashes: UNC filesystem path Windows-style
00518                                 'file://intranet/whatever/you/like.txt',
00519                                 array( 'file://intranet./whatever/you/like.txt' )
00520                         ),
00521                         // Multiple-slash cases that can sorta work on Mozilla
00522                         // if you hack it just right are kinda pathological,
00523                         // and unreliable cross-platform or on IE which means they're
00524                         // unlikely to appear on intranets.
00525                         //
00526                         // Those will survive the algorithm but with results that
00527                         // are less consistent.
00528 
00529                         // protocol-relative URL cases per bug 29854...
00530                         array(
00531                                 '//bugzilla.wikimedia.org/show_bug.cgi?id=28627',
00532                                 array(
00533                                         'http://org.wikimedia.bugzilla./show_bug.cgi?id=28627',
00534                                         'https://org.wikimedia.bugzilla./show_bug.cgi?id=28627'
00535                                 )
00536                         ),
00537                 );
00538         }
00539         
00543         function testWfMatchesDomainList( $url, $domains, $expected, $description ) {
00544                 $actual = wfMatchesDomainList( $url, $domains );
00545                 $this->assertEquals( $expected, $actual, $description );
00546         }
00547         
00548         function provideWfMatchesDomainList() {
00549                 $a = array();
00550                 $protocols = array( 'HTTP' => 'http:', 'HTTPS' => 'https:', 'protocol-relative' => '' );
00551                 foreach ( $protocols as $pDesc => $p ) {
00552                         $a = array_merge( $a, array(
00553                                 array( "$p//www.example.com", array(), false, "No matches for empty domains array, $pDesc URL" ),
00554                                 array( "$p//www.example.com", array( 'www.example.com' ), true, "Exact match in domains array, $pDesc URL" ),
00555                                 array( "$p//www.example.com", array( 'example.com' ), true, "Match without subdomain in domains array, $pDesc URL" ),
00556                                 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" ),
00557                                 array( "$p//www.example2.com", array( 'example.com', 'example2.com', 'example3,com' ), true, "Match without subdomain with other domains in array, $pDesc URL" ),
00558                                 array( "$p//www.example4.com", array( 'example.com', 'example2.com', 'example3,com' ), false, "Domain not in array, $pDesc URL" ),
00559                                 
00560                                 // FIXME: This is a bug in wfMatchesDomainList(). If and when this is fixed, update this test case
00561                                 array( "$p//nds-nl.wikipedia.org", array( 'nl.wikipedia.org' ), true, "Substrings of domains match while they shouldn't, $pDesc URL" ),
00562                         ) );
00563                 }
00564                 return $a;
00565         }
00566 
00570         function testWfShellMaintenanceCmd( $script, $parameters, $options, $expected, $description ) {
00571                 if( wfIsWindows() ) {
00572                         // Approximation that's good enough for our purposes just now
00573                         $expected = str_replace( "'", '"', $expected );
00574                 }
00575                 $actual = wfShellMaintenanceCmd( $script, $parameters, $options );
00576                 $this->assertEquals( $expected, $actual, $description );
00577         }
00578 
00579         function provideWfShellMaintenanceCmdList() {
00580                 global $wgPhpCli;
00581                 return array(
00582                         array( 'eval.php', array( '--help', '--test' ), array(),
00583                                 "'$wgPhpCli' 'eval.php' '--help' '--test'",
00584                                 "Called eval.php --help --test" ),
00585                         array( 'eval.php', array( '--help', '--test space' ), array('php' => 'php5'),
00586                                 "'php5' 'eval.php' '--help' '--test space'",
00587                                 "Called eval.php --help --test with php option" ),
00588                         array( 'eval.php', array( '--help', '--test', 'X' ), array('wrapper' => 'MWScript.php'),
00589                                 "'$wgPhpCli' 'MWScript.php' 'eval.php' '--help' '--test' 'X'",
00590                                 "Called eval.php --help --test with wrapper option" ),
00591                         array( 'eval.php', array( '--help', '--test', 'y' ), array('php' => 'php5', 'wrapper' => 'MWScript.php'),
00592                                 "'php5' 'MWScript.php' 'eval.php' '--help' '--test' 'y'",
00593                                 "Called eval.php --help --test with wrapper and php option" ),
00594                 );
00595         }
00596         /* TODO: many more! */
00597 }
00598