From e6e9e54be45a5ebd67b5e183cc008d8f883190b9 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Thu, 22 Sep 2016 18:29:28 +0100 Subject: [PATCH] tests: Fix invalid @covers value in StatusTest.php Uusally, phpunit issues a warning and continues to generate the report but in this case it caused an early exit with no output. Follows-up 3706dcb5c. > Trying to @cover not existing method Status::getErrorsOnlyStatus. Also: * Increase coverage by adding @covers where missing. * Use setOK() internally. * Add test for 'ok' setter. Change-Id: If6db634079c857f02b2594be199e6910ec49a52a --- tests/phpunit/includes/StatusTest.php | 33 ++++++++++++++++++++------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/tests/phpunit/includes/StatusTest.php b/tests/phpunit/includes/StatusTest.php index ebc2d1080c..7e56ebf20b 100644 --- a/tests/phpunit/includes/StatusTest.php +++ b/tests/phpunit/includes/StatusTest.php @@ -57,9 +57,11 @@ class StatusTest extends MediaWikiLangTestCase { } /** + * Test 'ok' and 'errors' getters. * + * @covers Status::__get */ - public function testOkAndErrors() { + public function testOkAndErrorsGetters() { $status = Status::newGood( 'foo' ); $this->assertTrue( $status->ok ); $status = Status::newFatal( 'foo', 1, 2 ); @@ -76,6 +78,19 @@ class StatusTest extends MediaWikiLangTestCase { ); } + /** + * Test 'ok' setter. + * + * @covers Status::__set + */ + public function testOkSetter() { + $status = new Status(); + $status->ok = false; + $this->assertFalse( $status->isOK() ); + $status->ok = true; + $this->assertTrue( $status->isOK() ); + } + /** * @dataProvider provideSetResult * @covers Status::setResult @@ -98,11 +113,12 @@ class StatusTest extends MediaWikiLangTestCase { /** * @dataProvider provideIsOk - * @covers Status::isOk + * @covers Status::setOK + * @covers Status::isOK */ public function testIsOk( $ok ) { $status = new Status(); - $status->ok = $ok; + $status->setOK( $ok ); $this->assertEquals( $ok, $status->isOK() ); } @@ -128,7 +144,7 @@ class StatusTest extends MediaWikiLangTestCase { */ public function testIsGood( $ok, $errors, $expected ) { $status = new Status(); - $status->ok = $ok; + $status->setOK( $ok ); foreach ( $errors as $error ) { $status->warning( $error ); } @@ -171,6 +187,7 @@ class StatusTest extends MediaWikiLangTestCase { * @covers Status::error * @covers Status::getErrorsArray * @covers Status::getStatusArray + * @covers Status::getErrors */ public function testErrorWithMessage( $mockDetails ) { $status = new Status(); @@ -361,7 +378,7 @@ class StatusTest extends MediaWikiLangTestCase { ]; $status = new Status(); - $status->ok = false; + $status->setOK( false ); $testCases['GoodButNoError'] = [ $status, "Internal error: Status::getWikiText: Invalid result object: no error text but not OK\n", @@ -475,7 +492,7 @@ class StatusTest extends MediaWikiLangTestCase { ]; $status = new Status(); - $status->ok = false; + $status->setOK( false ); $testCases['GoodButNoError'] = [ $status, [ "Status::getMessage: Invalid result object: no error text but not OK\n" ], @@ -647,8 +664,8 @@ class StatusTest extends MediaWikiLangTestCase { /** * @dataProvider provideErrorsWarningsOnly - * @covers Status::getErrorsOnlyStatus - * @covers Status::getWarningsOnlyStatus + * @covers Status::splitByErrorType + * @covers StatusValue::splitByErrorType */ public function testGetErrorsWarningsOnlyStatus( $errorText, $warningText, $type, $errorResult, $warningResult -- 2.20.1