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