2010-12-14 16:26:35 +00:00
< ? php
2010-12-28 18:17:16 +00:00
class GlobalTest extends MediaWikiTestCase {
2010-12-14 16:26:35 +00:00
function setUp () {
2011-07-19 21:05:17 +00:00
global $wgReadOnlyFile , $wgUrlProtocols ;
2010-12-14 16:26:35 +00:00
$this -> originals [ 'wgReadOnlyFile' ] = $wgReadOnlyFile ;
2011-04-25 21:00:49 +00:00
$this -> originals [ 'wgUrlProtocols' ] = $wgUrlProtocols ;
2010-12-14 16:26:35 +00:00
$wgReadOnlyFile = tempnam ( wfTempDir (), " mwtest_readonly " );
2011-04-25 21:00:49 +00:00
$wgUrlProtocols [] = 'file://' ;
2010-12-14 16:26:35 +00:00
unlink ( $wgReadOnlyFile );
}
function tearDown () {
2011-04-25 21:00:49 +00:00
global $wgReadOnlyFile , $wgUrlProtocols ;
2010-12-14 16:26:35 +00:00
if ( file_exists ( $wgReadOnlyFile ) ) {
unlink ( $wgReadOnlyFile );
}
$wgReadOnlyFile = $this -> originals [ 'wgReadOnlyFile' ];
2011-04-25 21:00:49 +00:00
$wgUrlProtocols = $this -> originals [ 'wgUrlProtocols' ];
2010-12-14 16:26:35 +00:00
}
2011-02-06 13:59:06 +00:00
/** @dataProvider provideForWfArrayDiff2 */
public function testWfArrayDiff2 ( $a , $b , $expected ) {
$this -> assertEquals (
wfArrayDiff2 ( $a , $b ), $expected
);
}
// @todo Provide more tests
public function provideForWfArrayDiff2 () {
// $a $b $expected
return array (
array (
array ( 'a' , 'b' ),
array ( 'a' , 'b' ),
array (),
),
array (
array ( array ( 'a' ), array ( 'a' , 'b' , 'c' )),
array ( array ( 'a' ), array ( 'a' , 'b' )),
array ( 1 => array ( 'a' , 'b' , 'c' ) ),
),
);
}
2010-12-14 16:26:35 +00:00
function testRandom () {
# This could hypothetically fail, but it shouldn't ;)
$this -> assertFalse (
wfRandom () == wfRandom () );
}
function testUrlencode () {
$this -> assertEquals (
" %E7%89%B9%E5%88%A5:Contributions/Foobar " ,
wfUrlencode ( " \xE7 \x89 \xB9 \xE5 \x88 \xA5 :Contributions/Foobar " ) );
}
function testReadOnlyEmpty () {
global $wgReadOnly ;
$wgReadOnly = null ;
$this -> assertFalse ( wfReadOnly () );
$this -> assertFalse ( wfReadOnly () );
}
function testReadOnlySet () {
global $wgReadOnly , $wgReadOnlyFile ;
$f = fopen ( $wgReadOnlyFile , " wt " );
fwrite ( $f , 'Message' );
fclose ( $f );
2010-12-24 12:08:47 +00:00
$wgReadOnly = null ; # Check on $wgReadOnlyFile
2010-12-14 16:26:35 +00:00
$this -> assertTrue ( wfReadOnly () );
2010-12-24 12:08:47 +00:00
$this -> assertTrue ( wfReadOnly () ); # Check cached
2010-12-14 16:26:35 +00:00
unlink ( $wgReadOnlyFile );
2010-12-24 12:08:47 +00:00
$wgReadOnly = null ; # Clean cache
2010-12-14 16:26:35 +00:00
$this -> assertFalse ( wfReadOnly () );
$this -> assertFalse ( wfReadOnly () );
}
function testQuotedPrintable () {
$this -> assertEquals (
" =?UTF-8?Q?=C4=88u=20legebla=3F?= " ,
UserMailer :: quotedPrintable ( " \xc4 \x88 u legebla? " , " UTF-8 " ) );
}
function testTime () {
$start = wfTime ();
2010-12-28 15:13:42 +00:00
$this -> assertInternalType ( 'float' , $start );
2010-12-14 16:26:35 +00:00
$end = wfTime ();
$this -> assertTrue ( $end > $start , " Time is running backwards! " );
}
2012-01-05 00:26:13 +00:00
function dataArrayToCGI () {
return array (
array ( array (), '' ), // empty
array ( array ( 'foo' => 'bar' ), 'foo=bar' ), // string test
array ( array ( 'foo' => '' ), 'foo=' ), // empty string test
array ( array ( 'foo' => 1 ), 'foo=1' ), // number test
array ( array ( 'foo' => true ), 'foo=1' ), // true test
array ( array ( 'foo' => false ), '' ), // false test
array ( array ( 'foo' => null ), '' ), // null test
array ( array ( 'foo' => 'A&B=5+6@!"\'' ), 'foo=A%26B%3D5%2B6%40%21%22%27' ), // urlencoding test
array ( array ( 'foo' => 'bar' , 'baz' => 'is' , 'asdf' => 'qwerty' ), 'foo=bar&baz=is&asdf=qwerty' ), // multi-item test
array ( array ( 'foo' => array ( 'bar' => 'baz' ) ), 'foo%5Bbar%5D=baz' ),
array ( array ( 'foo' => array ( 'bar' => 'baz' , 'qwerty' => 'asdf' ) ), 'foo%5Bbar%5D=baz&foo%5Bqwerty%5D=asdf' ),
array ( array ( 'foo' => array ( 'bar' , 'baz' ) ), 'foo%5B0%5D=bar&foo%5B1%5D=baz' ),
array ( array ( 'foo' => array ( 'bar' => array ( 'bar' => 'baz' ) ) ), 'foo%5Bbar%5D%5Bbar%5D=baz' ),
);
}
/**
* @ dataProvider dataArrayToCGI
*/
function testArrayToCGI ( $array , $result ) {
$this -> assertEquals ( $result , wfArrayToCGI ( $array ) );
}
function testArrayToCGI2 () {
2010-12-14 16:26:35 +00:00
$this -> assertEquals (
2012-01-05 00:26:13 +00:00
" baz=bar&foo=bar " ,
2010-12-14 16:26:35 +00:00
wfArrayToCGI (
2012-01-05 00:26:13 +00:00
array ( 'baz' => 'bar' ),
2010-12-14 16:26:35 +00:00
array ( 'foo' => 'bar' , 'baz' => 'overridden value' ) ) );
2011-06-23 15:25:07 +00:00
}
2012-01-05 00:26:13 +00:00
function dataCgiToArray () {
return array (
array ( '' , array () ), // empty
array ( 'foo=bar' , array ( 'foo' => 'bar' ) ), // string
array ( 'foo=' , array ( 'foo' => '' ) ), // empty string
array ( 'foo' , array ( 'foo' => '' ) ), // missing =
array ( 'foo=bar&qwerty=asdf' , array ( 'foo' => 'bar' , 'qwerty' => 'asdf' ) ), // multiple value
array ( 'foo=A%26B%3D5%2B6%40%21%22%27' , array ( 'foo' => 'A&B=5+6@!"\'' ) ), // urldecoding test
array ( 'foo%5Bbar%5D=baz' , array ( 'foo' => array ( 'bar' => 'baz' ) ) ),
array ( 'foo%5Bbar%5D=baz&foo%5Bqwerty%5D=asdf' , array ( 'foo' => array ( 'bar' => 'baz' , 'qwerty' => 'asdf' ) ) ),
array ( 'foo%5B0%5D=bar&foo%5B1%5D=baz' , array ( 'foo' => array ( 0 => 'bar' , 1 => 'baz' ) ) ),
array ( 'foo%5Bbar%5D%5Bbar%5D=baz' , array ( 'foo' => array ( 'bar' => array ( 'bar' => 'baz' ) ) ) ),
);
}
/**
* @ dataProvider dataCgiToArray
*/
function testCgiToArray ( $cgi , $result ) {
$this -> assertEquals ( $result , wfCgiToArray ( $cgi ) );
}
function dataCgiRoundTrip () {
return array (
array ( '' ),
array ( 'foo=bar' ),
array ( 'foo=' ),
array ( 'foo=bar&baz=biz' ),
array ( 'foo=A%26B%3D5%2B6%40%21%22%27' ),
array ( 'foo%5Bbar%5D=baz' ),
array ( 'foo%5B0%5D=bar&foo%5B1%5D=baz' ),
array ( 'foo%5Bbar%5D%5Bbar%5D=baz' ),
);
}
/**
* @ dataProvider dataCgiRoundTrip
*/
function testCgiRoundTrip ( $cgi ) {
$this -> assertEquals ( $cgi , wfArrayToCGI ( wfCgiToArray ( $cgi ) ) );
2010-12-14 16:26:35 +00:00
}
function testMimeTypeMatch () {
$this -> assertEquals (
'text/html' ,
mimeTypeMatch ( 'text/html' ,
array ( 'application/xhtml+xml' => 1.0 ,
'text/html' => 0.7 ,
'text/plain' => 0.3 ) ) );
$this -> assertEquals (
'text/*' ,
mimeTypeMatch ( 'text/html' ,
array ( 'image/*' => 1.0 ,
'text/*' => 0.5 ) ) );
$this -> assertEquals (
'*/*' ,
mimeTypeMatch ( 'text/html' ,
array ( '*/*' => 1.0 ) ) );
$this -> assertNull (
mimeTypeMatch ( 'text/html' ,
array ( 'image/png' => 1.0 ,
'image/svg+xml' => 0.5 ) ) );
}
function testNegotiateType () {
$this -> assertEquals (
'text/html' ,
wfNegotiateType (
array ( 'application/xhtml+xml' => 1.0 ,
'text/html' => 0.7 ,
'text/plain' => 0.5 ,
'text/*' => 0.2 ),
array ( 'text/html' => 1.0 ) ) );
$this -> assertEquals (
'application/xhtml+xml' ,
wfNegotiateType (
array ( 'application/xhtml+xml' => 1.0 ,
'text/html' => 0.7 ,
'text/plain' => 0.5 ,
'text/*' => 0.2 ),
array ( 'application/xhtml+xml' => 1.0 ,
'text/html' => 0.5 ) ) );
$this -> assertEquals (
'text/html' ,
wfNegotiateType (
array ( 'text/html' => 1.0 ,
'text/plain' => 0.5 ,
'text/*' => 0.5 ,
'application/xhtml+xml' => 0.2 ),
array ( 'application/xhtml+xml' => 1.0 ,
'text/html' => 0.5 ) ) );
$this -> assertEquals (
'text/html' ,
wfNegotiateType (
array ( 'text/*' => 1.0 ,
'image/*' => 0.7 ,
'*/*' => 0.3 ),
array ( 'application/xhtml+xml' => 1.0 ,
'text/html' => 0.5 ) ) );
$this -> assertNull (
wfNegotiateType (
array ( 'text/*' => 1.0 ),
array ( 'application/xhtml+xml' => 1.0 ) ) );
}
2011-01-02 01:51:44 +00:00
function testFallbackMbstringFunctions () {
if ( ! extension_loaded ( 'mbstring' ) ) {
$this -> markTestSkipped ( " The mb_string functions must be installed to test the fallback functions " );
}
$sampleUTF = " Östergötland_coat_of_arms.png " ;
//mb_substr
$substr_params = array (
array ( 0 , 0 ),
array ( 5 , - 4 ),
array ( 33 ),
array ( 100 , - 5 ),
array ( - 8 , 10 ),
array ( 1 , 1 ),
array ( 2 , - 1 )
);
foreach ( $substr_params as $param_set ) {
$old_param_set = $param_set ;
array_unshift ( $param_set , $sampleUTF );
$this -> assertEquals (
2011-01-04 01:51:48 +00:00
MWFunction :: callArray ( 'mb_substr' , $param_set ),
MWFunction :: callArray ( 'Fallback::mb_substr' , $param_set ),
2011-01-02 01:51:44 +00:00
'Fallback mb_substr with params ' . implode ( ', ' , $old_param_set )
);
}
//mb_strlen
$this -> assertEquals (
mb_strlen ( $sampleUTF ),
2011-01-04 01:44:11 +00:00
Fallback :: mb_strlen ( $sampleUTF ),
2011-01-02 01:51:44 +00:00
'Fallback mb_strlen'
);
//mb_str(r?)pos
$strpos_params = array (
//array( 'ter' ),
//array( 'Ö' ),
//array( 'Ö', 3 ),
//array( 'oat_', 100 ),
//array( 'c', -10 ),
//Broken for now
);
foreach ( $strpos_params as $param_set ) {
$old_param_set = $param_set ;
array_unshift ( $param_set , $sampleUTF );
$this -> assertEquals (
2011-01-04 01:51:48 +00:00
MWFunction :: callArray ( 'mb_strpos' , $param_set ),
MWFunction :: callArray ( 'Fallback::mb_strpos' , $param_set ),
2011-01-02 01:51:44 +00:00
'Fallback mb_strpos with params ' . implode ( ', ' , $old_param_set )
);
$this -> assertEquals (
2011-01-04 01:51:48 +00:00
MWFunction :: callArray ( 'mb_strrpos' , $param_set ),
MWFunction :: callArray ( 'Fallback::mb_strrpos' , $param_set ),
2011-01-02 01:51:44 +00:00
'Fallback mb_strrpos with params ' . implode ( ', ' , $old_param_set )
);
}
}
2011-01-02 01:59:52 +00:00
function testDebugFunctionTest () {
2011-01-02 02:16:32 +00:00
2011-02-20 17:44:37 +00:00
global $wgDebugLogFile , $wgOut , $wgShowDebug , $wgDebugTimestamps ;
2011-01-02 01:59:52 +00:00
$old_log_file = $wgDebugLogFile ;
$wgDebugLogFile = tempnam ( wfTempDir (), 'mw-' );
2011-05-17 22:03:20 +00:00
# @todo FIXME: This setting should be tested
$wgDebugTimestamps = false ;
2011-01-02 01:59:52 +00:00
2011-01-02 02:16:32 +00:00
2011-01-02 01:59:52 +00:00
wfDebug ( " This is a normal string " );
$this -> assertEquals ( " This is a normal string " , file_get_contents ( $wgDebugLogFile ) );
unlink ( $wgDebugLogFile );
2011-01-02 02:16:32 +00:00
2011-01-02 01:59:52 +00:00
wfDebug ( " This is nöt an ASCII string " );
$this -> assertEquals ( " This is nöt an ASCII string " , file_get_contents ( $wgDebugLogFile ) );
unlink ( $wgDebugLogFile );
2011-01-02 02:16:32 +00:00
2011-01-02 01:59:52 +00:00
wfDebug ( " \003 05This has böth UTF and control chars \003 " );
$this -> assertEquals ( " 05This has böth UTF and control chars " , file_get_contents ( $wgDebugLogFile ) );
unlink ( $wgDebugLogFile );
2011-01-02 02:16:32 +00:00
$old_wgOut = $wgOut ;
$old_wgShowDebug = $wgShowDebug ;
2011-05-23 17:53:31 +00:00
$wgOut = new MockOutputPage ;
2011-01-02 02:16:32 +00:00
$wgShowDebug = true ;
$message = " \003 05This has böth UTF and control chars \003 " ;
wfDebug ( $message );
if ( $wgOut -> message == " JAJA is a stupid error message. Anyway, here's your message: $message " ) {
$this -> assertTrue ( true , 'MockOutputPage called, set the proper message.' );
}
else {
$this -> assertTrue ( false , 'MockOutputPage was not called.' );
}
2011-01-02 02:33:07 +00:00
$wgOut = $old_wgOut ;
$wgShowDebug = $old_wgShowDebug ;
2011-01-02 02:16:32 +00:00
unlink ( $wgDebugLogFile );
2011-01-02 02:33:07 +00:00
wfDebugMem ();
$this -> assertGreaterThan ( 5000 , preg_replace ( '/\D/' , '' , file_get_contents ( $wgDebugLogFile ) ) );
unlink ( $wgDebugLogFile );
wfDebugMem ( true );
$this -> assertGreaterThan ( 5000000 , preg_replace ( '/\D/' , '' , file_get_contents ( $wgDebugLogFile ) ) );
unlink ( $wgDebugLogFile );
2011-01-02 02:16:32 +00:00
2011-01-02 01:59:52 +00:00
$wgDebugLogFile = $old_log_file ;
}
2011-01-02 04:38:04 +00:00
function testClientAcceptsGzipTest () {
$settings = array (
'gzip' => true ,
'bzip' => false ,
'*' => false ,
'compress, gzip' => true ,
'gzip;q=1.0' => true ,
'foozip' => false ,
'foo*zip' => false ,
'gzip;q=abcde' => true , //is this REALLY valid?
'gzip;q=12345678.9' => true ,
' gzip' => true ,
);
if ( isset ( $_SERVER [ 'HTTP_ACCEPT_ENCODING' ] ) ) $old_server_setting = $_SERVER [ 'HTTP_ACCEPT_ENCODING' ];
foreach ( $settings as $encoding => $expect ) {
$_SERVER [ 'HTTP_ACCEPT_ENCODING' ] = $encoding ;
$this -> assertEquals ( $expect , wfClientAcceptsGzip ( true ),
" ' $encoding ' => " . wfBoolToStr ( $expect ) );
}
if ( isset ( $old_server_setting ) ) $_SERVER [ 'HTTP_ACCEPT_ENCODING' ] = $old_server_setting ;
}
function testSwapVarsTest () {
$var1 = 1 ;
$var2 = 2 ;
$this -> assertEquals ( $var1 , 1 , 'var1 is set originally' );
$this -> assertEquals ( $var2 , 2 , 'var1 is set originally' );
swap ( $var1 , $var2 );
$this -> assertEquals ( $var1 , 2 , 'var1 is swapped' );
$this -> assertEquals ( $var2 , 1 , 'var2 is swapped' );
}
function testWfPercentTest () {
$pcts = array (
array ( 6 / 7 , '0.86%' , 2 , false ),
array ( 3 / 3 , '1%' ),
array ( 22 / 7 , '3.14286%' , 5 ),
array ( 3 / 6 , '0.5%' ),
array ( 1 / 3 , '0%' , 0 ),
array ( 10 / 3 , '0%' , - 1 ),
array ( 3 / 4 / 5 , '0.1%' , 1 ),
array ( 6 / 7 * 8 , '6.8571428571%' , 10 ),
);
foreach ( $pcts as $pct ) {
if ( ! isset ( $pct [ 2 ] ) ) $pct [ 2 ] = 2 ;
if ( ! isset ( $pct [ 3 ] ) ) $pct [ 3 ] = true ;
$this -> assertEquals ( wfPercent ( $pct [ 0 ], $pct [ 2 ], $pct [ 3 ] ), $pct [ 1 ], $pct [ 1 ] );
}
}
function testInStringTest () {
$this -> assertTrue ( in_string ( 'foo' , 'foobar' ), 'foo is in foobar' );
$this -> assertFalse ( in_string ( 'Bar' , 'foobar' ), 'Case-sensitive by default' );
$this -> assertTrue ( in_string ( 'Foo' , 'foobar' , true ), 'Case-insensitive when asked' );
}
2010-12-14 16:26:35 +00:00
2011-02-06 18:02:47 +00:00
/**
* test @ see wfShorthandToInteger ()
* @ dataProvider provideShorthand
*/
public function testWfShorthandToInteger ( $shorthand , $expected ) {
$this -> assertEquals ( $expected ,
wfShorthandToInteger ( $shorthand )
);
}
/** array( shorthand, expected integer ) */
public function provideShorthand () {
return array (
# Null, empty ...
array ( '' , - 1 ),
array ( ' ' , - 1 ),
array ( null , - 1 ),
# Failures returns 0 :(
array ( 'ABCDEFG' , 0 ),
array ( 'Ak' , 0 ),
# Int, strings with spaces
array ( 1 , 1 ),
array ( ' 1 ' , 1 ),
array ( 1023 , 1023 ),
array ( ' 1023 ' , 1023 ),
# kilo, Mega, Giga
array ( '1k' , 1024 ),
array ( '1K' , 1024 ),
array ( '1m' , 1024 * 1024 ),
array ( '1M' , 1024 * 1024 ),
array ( '1g' , 1024 * 1024 * 1024 ),
array ( '1G' , 1024 * 1024 * 1024 ),
# Negatives
array ( - 1 , - 1 ),
array ( - 500 , - 500 ),
array ( '-500' , - 500 ),
array ( '-1k' , - 1024 ),
# Zeroes
array ( '0' , 0 ),
array ( '0k' , 0 ),
array ( '0M' , 0 ),
array ( '0G' , 0 ),
array ( '-0' , 0 ),
array ( '-0k' , 0 ),
array ( '-0M' , 0 ),
array ( '-0G' , 0 ),
);
}
2011-04-25 21:00:49 +00:00
/**
2011-11-14 09:13:58 +00:00
* @ dataProvider provideMakeUrlIndexes ()
2011-04-25 21:00:49 +00:00
*/
2011-11-14 09:13:58 +00:00
function testMakeUrlIndexes ( $url , $expected ) {
$index = wfMakeUrlIndexes ( $url );
$this -> assertEquals ( $expected , $index , " wfMakeUrlIndexes( \" $url\ " ) " );
2011-04-25 21:00:49 +00:00
}
2011-11-14 09:13:58 +00:00
function provideMakeUrlIndexes () {
2011-04-25 21:00:49 +00:00
return array (
array (
// just a regular :)
'https://bugzilla.wikimedia.org/show_bug.cgi?id=28627' ,
2011-11-14 09:13:58 +00:00
array ( 'https://org.wikimedia.bugzilla./show_bug.cgi?id=28627' )
2011-04-25 21:00:49 +00:00
),
array (
// mailtos are handled special
// is this really right though? that final . probably belongs earlier?
'mailto:wiki@wikimedia.org' ,
2011-11-14 09:13:58 +00:00
array ( 'mailto:org.wikimedia@wiki.' )
2011-04-25 21:00:49 +00:00
),
// file URL cases per bug 28627...
array (
// three slashes: local filesystem path Unix-style
'file:///whatever/you/like.txt' ,
2011-11-14 09:13:58 +00:00
array ( 'file://./whatever/you/like.txt' )
2011-04-25 21:00:49 +00:00
),
array (
// three slashes: local filesystem path Windows-style
'file:///c:/whatever/you/like.txt' ,
2011-11-14 09:13:58 +00:00
array ( 'file://./c:/whatever/you/like.txt' )
2011-04-25 21:00:49 +00:00
),
array (
// two slashes: UNC filesystem path Windows-style
'file://intranet/whatever/you/like.txt' ,
2011-11-14 09:13:58 +00:00
array ( 'file://intranet./whatever/you/like.txt' )
2011-04-25 21:00:49 +00:00
),
// Multiple-slash cases that can sorta work on Mozilla
// if you hack it just right are kinda pathological,
// and unreliable cross-platform or on IE which means they're
// unlikely to appear on intranets.
//
// Those will survive the algorithm but with results that
// are less consistent.
2011-11-14 09:13:58 +00:00
// protocol-relative URL cases per bug 29854...
array (
'//bugzilla.wikimedia.org/show_bug.cgi?id=28627' ,
array (
'http://org.wikimedia.bugzilla./show_bug.cgi?id=28627' ,
'https://org.wikimedia.bugzilla./show_bug.cgi?id=28627'
)
),
2011-04-25 21:00:49 +00:00
);
}
2011-08-20 10:41:44 +00:00
/**
* @ dataProvider provideWfMatchesDomainList
*/
function testWfMatchesDomainList ( $url , $domains , $expected , $description ) {
$actual = wfMatchesDomainList ( $url , $domains );
$this -> assertEquals ( $expected , $actual , $description );
}
function provideWfMatchesDomainList () {
$a = array ();
$protocols = array ( 'HTTP' => 'http:' , 'HTTPS' => 'https:' , 'protocol-relative' => '' );
foreach ( $protocols as $pDesc => $p ) {
$a = array_merge ( $a , array (
array ( " $p //www.example.com " , array (), false , " No matches for empty domains array, $pDesc URL " ),
array ( " $p //www.example.com " , array ( 'www.example.com' ), true , " Exact match in domains array, $pDesc URL " ),
array ( " $p //www.example.com " , array ( 'example.com' ), true , " Match without subdomain in domains array, $pDesc URL " ),
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 " ),
array ( " $p //www.example2.com " , array ( 'example.com' , 'example2.com' , 'example3,com' ), true , " Match without subdomain with other domains in array, $pDesc URL " ),
array ( " $p //www.example4.com " , array ( 'example.com' , 'example2.com' , 'example3,com' ), false , " Domain not in array, $pDesc URL " ),
// FIXME: This is a bug in wfMatchesDomainList(). If and when this is fixed, update this test case
array ( " $p //nds-nl.wikipedia.org " , array ( 'nl.wikipedia.org' ), true , " Substrings of domains match while they shouldn't, $pDesc URL " ),
) );
}
return $a ;
}
2011-04-25 21:00:49 +00:00
2011-09-23 20:42:22 +00:00
/**
* @ dataProvider provideWfShellMaintenanceCmdList
*/
function testWfShellMaintenanceCmd ( $script , $parameters , $options , $expected , $description ) {
2011-09-23 22:17:41 +00:00
if ( wfIsWindows () ) {
// Approximation that's good enough for our purposes just now
$expected = str_replace ( " ' " , '"' , $expected );
}
2011-09-23 20:42:22 +00:00
$actual = wfShellMaintenanceCmd ( $script , $parameters , $options );
$this -> assertEquals ( $expected , $actual , $description );
}
function provideWfShellMaintenanceCmdList () {
global $wgPhpCli ;
return array (
array ( 'eval.php' , array ( '--help' , '--test' ), array (),
2012-03-13 00:18:29 +00:00
" $wgPhpCli eval.php '--help' '--test' " ,
2011-09-23 20:42:22 +00:00
" Called eval.php --help --test " ),
array ( 'eval.php' , array ( '--help' , '--test space' ), array ( 'php' => 'php5' ),
2012-03-13 00:18:29 +00:00
" php5 eval.php '--help' '--test space' " ,
2011-09-23 20:42:22 +00:00
" Called eval.php --help --test with php option " ),
array ( 'eval.php' , array ( '--help' , '--test' , 'X' ), array ( 'wrapper' => 'MWScript.php' ),
2012-03-13 00:18:29 +00:00
" $wgPhpCli MWScript.php eval.php '--help' '--test' 'X' " ,
2011-09-23 20:42:22 +00:00
" Called eval.php --help --test with wrapper option " ),
array ( 'eval.php' , array ( '--help' , '--test' , 'y' ), array ( 'php' => 'php5' , 'wrapper' => 'MWScript.php' ),
2012-03-13 00:18:29 +00:00
" php5 MWScript.php eval.php '--help' '--test' 'y' " ,
2011-09-23 20:42:22 +00:00
" Called eval.php --help --test with wrapper and php option " ),
);
}
2010-12-14 16:26:35 +00:00
/* TODO: many more! */
}
2011-01-02 02:16:32 +00:00
class MockOutputPage {
public $message ;
function debug ( $message ) {
$this -> message = " JAJA is a stupid error message. Anyway, here's your message: $message " ;
}
}