X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FStatusTest.php;h=ebc2d1080c6b353a6babb019ecaf9e09eb402800;hb=3706dcb;hp=782fab0c6bbd0bf689f6d098670ac38224faf4d8;hpb=c5f4cd0ad118ff38ded74fe882e997052452e77b;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/StatusTest.php b/tests/phpunit/includes/StatusTest.php index 782fab0c6b..ebc2d1080c 100644 --- a/tests/phpunit/includes/StatusTest.php +++ b/tests/phpunit/includes/StatusTest.php @@ -376,9 +376,9 @@ class StatusTest extends MediaWikiLangTestCase { $status->warning( 'fooBar!' ); $testCases['1StringWarning'] = [ $status, - "", + "⧼fooBar!⧽", "(wrap-short: (fooBar!))", - "

<fooBar!>\n

", + "

⧼fooBar!⧽\n

", "

(wrap-short: (fooBar!))\n

", ]; @@ -387,9 +387,9 @@ class StatusTest extends MediaWikiLangTestCase { $status->warning( 'fooBar2!' ); $testCases['2StringWarnings'] = [ $status, - "* \n* \n", + "* ⧼fooBar!⧽\n* ⧼fooBar2!⧽\n", "(wrap-long: * (fooBar!)\n* (fooBar2!)\n)", - "
  • <fooBar!>
  • \n
  • <fooBar2!>
\n", + "
  • ⧼fooBar!⧽
  • \n
  • ⧼fooBar2!⧽
\n", "

(wrap-long: * (fooBar!)\n

\n
  • (fooBar2!)
\n

)\n

", ]; @@ -397,9 +397,9 @@ class StatusTest extends MediaWikiLangTestCase { $status->warning( new Message( 'fooBar!', [ 'foo', 'bar' ] ) ); $testCases['1MessageWarning'] = [ $status, - "", + "⧼fooBar!⧽", "(wrap-short: (fooBar!: foo, bar))", - "

<fooBar!>\n

", + "

⧼fooBar!⧽\n

", "

(wrap-short: (fooBar!: foo, bar))\n

", ]; @@ -408,9 +408,9 @@ class StatusTest extends MediaWikiLangTestCase { $status->warning( new Message( 'fooBar2!' ) ); $testCases['2MessageWarnings'] = [ $status, - "* \n* \n", + "* ⧼fooBar!⧽\n* ⧼fooBar2!⧽\n", "(wrap-long: * (fooBar!: foo, bar)\n* (fooBar2!)\n)", - "
  • <fooBar!>
  • \n
  • <fooBar2!>
\n", + "
  • ⧼fooBar!⧽
  • \n
  • ⧼fooBar2!⧽
\n", "

(wrap-long: * (fooBar!: foo, bar)\n

\n
  • (fooBar2!)
\n

)\n

", ]; @@ -645,4 +645,66 @@ class StatusTest extends MediaWikiLangTestCase { ]; } + /** + * @dataProvider provideErrorsWarningsOnly + * @covers Status::getErrorsOnlyStatus + * @covers Status::getWarningsOnlyStatus + */ + public function testGetErrorsWarningsOnlyStatus( $errorText, $warningText, $type, $errorResult, + $warningResult + ) { + $status = Status::newGood(); + if ( $errorText ) { + $status->fatal( $errorText ); + } + if ( $warningText ) { + $status->warning( $warningText ); + } + $testStatus = $status->splitByErrorType()[$type]; + $this->assertEquals( $errorResult, $testStatus->getErrorsByType( 'error' ) ); + $this->assertEquals( $warningResult, $testStatus->getErrorsByType( 'warning' ) ); + } + + public static function provideErrorsWarningsOnly() { + return [ + [ + 'Just an error', + 'Just a warning', + 0, + [ + 0 => [ + 'type' => 'error', + 'message' => 'Just an error', + 'params' => [] + ], + ], + [], + ], [ + 'Just an error', + 'Just a warning', + 1, + [], + [ + 0 => [ + 'type' => 'warning', + 'message' => 'Just a warning', + 'params' => [] + ], + ], + ], [ + null, + null, + 1, + [], + [], + ], [ + null, + null, + 0, + [], + [], + ] + ]; + } + }