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