Add 3D filetype for STL files
[lhc/web/wiklou.git] / tests / phpunit / includes / GlobalFunctions / GlobalTest.php
1 <?php
2
3 /**
4 * @group Database
5 * @group GlobalFunctions
6 */
7 class GlobalTest extends MediaWikiTestCase {
8 protected function setUp() {
9 parent::setUp();
10
11 $readOnlyFile = $this->getNewTempFile();
12 unlink( $readOnlyFile );
13
14 $this->setMwGlobals( [
15 'wgReadOnlyFile' => $readOnlyFile,
16 'wgUrlProtocols' => [
17 'http://',
18 'https://',
19 'mailto:',
20 '//',
21 'file://', # Non-default
22 ],
23 ] );
24 }
25
26 /**
27 * @dataProvider provideForWfArrayDiff2
28 * @covers ::wfArrayDiff2
29 */
30 public function testWfArrayDiff2( $a, $b, $expected ) {
31 $this->assertEquals(
32 wfArrayDiff2( $a, $b ), $expected
33 );
34 }
35
36 // @todo Provide more tests
37 public static function provideForWfArrayDiff2() {
38 // $a $b $expected
39 return [
40 [
41 [ 'a', 'b' ],
42 [ 'a', 'b' ],
43 [],
44 ],
45 [
46 [ [ 'a' ], [ 'a', 'b', 'c' ] ],
47 [ [ 'a' ], [ 'a', 'b' ] ],
48 [ 1 => [ 'a', 'b', 'c' ] ],
49 ],
50 ];
51 }
52
53 /*
54 * Test cases for random functions could hypothetically fail,
55 * even though they shouldn't.
56 */
57
58 /**
59 * @covers ::wfRandom
60 */
61 public function testRandom() {
62 $this->assertFalse(
63 wfRandom() == wfRandom()
64 );
65 }
66
67 /**
68 * @covers ::wfRandomString
69 */
70 public function testRandomString() {
71 $this->assertFalse(
72 wfRandomString() == wfRandomString()
73 );
74 $this->assertEquals(
75 strlen( wfRandomString( 10 ) ), 10
76 );
77 $this->assertTrue(
78 preg_match( '/^[0-9a-f]+$/i', wfRandomString() ) === 1
79 );
80 }
81
82 /**
83 * @covers ::wfUrlencode
84 */
85 public function testUrlencode() {
86 $this->assertEquals(
87 "%E7%89%B9%E5%88%A5:Contributions/Foobar",
88 wfUrlencode( "\xE7\x89\xB9\xE5\x88\xA5:Contributions/Foobar" ) );
89 }
90
91 /**
92 * @covers ::wfExpandIRI
93 */
94 public function testExpandIRI() {
95 $this->assertEquals(
96 "https://te.wikibooks.org/wiki/ఉబుంటు_వాడుకరి_మార్గదర్శని",
97 wfExpandIRI( "https://te.wikibooks.org/wiki/"
98 . "%E0%B0%89%E0%B0%AC%E0%B1%81%E0%B0%82%E0%B0%9F%E0%B1%81_"
99 . "%E0%B0%B5%E0%B0%BE%E0%B0%A1%E0%B1%81%E0%B0%95%E0%B0%B0%E0%B0%BF_"
100 . "%E0%B0%AE%E0%B0%BE%E0%B0%B0%E0%B1%8D%E0%B0%97%E0%B0%A6%E0%B0%B0"
101 . "%E0%B1%8D%E0%B0%B6%E0%B0%A8%E0%B0%BF" ) );
102 }
103
104 /**
105 * @covers ::wfReadOnly
106 */
107 public function testReadOnlyEmpty() {
108 global $wgReadOnly;
109 $wgReadOnly = null;
110
111 $this->assertFalse( wfReadOnly() );
112 $this->assertFalse( wfReadOnly() );
113 }
114
115 /**
116 * @covers ::wfReadOnly
117 */
118 public function testReadOnlySet() {
119 global $wgReadOnly, $wgReadOnlyFile;
120
121 $f = fopen( $wgReadOnlyFile, "wt" );
122 fwrite( $f, 'Message' );
123 fclose( $f );
124 $wgReadOnly = null; # Check on $wgReadOnlyFile
125
126 $this->assertTrue( wfReadOnly() );
127 $this->assertTrue( wfReadOnly() ); # Check cached
128
129 unlink( $wgReadOnlyFile );
130 $wgReadOnly = null; # Clean cache
131
132 $this->assertFalse( wfReadOnly() );
133 $this->assertFalse( wfReadOnly() );
134 }
135
136 public static function provideArrayToCGI() {
137 return [
138 [ [], '' ], // empty
139 [ [ 'foo' => 'bar' ], 'foo=bar' ], // string test
140 [ [ 'foo' => '' ], 'foo=' ], // empty string test
141 [ [ 'foo' => 1 ], 'foo=1' ], // number test
142 [ [ 'foo' => true ], 'foo=1' ], // true test
143 [ [ 'foo' => false ], '' ], // false test
144 [ [ 'foo' => null ], '' ], // null test
145 [ [ 'foo' => 'A&B=5+6@!"\'' ], 'foo=A%26B%3D5%2B6%40%21%22%27' ], // urlencoding test
146 [
147 [ 'foo' => 'bar', 'baz' => 'is', 'asdf' => 'qwerty' ],
148 'foo=bar&baz=is&asdf=qwerty'
149 ], // multi-item test
150 [ [ 'foo' => [ 'bar' => 'baz' ] ], 'foo%5Bbar%5D=baz' ],
151 [
152 [ 'foo' => [ 'bar' => 'baz', 'qwerty' => 'asdf' ] ],
153 'foo%5Bbar%5D=baz&foo%5Bqwerty%5D=asdf'
154 ],
155 [ [ 'foo' => [ 'bar', 'baz' ] ], 'foo%5B0%5D=bar&foo%5B1%5D=baz' ],
156 [
157 [ 'foo' => [ 'bar' => [ 'bar' => 'baz' ] ] ],
158 'foo%5Bbar%5D%5Bbar%5D=baz'
159 ],
160 ];
161 }
162
163 /**
164 * @dataProvider provideArrayToCGI
165 * @covers ::wfArrayToCgi
166 */
167 public function testArrayToCGI( $array, $result ) {
168 $this->assertEquals( $result, wfArrayToCgi( $array ) );
169 }
170
171 /**
172 * @covers ::wfArrayToCgi
173 */
174 public function testArrayToCGI2() {
175 $this->assertEquals(
176 "baz=bar&foo=bar",
177 wfArrayToCgi(
178 [ 'baz' => 'bar' ],
179 [ 'foo' => 'bar', 'baz' => 'overridden value' ] ) );
180 }
181
182 public static function provideCgiToArray() {
183 return [
184 [ '', [] ], // empty
185 [ 'foo=bar', [ 'foo' => 'bar' ] ], // string
186 [ 'foo=', [ 'foo' => '' ] ], // empty string
187 [ 'foo', [ 'foo' => '' ] ], // missing =
188 [ 'foo=bar&qwerty=asdf', [ 'foo' => 'bar', 'qwerty' => 'asdf' ] ], // multiple value
189 [ 'foo=A%26B%3D5%2B6%40%21%22%27', [ 'foo' => 'A&B=5+6@!"\'' ] ], // urldecoding test
190 [ 'foo%5Bbar%5D=baz', [ 'foo' => [ 'bar' => 'baz' ] ] ],
191 [
192 'foo%5Bbar%5D=baz&foo%5Bqwerty%5D=asdf',
193 [ 'foo' => [ 'bar' => 'baz', 'qwerty' => 'asdf' ] ]
194 ],
195 [ 'foo%5B0%5D=bar&foo%5B1%5D=baz', [ 'foo' => [ 0 => 'bar', 1 => 'baz' ] ] ],
196 [
197 'foo%5Bbar%5D%5Bbar%5D=baz',
198 [ 'foo' => [ 'bar' => [ 'bar' => 'baz' ] ] ]
199 ],
200 ];
201 }
202
203 /**
204 * @dataProvider provideCgiToArray
205 * @covers ::wfCgiToArray
206 */
207 public function testCgiToArray( $cgi, $result ) {
208 $this->assertEquals( $result, wfCgiToArray( $cgi ) );
209 }
210
211 public static function provideCgiRoundTrip() {
212 return [
213 [ '' ],
214 [ 'foo=bar' ],
215 [ 'foo=' ],
216 [ 'foo=bar&baz=biz' ],
217 [ 'foo=A%26B%3D5%2B6%40%21%22%27' ],
218 [ 'foo%5Bbar%5D=baz' ],
219 [ 'foo%5B0%5D=bar&foo%5B1%5D=baz' ],
220 [ 'foo%5Bbar%5D%5Bbar%5D=baz' ],
221 ];
222 }
223
224 /**
225 * @dataProvider provideCgiRoundTrip
226 * @covers ::wfArrayToCgi
227 */
228 public function testCgiRoundTrip( $cgi ) {
229 $this->assertEquals( $cgi, wfArrayToCgi( wfCgiToArray( $cgi ) ) );
230 }
231
232 /**
233 * @covers ::mimeTypeMatch
234 */
235 public function testMimeTypeMatch() {
236 $this->assertEquals(
237 'text/html',
238 mimeTypeMatch( 'text/html',
239 [ 'application/xhtml+xml' => 1.0,
240 'text/html' => 0.7,
241 'text/plain' => 0.3 ] ) );
242 $this->assertEquals(
243 'text/*',
244 mimeTypeMatch( 'text/html',
245 [ 'image/*' => 1.0,
246 'text/*' => 0.5 ] ) );
247 $this->assertEquals(
248 '*/*',
249 mimeTypeMatch( 'text/html',
250 [ '*/*' => 1.0 ] ) );
251 $this->assertNull(
252 mimeTypeMatch( 'text/html',
253 [ 'image/png' => 1.0,
254 'image/svg+xml' => 0.5 ] ) );
255 }
256
257 /**
258 * @covers ::wfNegotiateType
259 */
260 public function testNegotiateType() {
261 $this->assertEquals(
262 'text/html',
263 wfNegotiateType(
264 [ 'application/xhtml+xml' => 1.0,
265 'text/html' => 0.7,
266 'text/plain' => 0.5,
267 'text/*' => 0.2 ],
268 [ 'text/html' => 1.0 ] ) );
269 $this->assertEquals(
270 'application/xhtml+xml',
271 wfNegotiateType(
272 [ 'application/xhtml+xml' => 1.0,
273 'text/html' => 0.7,
274 'text/plain' => 0.5,
275 'text/*' => 0.2 ],
276 [ 'application/xhtml+xml' => 1.0,
277 'text/html' => 0.5 ] ) );
278 $this->assertEquals(
279 'text/html',
280 wfNegotiateType(
281 [ 'text/html' => 1.0,
282 'text/plain' => 0.5,
283 'text/*' => 0.5,
284 'application/xhtml+xml' => 0.2 ],
285 [ 'application/xhtml+xml' => 1.0,
286 'text/html' => 0.5 ] ) );
287 $this->assertEquals(
288 'text/html',
289 wfNegotiateType(
290 [ 'text/*' => 1.0,
291 'image/*' => 0.7,
292 '*/*' => 0.3 ],
293 [ 'application/xhtml+xml' => 1.0,
294 'text/html' => 0.5 ] ) );
295 $this->assertNull(
296 wfNegotiateType(
297 [ 'text/*' => 1.0 ],
298 [ 'application/xhtml+xml' => 1.0 ] ) );
299 }
300
301 /**
302 * @covers ::wfDebug
303 * @covers ::wfDebugMem
304 */
305 public function testDebugFunctionTest() {
306 $debugLogFile = $this->getNewTempFile();
307
308 $this->setMwGlobals( [
309 'wgDebugLogFile' => $debugLogFile,
310 #  @todo FIXME: $wgDebugTimestamps should be tested
311 'wgDebugTimestamps' => false
312 ] );
313
314 wfDebug( "This is a normal string" );
315 $this->assertEquals( "This is a normal string\n", file_get_contents( $debugLogFile ) );
316 unlink( $debugLogFile );
317
318 wfDebug( "This is nöt an ASCII string" );
319 $this->assertEquals( "This is nöt an ASCII string\n", file_get_contents( $debugLogFile ) );
320 unlink( $debugLogFile );
321
322 wfDebug( "\00305This has böth UTF and control chars\003" );
323 $this->assertEquals(
324 " 05This has böth UTF and control chars \n",
325 file_get_contents( $debugLogFile )
326 );
327 unlink( $debugLogFile );
328
329 wfDebugMem();
330 $this->assertGreaterThan(
331 1000,
332 preg_replace( '/\D/', '', file_get_contents( $debugLogFile ) )
333 );
334 unlink( $debugLogFile );
335
336 wfDebugMem( true );
337 $this->assertGreaterThan(
338 1000000,
339 preg_replace( '/\D/', '', file_get_contents( $debugLogFile ) )
340 );
341 unlink( $debugLogFile );
342 }
343
344 /**
345 * @covers ::wfClientAcceptsGzip
346 */
347 public function testClientAcceptsGzipTest() {
348
349 $settings = [
350 'gzip' => true,
351 'bzip' => false,
352 '*' => false,
353 'compress, gzip' => true,
354 'gzip;q=1.0' => true,
355 'foozip' => false,
356 'foo*zip' => false,
357 'gzip;q=abcde' => true, // is this REALLY valid?
358 'gzip;q=12345678.9' => true,
359 ' gzip' => true,
360 ];
361
362 if ( isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) {
363 $old_server_setting = $_SERVER['HTTP_ACCEPT_ENCODING'];
364 }
365
366 foreach ( $settings as $encoding => $expect ) {
367 $_SERVER['HTTP_ACCEPT_ENCODING'] = $encoding;
368
369 $this->assertEquals( $expect, wfClientAcceptsGzip( true ),
370 "'$encoding' => " . wfBoolToStr( $expect ) );
371 }
372
373 if ( isset( $old_server_setting ) ) {
374 $_SERVER['HTTP_ACCEPT_ENCODING'] = $old_server_setting;
375 }
376 }
377
378 /**
379 * @covers ::wfPercent
380 */
381 public function testWfPercentTest() {
382
383 $pcts = [
384 [ 6 / 7, '0.86%', 2, false ],
385 [ 3 / 3, '1%' ],
386 [ 22 / 7, '3.14286%', 5 ],
387 [ 3 / 6, '0.5%' ],
388 [ 1 / 3, '0%', 0 ],
389 [ 10 / 3, '0%', -1 ],
390 [ 3 / 4 / 5, '0.1%', 1 ],
391 [ 6 / 7 * 8, '6.8571428571%', 10 ],
392 ];
393
394 foreach ( $pcts as $pct ) {
395 if ( !isset( $pct[2] ) ) {
396 $pct[2] = 2;
397 }
398 if ( !isset( $pct[3] ) ) {
399 $pct[3] = true;
400 }
401
402 $this->assertEquals( wfPercent( $pct[0], $pct[2], $pct[3] ), $pct[1], $pct[1] );
403 }
404 }
405
406 /**
407 * test @see wfShorthandToInteger()
408 * @dataProvider provideShorthand
409 * @covers ::wfShorthandToInteger
410 */
411 public function testWfShorthandToInteger( $shorthand, $expected ) {
412 $this->assertEquals( $expected,
413 wfShorthandToInteger( $shorthand )
414 );
415 }
416
417 public static function provideShorthand() {
418 // Syntax: [ shorthand, expected integer ]
419 return [
420 # Null, empty ...
421 [ '', -1 ],
422 [ ' ', -1 ],
423 [ null, -1 ],
424
425 # Failures returns 0 :(
426 [ 'ABCDEFG', 0 ],
427 [ 'Ak', 0 ],
428
429 # Int, strings with spaces
430 [ 1, 1 ],
431 [ ' 1 ', 1 ],
432 [ 1023, 1023 ],
433 [ ' 1023 ', 1023 ],
434
435 # kilo, Mega, Giga
436 [ '1k', 1024 ],
437 [ '1K', 1024 ],
438 [ '1m', 1024 * 1024 ],
439 [ '1M', 1024 * 1024 ],
440 [ '1g', 1024 * 1024 * 1024 ],
441 [ '1G', 1024 * 1024 * 1024 ],
442
443 # Negatives
444 [ -1, -1 ],
445 [ -500, -500 ],
446 [ '-500', -500 ],
447 [ '-1k', -1024 ],
448
449 # Zeroes
450 [ '0', 0 ],
451 [ '0k', 0 ],
452 [ '0M', 0 ],
453 [ '0G', 0 ],
454 [ '-0', 0 ],
455 [ '-0k', 0 ],
456 [ '-0M', 0 ],
457 [ '-0G', 0 ],
458 ];
459 }
460
461 /**
462 * @param string $old Text as it was in the database
463 * @param string $mine Text submitted while user was editing
464 * @param string $yours Text submitted by the user
465 * @param bool $expectedMergeResult Whether the merge should be a success
466 * @param string $expectedText Text after merge has been completed
467 *
468 * @dataProvider provideMerge()
469 * @group medium
470 * @covers ::wfMerge
471 */
472 public function testMerge( $old, $mine, $yours, $expectedMergeResult, $expectedText ) {
473 $this->markTestSkippedIfNoDiff3();
474
475 $mergedText = null;
476 $isMerged = wfMerge( $old, $mine, $yours, $mergedText );
477
478 $msg = 'Merge should be a ';
479 $msg .= $expectedMergeResult ? 'success' : 'failure';
480 $this->assertEquals( $expectedMergeResult, $isMerged, $msg );
481
482 if ( $isMerged ) {
483 // Verify the merged text
484 $this->assertEquals( $expectedText, $mergedText,
485 'is merged text as expected?' );
486 }
487 }
488
489 public static function provideMerge() {
490 $EXPECT_MERGE_SUCCESS = true;
491 $EXPECT_MERGE_FAILURE = false;
492
493 return [
494 // #0: clean merge
495 [
496 // old:
497 "one one one\n" . // trimmed
498 "\n" .
499 "two two two",
500
501 // mine:
502 "one one one ONE ONE\n" .
503 "\n" .
504 "two two two\n", // with tailing whitespace
505
506 // yours:
507 "one one one\n" .
508 "\n" .
509 "two two TWO TWO", // trimmed
510
511 // ok:
512 $EXPECT_MERGE_SUCCESS,
513
514 // result:
515 "one one one ONE ONE\n" .
516 "\n" .
517 "two two TWO TWO\n", // note: will always end in a newline
518 ],
519
520 // #1: conflict, fail
521 [
522 // old:
523 "one one one", // trimmed
524
525 // mine:
526 "one one one ONE ONE\n" .
527 "\n" .
528 "bla bla\n" .
529 "\n", // with tailing whitespace
530
531 // yours:
532 "one one one\n" .
533 "\n" .
534 "two two", // trimmed
535
536 $EXPECT_MERGE_FAILURE,
537
538 // result:
539 null,
540 ],
541 ];
542 }
543
544 /**
545 * @dataProvider provideMakeUrlIndexes()
546 * @covers ::wfMakeUrlIndexes
547 */
548 public function testMakeUrlIndexes( $url, $expected ) {
549 $index = wfMakeUrlIndexes( $url );
550 $this->assertEquals( $expected, $index, "wfMakeUrlIndexes(\"$url\")" );
551 }
552
553 public static function provideMakeUrlIndexes() {
554 return [
555 // Testcase for T30627
556 [
557 'https://example.org/test.cgi?id=12345',
558 [ 'https://org.example./test.cgi?id=12345' ]
559 ],
560 [
561 // mailtos are handled special
562 // is this really right though? that final . probably belongs earlier?
563 'mailto:wiki@wikimedia.org',
564 [ 'mailto:org.wikimedia@wiki.' ]
565 ],
566
567 // file URL cases per T30627...
568 [
569 // three slashes: local filesystem path Unix-style
570 'file:///whatever/you/like.txt',
571 [ 'file://./whatever/you/like.txt' ]
572 ],
573 [
574 // three slashes: local filesystem path Windows-style
575 'file:///c:/whatever/you/like.txt',
576 [ 'file://./c:/whatever/you/like.txt' ]
577 ],
578 [
579 // two slashes: UNC filesystem path Windows-style
580 'file://intranet/whatever/you/like.txt',
581 [ 'file://intranet./whatever/you/like.txt' ]
582 ],
583 // Multiple-slash cases that can sorta work on Mozilla
584 // if you hack it just right are kinda pathological,
585 // and unreliable cross-platform or on IE which means they're
586 // unlikely to appear on intranets.
587 // Those will survive the algorithm but with results that
588 // are less consistent.
589
590 // protocol-relative URL cases per T31854...
591 [
592 '//example.org/test.cgi?id=12345',
593 [
594 'http://org.example./test.cgi?id=12345',
595 'https://org.example./test.cgi?id=12345'
596 ]
597 ],
598 ];
599 }
600
601 /**
602 * @dataProvider provideWfMatchesDomainList
603 * @covers ::wfMatchesDomainList
604 */
605 public function testWfMatchesDomainList( $url, $domains, $expected, $description ) {
606 $actual = wfMatchesDomainList( $url, $domains );
607 $this->assertEquals( $expected, $actual, $description );
608 }
609
610 public static function provideWfMatchesDomainList() {
611 $a = [];
612 $protocols = [ 'HTTP' => 'http:', 'HTTPS' => 'https:', 'protocol-relative' => '' ];
613 foreach ( $protocols as $pDesc => $p ) {
614 $a = array_merge( $a, [
615 [
616 "$p//www.example.com",
617 [],
618 false,
619 "No matches for empty domains array, $pDesc URL"
620 ],
621 [
622 "$p//www.example.com",
623 [ 'www.example.com' ],
624 true,
625 "Exact match in domains array, $pDesc URL"
626 ],
627 [
628 "$p//www.example.com",
629 [ 'example.com' ],
630 true,
631 "Match without subdomain in domains array, $pDesc URL"
632 ],
633 [
634 "$p//www.example2.com",
635 [ 'www.example.com', 'www.example2.com', 'www.example3.com' ],
636 true,
637 "Exact match with other domains in array, $pDesc URL"
638 ],
639 [
640 "$p//www.example2.com",
641 [ 'example.com', 'example2.com', 'example3,com' ],
642 true,
643 "Match without subdomain with other domains in array, $pDesc URL"
644 ],
645 [
646 "$p//www.example4.com",
647 [ 'example.com', 'example2.com', 'example3,com' ],
648 false,
649 "Domain not in array, $pDesc URL"
650 ],
651 [
652 "$p//nds-nl.wikipedia.org",
653 [ 'nl.wikipedia.org' ],
654 false,
655 "Non-matching substring of domain, $pDesc URL"
656 ],
657 ] );
658 }
659
660 return $a;
661 }
662
663 /**
664 * @covers ::wfMkdirParents
665 */
666 public function testWfMkdirParents() {
667 // Should not return true if file exists instead of directory
668 $fname = $this->getNewTempFile();
669 MediaWiki\suppressWarnings();
670 $ok = wfMkdirParents( $fname );
671 MediaWiki\restoreWarnings();
672 $this->assertFalse( $ok );
673 }
674
675 /**
676 * @dataProvider provideWfShellWikiCmdList
677 * @covers ::wfShellWikiCmd
678 */
679 public function testWfShellWikiCmd( $script, $parameters, $options,
680 $expected, $description
681 ) {
682 if ( wfIsWindows() ) {
683 // Approximation that's good enough for our purposes just now
684 $expected = str_replace( "'", '"', $expected );
685 }
686 $actual = wfShellWikiCmd( $script, $parameters, $options );
687 $this->assertEquals( $expected, $actual, $description );
688 }
689
690 public function wfWikiID() {
691 $this->setMwGlobals( [
692 'wgDBname' => 'example',
693 'wgDBprefix' => '',
694 ] );
695 $this->assertEquals(
696 wfWikiID(),
697 'example'
698 );
699
700 $this->setMwGlobals( [
701 'wgDBname' => 'example',
702 'wgDBprefix' => 'mw_',
703 ] );
704 $this->assertEquals(
705 wfWikiID(),
706 'example-mw_'
707 );
708 }
709
710 public function testWfMemcKey() {
711 $cache = ObjectCache::getLocalClusterInstance();
712 $this->assertEquals(
713 $cache->makeKey( 'foo', 123, 'bar' ),
714 wfMemcKey( 'foo', 123, 'bar' )
715 );
716 }
717
718 public function testWfForeignMemcKey() {
719 $cache = ObjectCache::getLocalClusterInstance();
720 $keyspace = $this->readAttribute( $cache, 'keyspace' );
721 $this->assertEquals(
722 wfForeignMemcKey( $keyspace, '', 'foo', 'bar' ),
723 $cache->makeKey( 'foo', 'bar' )
724 );
725 }
726
727 public function testWfGlobalCacheKey() {
728 $cache = ObjectCache::getLocalClusterInstance();
729 $this->assertEquals(
730 $cache->makeGlobalKey( 'foo', 123, 'bar' ),
731 wfGlobalCacheKey( 'foo', 123, 'bar' )
732 );
733 }
734
735 public static function provideWfShellWikiCmdList() {
736 global $wgPhpCli;
737
738 return [
739 [ 'eval.php', [ '--help', '--test' ], [],
740 "'$wgPhpCli' 'eval.php' '--help' '--test'",
741 "Called eval.php --help --test" ],
742 [ 'eval.php', [ '--help', '--test space' ], [ 'php' => 'php5' ],
743 "'php5' 'eval.php' '--help' '--test space'",
744 "Called eval.php --help --test with php option" ],
745 [ 'eval.php', [ '--help', '--test', 'X' ], [ 'wrapper' => 'MWScript.php' ],
746 "'$wgPhpCli' 'MWScript.php' 'eval.php' '--help' '--test' 'X'",
747 "Called eval.php --help --test with wrapper option" ],
748 [
749 'eval.php',
750 [ '--help', '--test', 'y' ],
751 [ 'php' => 'php5', 'wrapper' => 'MWScript.php' ],
752 "'php5' 'MWScript.php' 'eval.php' '--help' '--test' 'y'",
753 "Called eval.php --help --test with wrapper and php option"
754 ],
755 ];
756 }
757 /* @todo many more! */
758 }