MediaWiki  1.28.0
StatusTest.php
Go to the documentation of this file.
1 <?php
2 
7 
8  public function testCanConstruct() {
9  new Status();
10  $this->assertTrue( true );
11  }
12 
17  public function testNewGood( $value = null ) {
19  $this->assertTrue( $status->isGood() );
20  $this->assertTrue( $status->isOK() );
21  $this->assertEquals( $value, $status->getValue() );
22  }
23 
24  public static function provideValues() {
25  return [
26  [],
27  [ 'foo' ],
28  [ [ 'foo' => 'bar' ] ],
29  [ new Exception() ],
30  [ 1234 ],
31  ];
32  }
33 
37  public function testNewFatalWithMessage() {
38  $message = $this->getMockBuilder( 'Message' )
39  ->disableOriginalConstructor()
40  ->getMock();
41 
42  $status = Status::newFatal( $message );
43  $this->assertFalse( $status->isGood() );
44  $this->assertFalse( $status->isOK() );
45  $this->assertEquals( $message, $status->getMessage() );
46  }
47 
51  public function testNewFatalWithString() {
52  $message = 'foo';
53  $status = Status::newFatal( $message );
54  $this->assertFalse( $status->isGood() );
55  $this->assertFalse( $status->isOK() );
56  $this->assertEquals( $message, $status->getMessage()->getKey() );
57  }
58 
64  public function testOkAndErrorsGetters() {
65  $status = Status::newGood( 'foo' );
66  $this->assertTrue( $status->ok );
67  $status = Status::newFatal( 'foo', 1, 2 );
68  $this->assertFalse( $status->ok );
69  $this->assertArrayEquals(
70  [
71  [
72  'type' => 'error',
73  'message' => 'foo',
74  'params' => [ 1, 2 ]
75  ]
76  ],
77  $status->errors
78  );
79  }
80 
86  public function testOkSetter() {
87  $status = new Status();
88  $status->ok = false;
89  $this->assertFalse( $status->isOK() );
90  $status->ok = true;
91  $this->assertTrue( $status->isOK() );
92  }
93 
98  public function testSetResult( $ok, $value = null ) {
99  $status = new Status();
100  $status->setResult( $ok, $value );
101  $this->assertEquals( $ok, $status->isOK() );
102  $this->assertEquals( $value, $status->getValue() );
103  }
104 
105  public static function provideSetResult() {
106  return [
107  [ true ],
108  [ false ],
109  [ true, 'value' ],
110  [ false, 'value' ],
111  ];
112  }
113 
119  public function testIsOk( $ok ) {
120  $status = new Status();
121  $status->setOK( $ok );
122  $this->assertEquals( $ok, $status->isOK() );
123  }
124 
125  public static function provideIsOk() {
126  return [
127  [ true ],
128  [ false ],
129  ];
130  }
131 
135  public function testGetValue() {
136  $status = new Status();
137  $status->value = 'foobar';
138  $this->assertEquals( 'foobar', $status->getValue() );
139  }
140 
145  public function testIsGood( $ok, $errors, $expected ) {
146  $status = new Status();
147  $status->setOK( $ok );
148  foreach ( $errors as $error ) {
149  $status->warning( $error );
150  }
151  $this->assertEquals( $expected, $status->isGood() );
152  }
153 
154  public static function provideIsGood() {
155  return [
156  [ true, [], true ],
157  [ true, [ 'foo' ], false ],
158  [ false, [], false ],
159  [ false, [ 'foo' ], false ],
160  ];
161  }
162 
169  public function testWarningWithMessage( $mockDetails ) {
170  $status = new Status();
171  $messages = $this->getMockMessages( $mockDetails );
172 
173  foreach ( $messages as $message ) {
174  $status->warning( $message );
175  }
176  $warnings = $status->getWarningsArray();
177 
178  $this->assertEquals( count( $messages ), count( $warnings ) );
179  foreach ( $messages as $key => $message ) {
180  $expectedArray = array_merge( [ $message->getKey() ], $message->getParams() );
181  $this->assertEquals( $warnings[$key], $expectedArray );
182  }
183  }
184 
192  public function testErrorWithMessage( $mockDetails ) {
193  $status = new Status();
194  $messages = $this->getMockMessages( $mockDetails );
195 
196  foreach ( $messages as $message ) {
197  $status->error( $message );
198  }
199  $errors = $status->getErrorsArray();
200 
201  $this->assertEquals( count( $messages ), count( $errors ) );
202  foreach ( $messages as $key => $message ) {
203  $expectedArray = array_merge( [ $message->getKey() ], $message->getParams() );
204  $this->assertEquals( $errors[$key], $expectedArray );
205  }
206  }
207 
214  public function testFatalWithMessage( $mockDetails ) {
215  $status = new Status();
216  $messages = $this->getMockMessages( $mockDetails );
217 
218  foreach ( $messages as $message ) {
219  $status->fatal( $message );
220  }
221  $errors = $status->getErrorsArray();
222 
223  $this->assertEquals( count( $messages ), count( $errors ) );
224  foreach ( $messages as $key => $message ) {
225  $expectedArray = array_merge( [ $message->getKey() ], $message->getParams() );
226  $this->assertEquals( $errors[$key], $expectedArray );
227  }
228  $this->assertFalse( $status->isOK() );
229  }
230 
231  protected function getMockMessage( $key = 'key', $params = [] ) {
232  $message = $this->getMockBuilder( 'Message' )
233  ->disableOriginalConstructor()
234  ->getMock();
235  $message->expects( $this->atLeastOnce() )
236  ->method( 'getKey' )
237  ->will( $this->returnValue( $key ) );
238  $message->expects( $this->atLeastOnce() )
239  ->method( 'getParams' )
240  ->will( $this->returnValue( $params ) );
241  return $message;
242  }
243 
248  protected function getMockMessages( $messageDetails ) {
249  $messages = [];
250  foreach ( $messageDetails as $key => $paramsArray ) {
251  $messages[] = $this->getMockMessage( $key, $paramsArray );
252  }
253  return $messages;
254  }
255 
256  public static function provideMockMessageDetails() {
257  return [
258  [ [ 'key1' => [ 'foo' => 'bar' ] ] ],
259  [ [ 'key1' => [ 'foo' => 'bar' ], 'key2' => [ 'foo2' => 'bar2' ] ] ],
260  ];
261  }
262 
266  public function testMerge() {
267  $status1 = new Status();
268  $status2 = new Status();
269  $message1 = $this->getMockMessage( 'warn1' );
270  $message2 = $this->getMockMessage( 'error2' );
271  $status1->warning( $message1 );
272  $status2->error( $message2 );
273 
274  $status1->merge( $status2 );
275  $this->assertEquals(
276  2,
277  count( $status1->getWarningsArray() ) + count( $status1->getErrorsArray() )
278  );
279  }
280 
284  public function testMergeWithOverwriteValue() {
285  $status1 = new Status();
286  $status2 = new Status();
287  $message1 = $this->getMockMessage( 'warn1' );
288  $message2 = $this->getMockMessage( 'error2' );
289  $status1->warning( $message1 );
290  $status2->error( $message2 );
291  $status2->value = 'FooValue';
292 
293  $status1->merge( $status2, true );
294  $this->assertEquals(
295  2,
296  count( $status1->getWarningsArray() ) + count( $status1->getErrorsArray() )
297  );
298  $this->assertEquals( 'FooValue', $status1->getValue() );
299  }
300 
304  public function testHasMessage() {
305  $status = new Status();
306  $status->fatal( 'bad' );
307  $status->fatal( wfMessage( 'bad-msg' ) );
308  $this->assertTrue( $status->hasMessage( 'bad' ) );
309  $this->assertTrue( $status->hasMessage( 'bad-msg' ) );
310  $this->assertTrue( $status->hasMessage( wfMessage( 'bad-msg' ) ) );
311  $this->assertFalse( $status->hasMessage( 'good' ) );
312  }
313 
318  public function testCleanParams( $cleanCallback, $params, $expected ) {
319  $method = new ReflectionMethod( 'Status', 'cleanParams' );
320  $method->setAccessible( true );
321  $status = new Status();
322  $status->cleanCallback = $cleanCallback;
323 
324  $this->assertEquals( $expected, $method->invoke( $status, $params ) );
325  }
326 
327  public static function provideCleanParams() {
328  $cleanCallback = function ( $value ) {
329  return '-' . $value . '-';
330  };
331 
332  return [
333  [ false, [ 'foo' => 'bar' ], [ 'foo' => 'bar' ] ],
334  [ $cleanCallback, [ 'foo' => 'bar' ], [ 'foo' => '-bar-' ] ],
335  ];
336  }
337 
342  public function testGetWikiText(
343  Status $status, $wikitext, $wrappedWikitext, $html, $wrappedHtml
344  ) {
345  $this->assertEquals( $wikitext, $status->getWikiText() );
346 
347  $this->assertEquals( $wrappedWikitext, $status->getWikiText( 'wrap-short', 'wrap-long', 'qqx' ) );
348  }
349 
354  public function testGetHtml(
355  Status $status, $wikitext, $wrappedWikitext, $html, $wrappedHtml
356  ) {
357  $this->assertEquals( $html, $status->getHTML() );
358 
359  $this->assertEquals( $wrappedHtml, $status->getHTML( 'wrap-short', 'wrap-long', 'qqx' ) );
360  }
361 
367  public static function provideGetWikiTextAndHtml() {
368  $testCases = [];
369 
370  $testCases['GoodStatus'] = [
371  new Status(),
372  "Internal error: Status::getWikiText called for a good result, this is incorrect\n",
373  "(wrap-short: (internalerror_info: Status::getWikiText called for a good result, " .
374  "this is incorrect\n))",
375  "<p>Internal error: Status::getWikiText called for a good result, this is incorrect\n</p>",
376  "<p>(wrap-short: (internalerror_info: Status::getWikiText called for a good result, " .
377  "this is incorrect\n))\n</p>",
378  ];
379 
380  $status = new Status();
381  $status->setOK( false );
382  $testCases['GoodButNoError'] = [
383  $status,
384  "Internal error: Status::getWikiText: Invalid result object: no error text but not OK\n",
385  "(wrap-short: (internalerror_info: Status::getWikiText: Invalid result object: " .
386  "no error text but not OK\n))",
387  "<p>Internal error: Status::getWikiText: Invalid result object: no error text but not OK\n</p>",
388  "<p>(wrap-short: (internalerror_info: Status::getWikiText: Invalid result object: " .
389  "no error text but not OK\n))\n</p>",
390  ];
391 
392  $status = new Status();
393  $status->warning( 'fooBar!' );
394  $testCases['1StringWarning'] = [
395  $status,
396  "⧼fooBar!⧽",
397  "(wrap-short: (fooBar!))",
398  "<p>⧼fooBar!⧽\n</p>",
399  "<p>(wrap-short: (fooBar!))\n</p>",
400  ];
401 
402  $status = new Status();
403  $status->warning( 'fooBar!' );
404  $status->warning( 'fooBar2!' );
405  $testCases['2StringWarnings'] = [
406  $status,
407  "* ⧼fooBar!⧽\n* ⧼fooBar2!⧽\n",
408  "(wrap-long: * (fooBar!)\n* (fooBar2!)\n)",
409  "<ul><li> ⧼fooBar!⧽</li>\n<li> ⧼fooBar2!⧽</li></ul>\n",
410  "<p>(wrap-long: * (fooBar!)\n</p>\n<ul><li> (fooBar2!)</li></ul>\n<p>)\n</p>",
411  ];
412 
413  $status = new Status();
414  $status->warning( new Message( 'fooBar!', [ 'foo', 'bar' ] ) );
415  $testCases['1MessageWarning'] = [
416  $status,
417  "⧼fooBar!⧽",
418  "(wrap-short: (fooBar!: foo, bar))",
419  "<p>⧼fooBar!⧽\n</p>",
420  "<p>(wrap-short: (fooBar!: foo, bar))\n</p>",
421  ];
422 
423  $status = new Status();
424  $status->warning( new Message( 'fooBar!', [ 'foo', 'bar' ] ) );
425  $status->warning( new Message( 'fooBar2!' ) );
426  $testCases['2MessageWarnings'] = [
427  $status,
428  "* ⧼fooBar!⧽\n* ⧼fooBar2!⧽\n",
429  "(wrap-long: * (fooBar!: foo, bar)\n* (fooBar2!)\n)",
430  "<ul><li> ⧼fooBar!⧽</li>\n<li> ⧼fooBar2!⧽</li></ul>\n",
431  "<p>(wrap-long: * (fooBar!: foo, bar)\n</p>\n<ul><li> (fooBar2!)</li></ul>\n<p>)\n</p>",
432  ];
433 
434  return $testCases;
435  }
436 
437  private static function sanitizedMessageParams( Message $message ) {
438  return array_map( function ( $p ) {
439  return $p instanceof Message
440  ? [
441  'key' => $p->getKey(),
442  'params' => self::sanitizedMessageParams( $p ),
443  'lang' => $p->getLanguage()->getCode(),
444  ]
445  : $p;
446  }, $message->getParams() );
447  }
448 
453  public function testGetMessage(
454  Status $status, $expectedParams = [], $expectedKey, $expectedWrapper
455  ) {
456  $message = $status->getMessage( null, null, 'qqx' );
457  $this->assertInstanceOf( 'Message', $message );
458  $this->assertEquals( $expectedParams, self::sanitizedMessageParams( $message ),
459  'Message::getParams' );
460  $this->assertEquals( $expectedKey, $message->getKey(), 'Message::getKey' );
461 
462  $message = $status->getMessage( 'wrapper-short', 'wrapper-long' );
463  $this->assertInstanceOf( 'Message', $message );
464  $this->assertEquals( $expectedWrapper, $message->getKey(), 'Message::getKey with wrappers' );
465  $this->assertCount( 1, $message->getParams(), 'Message::getParams with wrappers' );
466 
467  $message = $status->getMessage( 'wrapper' );
468  $this->assertInstanceOf( 'Message', $message );
469  $this->assertEquals( 'wrapper', $message->getKey(), 'Message::getKey with wrappers' );
470  $this->assertCount( 1, $message->getParams(), 'Message::getParams with wrappers' );
471 
472  $message = $status->getMessage( false, 'wrapper' );
473  $this->assertInstanceOf( 'Message', $message );
474  $this->assertEquals( 'wrapper', $message->getKey(), 'Message::getKey with wrappers' );
475  $this->assertCount( 1, $message->getParams(), 'Message::getParams with wrappers' );
476  }
477 
484  public static function provideGetMessage() {
485  $testCases = [];
486 
487  $testCases['GoodStatus'] = [
488  new Status(),
489  [ "Status::getMessage called for a good result, this is incorrect\n" ],
490  'internalerror_info',
491  'wrapper-short'
492  ];
493 
494  $status = new Status();
495  $status->setOK( false );
496  $testCases['GoodButNoError'] = [
497  $status,
498  [ "Status::getMessage: Invalid result object: no error text but not OK\n" ],
499  'internalerror_info',
500  'wrapper-short'
501  ];
502 
503  $status = new Status();
504  $status->warning( 'fooBar!' );
505  $testCases['1StringWarning'] = [
506  $status,
507  [],
508  'fooBar!',
509  'wrapper-short'
510  ];
511 
512  $status = new Status();
513  $status->warning( 'fooBar!' );
514  $status->warning( 'fooBar2!' );
515  $testCases[ '2StringWarnings' ] = [
516  $status,
517  [
518  [ 'key' => 'fooBar!', 'params' => [], 'lang' => 'qqx' ],
519  [ 'key' => 'fooBar2!', 'params' => [], 'lang' => 'qqx' ]
520  ],
521  "* \$1\n* \$2",
522  'wrapper-long'
523  ];
524 
525  $status = new Status();
526  $status->warning( new Message( 'fooBar!', [ 'foo', 'bar' ] ) );
527  $testCases['1MessageWarning'] = [
528  $status,
529  [ 'foo', 'bar' ],
530  'fooBar!',
531  'wrapper-short'
532  ];
533 
534  $status = new Status();
535  $status->warning( new Message( 'fooBar!', [ 'foo', 'bar' ] ) );
536  $status->warning( new Message( 'fooBar2!' ) );
537  $testCases['2MessageWarnings'] = [
538  $status,
539  [
540  [ 'key' => 'fooBar!', 'params' => [ 'foo', 'bar' ], 'lang' => 'qqx' ],
541  [ 'key' => 'fooBar2!', 'params' => [], 'lang' => 'qqx' ]
542  ],
543  "* \$1\n* \$2",
544  'wrapper-long'
545  ];
546 
547  return $testCases;
548  }
549 
553  public function testReplaceMessage() {
554  $status = new Status();
555  $message = new Message( 'key1', [ 'foo1', 'bar1' ] );
556  $status->error( $message );
557  $newMessage = new Message( 'key2', [ 'foo2', 'bar2' ] );
558 
559  $status->replaceMessage( $message, $newMessage );
560 
561  $this->assertEquals( $newMessage, $status->errors[0]['message'] );
562  }
563 
567  public function testGetErrorMessage() {
568  $method = new ReflectionMethod( 'Status', 'getErrorMessage' );
569  $method->setAccessible( true );
570  $status = new Status();
571  $key = 'foo';
572  $params = [ 'bar' ];
573 
575  $message = $method->invoke( $status, array_merge( [ $key ], $params ) );
576  $this->assertInstanceOf( 'Message', $message );
577  $this->assertEquals( $key, $message->getKey() );
578  $this->assertEquals( $params, $message->getParams() );
579  }
580 
584  public function testGetErrorMessageArray() {
585  $method = new ReflectionMethod( 'Status', 'getErrorMessageArray' );
586  $method->setAccessible( true );
587  $status = new Status();
588  $key = 'foo';
589  $params = [ 'bar' ];
590 
592  $messageArray = $method->invoke(
593  $status,
594  [
595  array_merge( [ $key ], $params ),
596  array_merge( [ $key ], $params )
597  ]
598  );
599 
600  $this->assertInternalType( 'array', $messageArray );
601  $this->assertCount( 2, $messageArray );
602  foreach ( $messageArray as $message ) {
603  $this->assertInstanceOf( 'Message', $message );
604  $this->assertEquals( $key, $message->getKey() );
605  $this->assertEquals( $params, $message->getParams() );
606  }
607  }
608 
612  public function testGetErrorsByType() {
613  $status = new Status();
614  $warning = new Message( 'warning111' );
615  $error = new Message( 'error111' );
616  $status->warning( $warning );
617  $status->error( $error );
618 
619  $warnings = $status->getErrorsByType( 'warning' );
620  $errors = $status->getErrorsByType( 'error' );
621 
622  $this->assertCount( 1, $warnings );
623  $this->assertCount( 1, $errors );
624  $this->assertEquals( $warning, $warnings[0]['message'] );
625  $this->assertEquals( $error, $errors[0]['message'] );
626  }
627 
631  public function testWakeUpSanitizesCallback() {
632  $status = new Status();
633  $status->cleanCallback = function ( $value ) {
634  return '-' . $value . '-';
635  };
636  $status->__wakeup();
637  $this->assertEquals( false, $status->cleanCallback );
638  }
639 
644  public function testGetStatusArrayWithNonObjectMessages( $nonObjMsg ) {
645  $status = new Status();
646  if ( !array_key_exists( 1, $nonObjMsg ) ) {
647  $status->warning( $nonObjMsg[0] );
648  } else {
649  $status->warning( $nonObjMsg[0], $nonObjMsg[1] );
650  }
651 
652  $array = $status->getWarningsArray(); // We use getWarningsArray to access getStatusArray
653 
654  $this->assertEquals( 1, count( $array ) );
655  $this->assertEquals( $nonObjMsg, $array[0] );
656  }
657 
658  public static function provideNonObjectMessages() {
659  return [
660  [ [ 'ImaString', [ 'param1' => 'value1' ] ] ],
661  [ [ 'ImaString' ] ],
662  ];
663  }
664 
670  public function testGetErrorsWarningsOnlyStatus( $errorText, $warningText, $type, $errorResult,
671  $warningResult
672  ) {
674  if ( $errorText ) {
675  $status->fatal( $errorText );
676  }
677  if ( $warningText ) {
678  $status->warning( $warningText );
679  }
680  $testStatus = $status->splitByErrorType()[$type];
681  $this->assertEquals( $errorResult, $testStatus->getErrorsByType( 'error' ) );
682  $this->assertEquals( $warningResult, $testStatus->getErrorsByType( 'warning' ) );
683  }
684 
685  public static function provideErrorsWarningsOnly() {
686  return [
687  [
688  'Just an error',
689  'Just a warning',
690  0,
691  [
692  0 => [
693  'type' => 'error',
694  'message' => 'Just an error',
695  'params' => []
696  ],
697  ],
698  [],
699  ], [
700  'Just an error',
701  'Just a warning',
702  1,
703  [],
704  [
705  0 => [
706  'type' => 'warning',
707  'message' => 'Just a warning',
708  'params' => []
709  ],
710  ],
711  ], [
712  null,
713  null,
714  1,
715  [],
716  [],
717  ], [
718  null,
719  null,
720  0,
721  [],
722  [],
723  ]
724  ];
725  }
726 
727 }
testGetErrorMessage()
Status::getErrorMessage.
Definition: StatusTest.php:567
testMergeWithOverwriteValue()
Status::merge.
Definition: StatusTest.php:284
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
Definition: hooks.txt:1936
testFatalWithMessage($mockDetails)
provideMockMessageDetails Status::fatal Status::getErrorsArray Status::getStatusArray ...
Definition: StatusTest.php:214
testGetErrorMessageArray()
Status::getErrorMessageArray.
Definition: StatusTest.php:584
testCanConstruct()
Definition: StatusTest.php:8
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:189
testReplaceMessage()
Status::replaceMessage.
Definition: StatusTest.php:553
static newFatal($message)
Factory function for fatal errors.
Definition: StatusValue.php:63
static provideIsOk()
Definition: StatusTest.php:125
getWikiText($shortContext=false, $longContext=false, $lang=null)
Get the error list as a wikitext formatted list.
Definition: Status.php:177
testNewFatalWithMessage()
Status::newFatal.
Definition: StatusTest.php:37
testMerge()
Status::merge.
Definition: StatusTest.php:266
testOkSetter()
Test 'ok' setter.
Definition: StatusTest.php:86
assertArrayEquals(array $expected, array $actual, $ordered=false, $named=false)
Assert that two arrays are equal.
$value
testWarningWithMessage($mockDetails)
provideMockMessageDetails Status::warning Status::getWarningsArray Status::getStatusArray ...
Definition: StatusTest.php:169
testNewFatalWithString()
Status::newFatal.
Definition: StatusTest.php:51
testIsOk($ok)
provideIsOk Status::setOK Status::isOK
Definition: StatusTest.php:119
static provideIsGood()
Definition: StatusTest.php:154
testGetValue()
Status::getValue.
Definition: StatusTest.php:135
static sanitizedMessageParams(Message $message)
Definition: StatusTest.php:437
static provideNonObjectMessages()
Definition: StatusTest.php:658
getHTML($shortContext=false, $longContext=false, $lang=null)
Get the error message as HTML.
Definition: Status.php:315
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
Definition: hooks.txt:1936
getParams()
Returns the message parameters.
Definition: Message.php:340
testGetErrorsWarningsOnlyStatus($errorText, $warningText, $type, $errorResult, $warningResult)
provideErrorsWarningsOnly Status::splitByErrorType StatusValue::splitByErrorType
Definition: StatusTest.php:670
testHasMessage()
Status::hasMessage.
Definition: StatusTest.php:304
testGetStatusArrayWithNonObjectMessages($nonObjMsg)
provideNonObjectMessages Status::getStatusArray
Definition: StatusTest.php:644
static provideErrorsWarningsOnly()
Definition: StatusTest.php:685
testWakeUpSanitizesCallback()
Status::__wakeup.
Definition: StatusTest.php:631
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock()-offset Set to overwrite offset parameter in $wgRequest set to ''to unsetoffset-wrap String Wrap the message in html(usually something like"&lt
static provideSetResult()
Definition: StatusTest.php:105
static provideGetMessage()
Definition: StatusTest.php:484
static provideCleanParams()
Definition: StatusTest.php:327
testGetErrorsByType()
Status::getErrorsByType.
Definition: StatusTest.php:612
testGetHtml(Status $status, $wikitext, $wrappedWikitext, $html, $wrappedHtml)
provideGetWikiTextAndHtml Status::getHtml
Definition: StatusTest.php:354
$params
testGetMessage(Status $status, $expectedParams=[], $expectedKey, $expectedWrapper)
provideGetMessage Status::getMessage
Definition: StatusTest.php:453
Base class that store and restore the Language objects.
testNewGood($value=null)
provideValues Status::newGood
Definition: StatusTest.php:17
static provideGetWikiTextAndHtml()
Definition: StatusTest.php:367
static newGood($value=null)
Factory function for good results.
Definition: StatusValue.php:76
testErrorWithMessage($mockDetails)
provideMockMessageDetails Status::error Status::getErrorsArray Status::getStatusArray Status::getErro...
Definition: StatusTest.php:192
getMockMessage($key= 'key', $params=[])
Definition: StatusTest.php:231
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
static provideValues()
Definition: StatusTest.php:24
getMessage($shortContext=false, $longContext=false, $lang=null)
Get a bullet list of the errors as a Message object.
Definition: Status.php:233
testGetWikiText(Status $status, $wikitext, $wrappedWikitext, $html, $wrappedHtml)
provideGetWikiTextAndHtml Status::getWikiText
Definition: StatusTest.php:342
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
static provideMockMessageDetails()
Definition: StatusTest.php:256
testIsGood($ok, $errors, $expected)
provideIsGood Status::isGood
Definition: StatusTest.php:145
testCleanParams($cleanCallback, $params, $expected)
provideCleanParams Status::cleanParams
Definition: StatusTest.php:318
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
Definition: hooks.txt:1046
$messages
testOkAndErrorsGetters()
Test 'ok' and 'errors' getters.
Definition: StatusTest.php:64
testSetResult($ok, $value=null)
provideSetResult Status::setResult
Definition: StatusTest.php:98
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
Definition: hooks.txt:2491
getMockMessages($messageDetails)
Definition: StatusTest.php:248