From 876b33bb4beb3c9b4f09ac78d0e6910c3e1d5daa Mon Sep 17 00:00:00 2001 From: addshore Date: Sat, 25 Jan 2014 16:11:57 +0100 Subject: [PATCH] Add test that covers Status::fatal Change-Id: I7cb1e19569f77df5230808d7b35200b0ec9a6698 --- tests/phpunit/includes/StatusTest.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/phpunit/includes/StatusTest.php b/tests/phpunit/includes/StatusTest.php index aa5367ec9d..08c1470b09 100644 --- a/tests/phpunit/includes/StatusTest.php +++ b/tests/phpunit/includes/StatusTest.php @@ -166,6 +166,29 @@ class StatusTest extends MediaWikiLangTestCase { } } + /** + * @dataProvider provideMockMessageDetails + * @covers Status::fatal + * @covers Status::getErrorsArray + * @covers Status::getStatusArray + */ + public function testFatalWithMessage( $mockDetails ) { + $status = new Status(); + $messages = $this->getMockMessages( $mockDetails ); + + foreach ( $messages as $message ) { + $status->fatal( $message ); + } + $errors = $status->getErrorsArray(); + + $this->assertEquals( count( $messages ), count( $errors ) ); + foreach ( $messages as $key => $message ) { + $expectedArray = array_merge( array( $message->getKey() ), $message->getParams() ); + $this->assertEquals( $errors[$key], $expectedArray ); + } + $this->assertFalse( $status->isOK() ); + } + protected function getMockMessage( $key = 'key', $params = array() ) { $message = $this->getMockBuilder( 'Message' ) ->disableOriginalConstructor() -- 2.20.1