3 class GlobalTest
extends MediaWikiTestCase
{
5 global $wgReadOnlyFile, $wgContLang, $wgLang, $wgUrlProtocols, $wgLanguageCode;
6 $this->originals
['wgReadOnlyFile'] = $wgReadOnlyFile;
7 $this->originals
['wgUrlProtocols'] = $wgUrlProtocols;
8 $wgReadOnlyFile = tempnam( wfTempDir(), "mwtest_readonly" );
9 $wgUrlProtocols[] = 'file://';
10 unlink( $wgReadOnlyFile );
11 $wgLanguageCode = 'en';
12 $wgContLang = $wgLang = Language
::factory( 'en' );
16 global $wgReadOnlyFile, $wgUrlProtocols;
17 if ( file_exists( $wgReadOnlyFile ) ) {
18 unlink( $wgReadOnlyFile );
20 $wgReadOnlyFile = $this->originals
['wgReadOnlyFile'];
21 $wgUrlProtocols = $this->originals
['wgUrlProtocols'];
24 /** @dataProvider provideForWfArrayDiff2 */
25 public function testWfArrayDiff2( $a, $b, $expected ) {
27 wfArrayDiff2( $a, $b), $expected
31 // @todo Provide more tests
32 public function provideForWfArrayDiff2() {
41 array( array( 'a'), array( 'a', 'b', 'c' )),
42 array( array( 'a'), array( 'a', 'b' )),
43 array( 1 => array( 'a', 'b', 'c' ) ),
48 function testRandom() {
49 # This could hypothetically fail, but it shouldn't ;)
51 wfRandom() == wfRandom() );
54 function testUrlencode() {
56 "%E7%89%B9%E5%88%A5:Contributions/Foobar",
57 wfUrlencode( "\xE7\x89\xB9\xE5\x88\xA5:Contributions/Foobar" ) );
60 function testReadOnlyEmpty() {
64 $this->assertFalse( wfReadOnly() );
65 $this->assertFalse( wfReadOnly() );
68 function testReadOnlySet() {
69 global $wgReadOnly, $wgReadOnlyFile;
71 $f = fopen( $wgReadOnlyFile, "wt" );
72 fwrite( $f, 'Message' );
74 $wgReadOnly = null; # Check on $wgReadOnlyFile
76 $this->assertTrue( wfReadOnly() );
77 $this->assertTrue( wfReadOnly() ); # Check cached
79 unlink( $wgReadOnlyFile );
80 $wgReadOnly = null; # Clean cache
82 $this->assertFalse( wfReadOnly() );
83 $this->assertFalse( wfReadOnly() );
86 function testQuotedPrintable() {
88 "=?UTF-8?Q?=C4=88u=20legebla=3F?=",
89 UserMailer
::quotedPrintable( "\xc4\x88u legebla?", "UTF-8" ) );
94 $this->assertInternalType( 'float', $start );
96 $this->assertTrue( $end > $start, "Time is running backwards!" );
99 function testArrayToCGI() {
101 "baz=AT%26T&foo=bar",
103 array( 'baz' => 'AT&T', 'ignore' => '' ),
104 array( 'foo' => 'bar', 'baz' => 'overridden value' ) ) );
107 function testMimeTypeMatch() {
110 mimeTypeMatch( 'text/html',
111 array( 'application/xhtml+xml' => 1.0,
113 'text/plain' => 0.3 ) ) );
116 mimeTypeMatch( 'text/html',
117 array( 'image/*' => 1.0,
118 'text/*' => 0.5 ) ) );
121 mimeTypeMatch( 'text/html',
122 array( '*/*' => 1.0 ) ) );
124 mimeTypeMatch( 'text/html',
125 array( 'image/png' => 1.0,
126 'image/svg+xml' => 0.5 ) ) );
129 function testNegotiateType() {
133 array( 'application/xhtml+xml' => 1.0,
137 array( 'text/html' => 1.0 ) ) );
139 'application/xhtml+xml',
141 array( 'application/xhtml+xml' => 1.0,
145 array( 'application/xhtml+xml' => 1.0,
146 'text/html' => 0.5 ) ) );
150 array( 'text/html' => 1.0,
153 'application/xhtml+xml' => 0.2 ),
154 array( 'application/xhtml+xml' => 1.0,
155 'text/html' => 0.5 ) ) );
159 array( 'text/*' => 1.0,
162 array( 'application/xhtml+xml' => 1.0,
163 'text/html' => 0.5 ) ) );
166 array( 'text/*' => 1.0 ),
167 array( 'application/xhtml+xml' => 1.0 ) ) );
170 function testTimestamp() {
171 $t = gmmktime( 12, 34, 56, 1, 15, 2001 );
174 wfTimestamp( TS_MW
, $t ),
175 'TS_UNIX to TS_MW' );
178 wfTimestamp( TS_MW
, -30281104 ),
179 'Negative TS_UNIX to TS_MW' );
182 wfTimestamp( TS_UNIX
, $t ),
183 'TS_UNIX to TS_UNIX' );
185 '2001-01-15 12:34:56',
186 wfTimestamp( TS_DB
, $t ),
187 'TS_UNIX to TS_DB' );
190 wfTimestamp( TS_ISO_8601_BASIC
, $t ),
191 'TS_ISO_8601_BASIC to TS_DB' );
195 wfTimestamp( TS_MW
, '20010115123456' ),
199 wfTimestamp( TS_UNIX
, '20010115123456' ),
200 'TS_MW to TS_UNIX' );
202 '2001-01-15 12:34:56',
203 wfTimestamp( TS_DB
, '20010115123456' ),
207 wfTimestamp( TS_ISO_8601_BASIC
, '20010115123456' ),
208 'TS_MW to TS_ISO_8601_BASIC' );
212 wfTimestamp( TS_MW
, '2001-01-15 12:34:56' ),
216 wfTimestamp( TS_UNIX
, '2001-01-15 12:34:56' ),
217 'TS_DB to TS_UNIX' );
219 '2001-01-15 12:34:56',
220 wfTimestamp( TS_DB
, '2001-01-15 12:34:56' ),
224 wfTimestamp( TS_ISO_8601_BASIC
, '2001-01-15 12:34:56' ),
225 'TS_DB to TS_ISO_8601_BASIC' );
227 # rfc2822 section 3.3
230 'Mon, 15 Jan 2001 12:34:56 GMT',
231 wfTimestamp( TS_RFC2822
, '20010115123456' ),
232 'TS_MW to TS_RFC2822' );
236 wfTimestamp( TS_MW
, 'Mon, 15 Jan 2001 12:34:56 GMT' ),
237 'TS_RFC2822 to TS_MW' );
241 wfTimestamp( TS_MW
, ' Mon, 15 Jan 2001 12:34:56 GMT' ),
242 'TS_RFC2822 with leading space to TS_MW' );
246 wfTimestamp( TS_MW
, '15 Jan 2001 12:34:56 GMT' ),
247 'TS_RFC2822 without optional day-of-week to TS_MW' );
249 # FWS = ([*WSP CRLF] 1*WSP) / obs-FWS ; Folding white space
250 # obs-FWS = 1*WSP *(CRLF 1*WSP) ; Section 4.2
253 wfTimestamp( TS_MW
, 'Mon, 15 Jan 2001 12:34:56 GMT' ),
254 'TS_RFC2822 to TS_MW' );
256 # WSP = SP / HTAB ; rfc2234
259 wfTimestamp( TS_MW
, "Mon, 15 Jan\x092001 12:34:56 GMT" ),
260 'TS_RFC2822 with HTAB to TS_MW' );
264 wfTimestamp( TS_MW
, "Mon, 15 Jan\x09 \x09 2001 12:34:56 GMT" ),
265 'TS_RFC2822 with HTAB and SP to TS_MW' );
269 wfTimestamp( TS_MW
, "Sun, 6 Nov 94 08:49:37 GMT" ),
270 'TS_RFC2822 with obsolete year to TS_MW' );
274 * This test checks wfTimestamp() with values outside.
275 * It needs PHP 64 bits or PHP > 5.1.
276 * See r74778 and bug 25451
278 function testOldTimestamps() {
279 $this->assertEquals( 'Fri, 13 Dec 1901 20:45:54 GMT',
280 wfTimestamp( TS_RFC2822
, '19011213204554' ),
281 'Earliest time according to php documentation' );
283 $this->assertEquals( 'Tue, 19 Jan 2038 03:14:07 GMT',
284 wfTimestamp( TS_RFC2822
, '20380119031407' ),
285 'Latest 32 bit time' );
287 $this->assertEquals( '-2147483648',
288 wfTimestamp( TS_UNIX
, '19011213204552' ),
289 'Earliest 32 bit unix time' );
291 $this->assertEquals( '2147483647',
292 wfTimestamp( TS_UNIX
, '20380119031407' ),
293 'Latest 32 bit unix time' );
295 $this->assertEquals( 'Fri, 13 Dec 1901 20:45:52 GMT',
296 wfTimestamp( TS_RFC2822
, '19011213204552' ),
297 'Earliest 32 bit time' );
299 $this->assertEquals( 'Fri, 13 Dec 1901 20:45:51 GMT',
300 wfTimestamp( TS_RFC2822
, '19011213204551' ),
301 'Earliest 32 bit time - 1' );
303 $this->assertEquals( 'Tue, 19 Jan 2038 03:14:08 GMT',
304 wfTimestamp( TS_RFC2822
, '20380119031408' ),
305 'Latest 32 bit time + 1' );
307 $this->assertEquals( '19011212000000',
308 wfTimestamp(TS_MW
, '19011212000000'),
309 'Convert to itself r74778#c10645' );
311 $this->assertEquals( '-2147483649',
312 wfTimestamp( TS_UNIX
, '19011213204551' ),
313 'Earliest 32 bit unix time - 1' );
315 $this->assertEquals( '2147483648',
316 wfTimestamp( TS_UNIX
, '20380119031408' ),
317 'Latest 32 bit unix time + 1' );
319 $this->assertEquals( '19011213204551',
320 wfTimestamp( TS_MW
, '-2147483649' ),
321 '1901 negative unix time to MediaWiki' );
323 $this->assertEquals( '18010115123456',
324 wfTimestamp( TS_MW
, '-5331871504' ),
325 '1801 negative unix time to MediaWiki' );
327 $this->assertEquals( 'Tue, 09 Aug 0117 12:34:56 GMT',
328 wfTimestamp( TS_RFC2822
, '0117-08-09 12:34:56'),
329 'Death of Roman Emperor [[Trajan]]');
331 /* @todo FIXME: 00 to 101 years are taken as being in [1970-2069] */
333 $this->assertEquals( 'Sun, 01 Jan 0101 00:00:00 GMT',
334 wfTimestamp( TS_RFC2822
, '-58979923200'),
337 $this->assertEquals( 'Mon, 01 Jan 0001 00:00:00 GMT',
338 wfTimestamp( TS_RFC2822
, '-62135596800'),
341 /* It is not clear if we should generate a year 0 or not
342 * We are completely off RFC2822 requirement of year being
345 $this->assertEquals( 'Wed, 18 Oct 0000 00:00:00 GMT',
346 wfTimestamp( TS_RFC2822
, '-62142076800'),
347 'ISO 8601:2004 [[year 0]], also called [[1 BC]]');
350 function testHttpDate() {
351 # The Resource Loader uses wfTimestamp() to convert timestamps
352 # from If-Modified-Since header.
353 # Thus it must be able to parse all rfc2616 date formats
354 # http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1
358 wfTimestamp( TS_MW
, 'Sun, 06 Nov 1994 08:49:37 GMT' ),
363 wfTimestamp( TS_MW
, 'Sunday, 06-Nov-94 08:49:37 GMT' ),
368 wfTimestamp( TS_MW
, 'Sun Nov 6 08:49:37 1994' ),
369 "ANSI C's asctime() format" );
371 // See http://www.squid-cache.org/mail-archive/squid-users/200307/0122.html and r77171
374 wfTimestamp( TS_MW
, 'Mon, 22 Nov 2010 14:12:42 GMT; length=52626' ),
375 "Netscape extension to HTTP/1.0" );
379 function testTimestampParameter() {
380 // There are a number of assumptions in our codebase where wfTimestamp() should give
381 // the current date but it is not given a 0 there. See r71751 CR
383 $now = wfTimestamp( TS_UNIX
);
384 // We check that wfTimestamp doesn't return false (error) and use a LessThan assert
385 // for the cases where the test is run in a second boundary.
387 $zero = wfTimestamp( TS_UNIX
, 0 );
388 $this->assertNotEquals( false, $zero );
389 $this->assertLessThan( 5, $zero - $now );
391 $empty = wfTimestamp( TS_UNIX
, '' );
392 $this->assertNotEquals( false, $empty );
393 $this->assertLessThan( 5, $empty - $now );
395 $null = wfTimestamp( TS_UNIX
, null );
396 $this->assertNotEquals( false, $null );
397 $this->assertLessThan( 5, $null - $now );
400 function testBasename() {
414 '\\aaaa\\' => 'aaaa',
415 '\\aaaa\\' => 'aaaa',
416 '/mnt/upload3/wikipedia/en/thumb/8/8b/Zork_Grand_Inquisitor_box_cover.jpg/93px-Zork_Grand_Inquisitor_box_cover.jpg' => '93px-Zork_Grand_Inquisitor_box_cover.jpg',
417 'C:\\Progra~1\\Wikime~1\\Wikipe~1\\VIEWER.EXE' => 'VIEWER.EXE',
418 'Östergötland_coat_of_arms.png' => 'Östergötland_coat_of_arms.png',
420 foreach ( $sets as $from => $to ) {
421 $this->assertEquals( $to, wfBaseName( $from ),
422 "wfBaseName('$from') => '$to'" );
427 function testFallbackMbstringFunctions() {
429 if( !extension_loaded( 'mbstring' ) ) {
430 $this->markTestSkipped( "The mb_string functions must be installed to test the fallback functions" );
433 $sampleUTF = "Östergötland_coat_of_arms.png";
437 $substr_params = array(
447 foreach( $substr_params as $param_set ) {
448 $old_param_set = $param_set;
449 array_unshift( $param_set, $sampleUTF );
452 MWFunction
::callArray( 'mb_substr', $param_set ),
453 MWFunction
::callArray( 'Fallback::mb_substr', $param_set ),
454 'Fallback mb_substr with params ' . implode( ', ', $old_param_set )
461 mb_strlen( $sampleUTF ),
462 Fallback
::mb_strlen( $sampleUTF ),
468 $strpos_params = array(
472 //array( 'oat_', 100 ),
477 foreach( $strpos_params as $param_set ) {
478 $old_param_set = $param_set;
479 array_unshift( $param_set, $sampleUTF );
482 MWFunction
::callArray( 'mb_strpos', $param_set ),
483 MWFunction
::callArray( 'Fallback::mb_strpos', $param_set ),
484 'Fallback mb_strpos with params ' . implode( ', ', $old_param_set )
488 MWFunction
::callArray( 'mb_strrpos', $param_set ),
489 MWFunction
::callArray( 'Fallback::mb_strrpos', $param_set ),
490 'Fallback mb_strrpos with params ' . implode( ', ', $old_param_set )
497 function testDebugFunctionTest() {
499 global $wgDebugLogFile, $wgOut, $wgShowDebug, $wgDebugTimestamps;
501 $old_log_file = $wgDebugLogFile;
502 $wgDebugLogFile = tempnam( wfTempDir(), 'mw-' );
503 #Â @todo FIXME: This setting should be tested
504 $wgDebugTimestamps = false;
508 wfDebug( "This is a normal string" );
509 $this->assertEquals( "This is a normal string", file_get_contents( $wgDebugLogFile ) );
510 unlink( $wgDebugLogFile );
513 wfDebug( "This is nöt an ASCII string" );
514 $this->assertEquals( "This is nöt an ASCII string", file_get_contents( $wgDebugLogFile ) );
515 unlink( $wgDebugLogFile );
518 wfDebug( "\00305This has böth UTF and control chars\003" );
519 $this->assertEquals( " 05This has böth UTF and control chars ", file_get_contents( $wgDebugLogFile ) );
520 unlink( $wgDebugLogFile );
525 $old_wgShowDebug = $wgShowDebug;
527 $wgOut = new MockOutputPage
;
531 $message = "\00305This has böth UTF and control chars\003";
535 if( $wgOut->message
== "JAJA is a stupid error message. Anyway, here's your message: $message" ) {
536 $this->assertTrue( true, 'MockOutputPage called, set the proper message.' );
539 $this->assertTrue( false, 'MockOutputPage was not called.' );
543 $wgShowDebug = $old_wgShowDebug;
544 unlink( $wgDebugLogFile );
549 $this->assertGreaterThan( 5000, preg_replace( '/\D/', '', file_get_contents( $wgDebugLogFile ) ) );
550 unlink( $wgDebugLogFile );
553 $this->assertGreaterThan( 5000000, preg_replace( '/\D/', '', file_get_contents( $wgDebugLogFile ) ) );
554 unlink( $wgDebugLogFile );
558 $wgDebugLogFile = $old_log_file;
562 function testClientAcceptsGzipTest() {
568 'compress, gzip' => true,
569 'gzip;q=1.0' => true,
572 'gzip;q=abcde' => true, //is this REALLY valid?
573 'gzip;q=12345678.9' => true,
577 if( isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) $old_server_setting = $_SERVER['HTTP_ACCEPT_ENCODING'];
579 foreach ( $settings as $encoding => $expect ) {
580 $_SERVER['HTTP_ACCEPT_ENCODING'] = $encoding;
582 $this->assertEquals( $expect, wfClientAcceptsGzip( true ),
583 "'$encoding' => " . wfBoolToStr( $expect ) );
586 if( isset( $old_server_setting ) ) $_SERVER['HTTP_ACCEPT_ENCODING'] = $old_server_setting;
592 function testSwapVarsTest() {
598 $this->assertEquals( $var1, 1, 'var1 is set originally' );
599 $this->assertEquals( $var2, 2, 'var1 is set originally' );
601 swap( $var1, $var2 );
603 $this->assertEquals( $var1, 2, 'var1 is swapped' );
604 $this->assertEquals( $var2, 1, 'var2 is swapped' );
609 function testWfPercentTest() {
612 array( 6/7, '0.86%', 2, false ),
614 array( 22/7, '3.14286%', 5 ),
615 array( 3/6, '0.5%' ),
616 array( 1/3, '0%', 0 ),
617 array( 10/3, '0%', -1 ),
618 array( 3/4/5, '0.1%', 1 ),
619 array( 6/7*8, '6.8571428571%', 10 ),
622 foreach( $pcts as $pct ) {
623 if( !isset( $pct[2] ) ) $pct[2] = 2;
624 if( !isset( $pct[3] ) ) $pct[3] = true;
626 $this->assertEquals( wfPercent( $pct[0], $pct[2], $pct[3] ), $pct[1], $pct[1] );
632 function testInStringTest() {
634 $this->assertTrue( in_string( 'foo', 'foobar' ), 'foo is in foobar' );
635 $this->assertFalse( in_string( 'Bar', 'foobar' ), 'Case-sensitive by default' );
636 $this->assertTrue( in_string( 'Foo', 'foobar', true ), 'Case-insensitive when asked' );
641 * test @see wfShorthandToInteger()
642 * @dataProvider provideShorthand
644 public function testWfShorthandToInteger( $shorthand, $expected ) {
645 $this->assertEquals( $expected,
646 wfShorthandToInteger( $shorthand )
650 /** array( shorthand, expected integer ) */
651 public function provideShorthand() {
658 # Failures returns 0 :(
659 array( 'ABCDEFG', 0 ),
662 # Int, strings with spaces
666 array( ' 1023 ', 1023 ),
671 array( '1m', 1024 * 1024 ),
672 array( '1M', 1024 * 1024 ),
673 array( '1g', 1024 * 1024 * 1024 ),
674 array( '1G', 1024 * 1024 * 1024 ),
679 array( '-500', -500 ),
680 array( '-1k', -1024 ),
696 * test @see wfBCP47().
697 * Please note the BCP explicitly state that language codes are case
698 * insensitive, there are some exceptions to the rule :)
699 * This test is used to verify our formatting against all lower and
700 * all upper cases language code.
702 * @see http://tools.ietf.org/html/bcp47
703 * @dataProvider provideLanguageCodes()
705 function testBCP47( $code, $expected ) {
706 $code = strtolower( $code );
707 $this->assertEquals( $expected, wfBCP47($code),
708 "Applying BCP47 standard to lower case '$code'"
711 $code = strtoupper( $code );
712 $this->assertEquals( $expected, wfBCP47($code),
713 "Applying BCP47 standard to upper case '$code'"
718 * Array format is ($code, $expected)
720 function provideLanguageCodes() {
722 // Extracted from BCP47 (list not exhaustive)
724 array( 'en-ca-x-ca' , 'en-CA-x-ca' ),
725 array( 'sgn-be-fr' , 'sgn-BE-FR' ),
726 array( 'az-latn-x-latn', 'az-Latn-x-latn' ),
728 array( 'sr-Latn-RS', 'sr-Latn-RS' ),
729 array( 'az-arab-ir', 'az-Arab-IR' ),
732 array( 'sl-nedis' , 'sl-nedis' ),
733 array( 'de-ch-1996', 'de-CH-1996' ),
737 'en-latn-gb-boont-r-extended-sequence-x-private',
738 'en-Latn-GB-boont-r-extended-sequence-x-private'
741 // Examples from BCP47 Appendix A
742 # Simple language subtag:
747 # Language subtag plus script subtag:
748 array( 'zh-hans', 'zh-Hans'),
749 array( 'sr-cyrl', 'sr-Cyrl'),
750 array( 'sr-latn', 'sr-Latn'),
752 # Extended language subtags and their primary language subtag
754 array( 'zh-cmn-hans-cn', 'zh-cmn-Hans-CN' ),
755 array( 'cmn-hans-cn' , 'cmn-Hans-CN' ),
756 array( 'zh-yue-hk' , 'zh-yue-HK' ),
757 array( 'yue-hk' , 'yue-HK' ),
759 # Language-Script-Region:
760 array( 'zh-hans-cn', 'zh-Hans-CN' ),
761 array( 'sr-latn-RS', 'sr-Latn-RS' ),
764 array( 'sl-rozaj' , 'sl-rozaj' ),
765 array( 'sl-rozaj-biske', 'sl-rozaj-biske' ),
766 array( 'sl-nedis' , 'sl-nedis' ),
768 # Language-Region-Variant:
769 array( 'de-ch-1901' , 'de-CH-1901' ),
770 array( 'sl-it-nedis' , 'sl-IT-nedis' ),
772 # Language-Script-Region-Variant:
773 array( 'hy-latn-it-arevela', 'hy-Latn-IT-arevela' ),
776 array( 'de-de' , 'de-DE' ),
777 array( 'en-us' , 'en-US' ),
778 array( 'es-419', 'es-419'),
780 # Private use subtags:
781 array( 'de-ch-x-phonebk' , 'de-CH-x-phonebk' ),
782 array( 'az-arab-x-aze-derbend', 'az-Arab-x-aze-derbend' ),
784 * Previous test does not reflect the BCP which states:
785 * az-Arab-x-AZE-derbend
786 * AZE being private, it should be lower case, hence the test above
787 * should probably be:
788 #array( 'az-arab-x-aze-derbend', 'az-Arab-x-AZE-derbend' ),
791 # Private use registry values:
792 array( 'x-whatever', 'x-whatever' ),
793 array( 'qaa-qaaa-qm-x-southern', 'qaa-Qaaa-QM-x-southern' ),
794 array( 'de-qaaa' , 'de-Qaaa' ),
795 array( 'sr-latn-qm', 'sr-Latn-QM' ),
796 array( 'sr-qaaa-rs', 'sr-Qaaa-RS' ),
798 # Tags that use extensions
799 array( 'en-us-u-islamcal', 'en-US-u-islamcal' ),
800 array( 'zh-cn-a-myext-x-private', 'zh-CN-a-myext-x-private' ),
801 array( 'en-a-myext-b-another', 'en-a-myext-b-another' ),
806 // ar-a-aaa-b-bbb-a-ccc
810 array( 'sr-Cyrl', 'sr-Cyrl' ),
811 # @todo FIXME: Fix our function?
812 array( 'SR-lATN', 'sr-Latn' ),
813 array( 'fr-latn', 'fr-Latn' ),
814 // Use lowercase for single segment
815 // ISO 3166-1-alpha-2 code
816 array( 'US', 'us' ), # USA
817 array( 'uS', 'us' ), # USA
818 array( 'Fr', 'fr' ), # France
819 array( 'va', 'va' ), # Holy See (Vatican City State)
824 * @dataProvider provideMakeUrlIndex()
826 function testMakeUrlIndex( $url, $expected ) {
827 $index = wfMakeUrlIndex( $url );
828 $this->assertEquals( $expected, $index, "wfMakeUrlIndex(\"$url\")" );
831 function provideMakeUrlIndex() {
835 'https://bugzilla.wikimedia.org/show_bug.cgi?id=28627',
836 'https://org.wikimedia.bugzilla./show_bug.cgi?id=28627'
839 // mailtos are handled special
840 // is this really right though? that final . probably belongs earlier?
841 'mailto:wiki@wikimedia.org',
842 'mailto:org.wikimedia@wiki.',
845 // file URL cases per bug 28627...
847 // three slashes: local filesystem path Unix-style
848 'file:///whatever/you/like.txt',
849 'file://./whatever/you/like.txt'
852 // three slashes: local filesystem path Windows-style
853 'file:///c:/whatever/you/like.txt',
854 'file://./c:/whatever/you/like.txt'
857 // two slashes: UNC filesystem path Windows-style
858 'file://intranet/whatever/you/like.txt',
859 'file://intranet./whatever/you/like.txt'
861 // Multiple-slash cases that can sorta work on Mozilla
862 // if you hack it just right are kinda pathological,
863 // and unreliable cross-platform or on IE which means they're
864 // unlikely to appear on intranets.
866 // Those will survive the algorithm but with results that
867 // are less consistent.
871 /* TODO: many more! */
875 class MockOutputPage
{
879 function debug( $message ) {
880 $this->message
= "JAJA is a stupid error message. Anyway, here's your message: $message";