class GlobalTest extends MediaWikiTestCase {
function setUp() {
- global $wgReadOnlyFile, $wgContLang, $wgLang;
+ global $wgReadOnlyFile, $wgContLang, $wgLang, $wgUrlProtocols, $wgLanguageCode;
$this->originals['wgReadOnlyFile'] = $wgReadOnlyFile;
+ $this->originals['wgUrlProtocols'] = $wgUrlProtocols;
$wgReadOnlyFile = tempnam( wfTempDir(), "mwtest_readonly" );
+ $wgUrlProtocols[] = 'file://';
unlink( $wgReadOnlyFile );
+ $wgLanguageCode = 'en';
$wgContLang = $wgLang = Language::factory( 'en' );
}
function tearDown() {
- global $wgReadOnlyFile;
+ global $wgReadOnlyFile, $wgUrlProtocols;
if ( file_exists( $wgReadOnlyFile ) ) {
unlink( $wgReadOnlyFile );
}
$wgReadOnlyFile = $this->originals['wgReadOnlyFile'];
+ $wgUrlProtocols = $this->originals['wgUrlProtocols'];
}
/** @dataProvider provideForWfArrayDiff2 */
wfArrayToCGI(
array( 'baz' => 'AT&T', 'ignore' => '' ),
array( 'foo' => 'bar', 'baz' => 'overridden value' ) ) );
+ $this->assertEquals(
+ "path%5B0%5D=wiki&path%5B1%5D=test&cfg%5Bservers%5D%5Bhttp%5D=localhost",
+ wfArrayToCGI( array(
+ 'path' => array( 'wiki', 'test' ),
+ 'cfg' => array( 'servers' => array( 'http' => 'localhost' ) ) ) ) );
+ }
+
+ function testCgiToArray() {
+ $this->assertEquals(
+ array( 'path' => array( 'wiki', 'test' ),
+ 'cfg' => array( 'servers' => array( 'http' => 'localhost' ) ) ),
+ wfCgiToArray( 'path%5B0%5D=wiki&path%5B1%5D=test&cfg%5Bservers%5D%5Bhttp%5D=localhost' ) );
}
function testMimeTypeMatch() {
wfTimestamp( TS_RFC2822, '0117-08-09 12:34:56'),
'Death of Roman Emperor [[Trajan]]');
- /* FIXME: 00 to 101 years are taken as being in [1970-2069] */
+ /* @todo FIXME: 00 to 101 years are taken as being in [1970-2069] */
$this->assertEquals( 'Sun, 01 Jan 0101 00:00:00 GMT',
wfTimestamp( TS_RFC2822, '-58979923200'),
$old_log_file = $wgDebugLogFile;
$wgDebugLogFile = tempnam( wfTempDir(), 'mw-' );
- $wgDebugTimestamps = false; # FIXME: this setting should be tested
+ # @todo FIXME: This setting should be tested
+ $wgDebugTimestamps = false;
$old_wgOut = $wgOut;
$old_wgShowDebug = $wgShowDebug;
- $wgOut = new StubObject( 'wgOut', 'MockOutputPage' );
- $wgOut->doNothing(); //just to unstub it
+ $wgOut = new MockOutputPage;
$wgShowDebug = true;
/*
// ISO 15924 :
array( 'sr-Cyrl', 'sr-Cyrl' ),
- array( 'SR-lATN', 'sr-Latn' ), # FIXME fix our function?
+ # @todo FIXME: Fix our function?
+ array( 'SR-lATN', 'sr-Latn' ),
array( 'fr-latn', 'fr-Latn' ),
// Use lowercase for single segment
// ISO 3166-1-alpha-2 code
*/);
}
+ /**
+ * @dataProvider provideMakeUrlIndex()
+ */
+ function testMakeUrlIndex( $url, $expected ) {
+ $index = wfMakeUrlIndex( $url );
+ $this->assertEquals( $expected, $index, "wfMakeUrlIndex(\"$url\")" );
+ }
+
+ function provideMakeUrlIndex() {
+ return array(
+ array(
+ // just a regular :)
+ 'https://bugzilla.wikimedia.org/show_bug.cgi?id=28627',
+ 'https://org.wikimedia.bugzilla./show_bug.cgi?id=28627'
+ ),
+ array(
+ // mailtos are handled special
+ // is this really right though? that final . probably belongs earlier?
+ 'mailto:wiki@wikimedia.org',
+ 'mailto:org.wikimedia@wiki.',
+ ),
+
+ // file URL cases per bug 28627...
+ array(
+ // three slashes: local filesystem path Unix-style
+ 'file:///whatever/you/like.txt',
+ 'file://./whatever/you/like.txt'
+ ),
+ array(
+ // three slashes: local filesystem path Windows-style
+ 'file:///c:/whatever/you/like.txt',
+ 'file://./c:/whatever/you/like.txt'
+ ),
+ array(
+ // two slashes: UNC filesystem path Windows-style
+ 'file://intranet/whatever/you/like.txt',
+ 'file://intranet./whatever/you/like.txt'
+ ),
+ // 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.
+ );
+ }
+
/* TODO: many more! */
}
function debug( $message ) {
$this->message = "JAJA is a stupid error message. Anyway, here's your message: $message";
}
-
- function doNothing() {}
}