From aea1b27db02bdf9b60789d55db320792b7cbe2dd Mon Sep 17 00:00:00 2001 From: addshore Date: Thu, 24 Oct 2013 20:35:04 +0100 Subject: [PATCH] @covers tags for more test classes Change-Id: I19d49c279646a4b4c595700e53b790ba4eb9521e --- tests/phpunit/includes/MWFunctionTest.php | 3 ++ tests/phpunit/includes/MWNamespaceTest.php | 39 ++++++++++++++++++- tests/phpunit/includes/MessageTest.php | 34 ++++++++++++++++ tests/phpunit/includes/OutputPageTest.php | 5 +++ tests/phpunit/includes/PathRouterTest.php | 4 +- tests/phpunit/includes/db/ORMTableTest.php | 4 ++ tests/phpunit/includes/db/TestORMRowTest.php | 3 ++ tests/phpunit/includes/debug/MWDebugTest.php | 12 ++++++ .../includes/jobqueue/JobQueueTest.php | 19 ++++++++- .../phpunit/includes/json/FormatJsonTest.php | 3 ++ tests/phpunit/includes/normal/CleanUpTest.php | 3 ++ .../includes/search/SearchEngineTest.php | 9 ++++- .../specials/QueryAllSpecialPagesTest.php | 3 ++ 13 files changed, 135 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/includes/MWFunctionTest.php b/tests/phpunit/includes/MWFunctionTest.php index d86f2c9bc5..f2a720e829 100644 --- a/tests/phpunit/includes/MWFunctionTest.php +++ b/tests/phpunit/includes/MWFunctionTest.php @@ -1,5 +1,8 @@ assertFalse( MWNamespace::isMovable( NS_CATEGORY ) ); @@ -39,6 +42,7 @@ class MWNamespaceTest extends MediaWikiTestCase { /** * Please make sure to change testIsTalk() if you change the assertions below + * @covers MWNamespace::isSubject */ public function testIsSubject() { // Special namespaces @@ -59,6 +63,7 @@ class MWNamespaceTest extends MediaWikiTestCase { /** * Reverse of testIsSubject(). * Please update testIsSubject() if you change assertions below + * @covers MWNamespace::isTalk */ public function testIsTalk() { // Special namespaces @@ -77,6 +82,7 @@ class MWNamespaceTest extends MediaWikiTestCase { } /** + * @covers MWNamespace::getSubject */ public function testGetSubject() { // Special namespaces are their own subjects @@ -91,6 +97,7 @@ class MWNamespaceTest extends MediaWikiTestCase { * Regular getTalk() calls * Namespaces without a talk page (NS_MEDIA, NS_SPECIAL) are tested in * the function testGetTalkExceptions() + * @covers MWNamespace::getTalk */ public function testGetTalk() { $this->assertEquals( NS_TALK, MWNamespace::getTalk( NS_MAIN ) ); @@ -103,6 +110,7 @@ class MWNamespaceTest extends MediaWikiTestCase { * Exceptions with getTalk() * NS_MEDIA does not have talk pages. MediaWiki raise an exception for them. * @expectedException MWException + * @covers MWNamespace::getTalk */ public function testGetTalkExceptionsForNsMedia() { $this->assertNull( MWNamespace::getTalk( NS_MEDIA ) ); @@ -112,6 +120,7 @@ class MWNamespaceTest extends MediaWikiTestCase { * Exceptions with getTalk() * NS_SPECIAL does not have talk pages. MediaWiki raise an exception for them. * @expectedException MWException + * @covers MWNamespace::getTalk */ public function testGetTalkExceptionsForNsSpecial() { $this->assertNull( MWNamespace::getTalk( NS_SPECIAL ) ); @@ -121,6 +130,7 @@ class MWNamespaceTest extends MediaWikiTestCase { * Regular getAssociated() calls * Namespaces without an associated page (NS_MEDIA, NS_SPECIAL) are tested in * the function testGetAssociatedExceptions() + * @covers MWNamespace::getAssociated */ public function testGetAssociated() { $this->assertEquals( NS_TALK, MWNamespace::getAssociated( NS_MAIN ) ); @@ -132,6 +142,7 @@ class MWNamespaceTest extends MediaWikiTestCase { ### an exception for them. /** * @expectedException MWException + * @covers MWNamespace::getAssociated */ public function testGetAssociatedExceptionsForNsMedia() { $this->assertNull( MWNamespace::getAssociated( NS_MEDIA ) ); @@ -139,6 +150,7 @@ class MWNamespaceTest extends MediaWikiTestCase { /** * @expectedException MWException + * @covers MWNamespace::getAssociated */ public function testGetAssociatedExceptionsForNsSpecial() { $this->assertNull( MWNamespace::getAssociated( NS_SPECIAL ) ); @@ -161,6 +173,7 @@ class MWNamespaceTest extends MediaWikiTestCase { * Note if we add a namespace registration system with keys like 'MAIN' * we should add tests here for equivilance on things like 'MAIN' == 0 * and 'MAIN' == NS_MAIN. + * @covers MWNamespace::equals */ public function testEquals() { $this->assertTrue( MWNamespace::equals( NS_MAIN, NS_MAIN ) ); @@ -175,7 +188,7 @@ class MWNamespaceTest extends MediaWikiTestCase { } /** - * Test MWNamespace::subjectEquals + * @covers MWNamespace::subjectEquals */ public function testSubjectEquals() { $this->assertSameSubject( NS_MAIN, NS_MAIN ); @@ -191,6 +204,9 @@ class MWNamespaceTest extends MediaWikiTestCase { $this->assertDifferentSubject( NS_SPECIAL, NS_MAIN ); } + /** + * @covers MWNamespace::subjectEquals + */ public function testSpecialAndMediaAreDifferentSubjects() { $this->assertDifferentSubject( NS_MEDIA, NS_SPECIAL, @@ -249,6 +265,7 @@ class MWNamespaceTest extends MediaWikiTestCase { */ /** + * @covers MWNamespace::canTalk */ public function testCanTalk() { $this->assertCanNotTalk( NS_MEDIA ); @@ -265,6 +282,7 @@ class MWNamespaceTest extends MediaWikiTestCase { } /** + * @covers MWNamespace::isContent */ public function testIsContent() { // NS_MAIN is a content namespace per DefaultSettings.php @@ -285,6 +303,7 @@ class MWNamespaceTest extends MediaWikiTestCase { /** * Similar to testIsContent() but alters the $wgContentNamespaces * global variable. + * @covers MWNamespace::isContent */ public function testIsContentAdvanced() { global $wgContentNamespaces; @@ -301,6 +320,9 @@ class MWNamespaceTest extends MediaWikiTestCase { $this->assertIsContent( NS_MAIN ); } + /** + * @covers MWNamespace::isWatchable + */ public function testIsWatchable() { // Specials namespaces are not watchable $this->assertIsNotWatchable( NS_MEDIA ); @@ -315,6 +337,9 @@ class MWNamespaceTest extends MediaWikiTestCase { $this->assertIsWatchable( 101 ); } + /** + * @covers MWNamespace::hasSubpages + */ public function testHasSubpages() { global $wgNamespacesWithSubpages; @@ -338,6 +363,7 @@ class MWNamespaceTest extends MediaWikiTestCase { } /** + * @covers MWNamespace::getContentNamespaces */ public function testGetContentNamespaces() { global $wgContentNamespaces; @@ -388,6 +414,7 @@ class MWNamespaceTest extends MediaWikiTestCase { } /** + * @covers MWNamespace::getSubjectNamespaces */ public function testGetSubjectNamespaces() { $subjectsNS = MWNamespace::getSubjectNamespaces(); @@ -403,6 +430,7 @@ class MWNamespaceTest extends MediaWikiTestCase { } /** + * @covers MWNamespace::getTalkNamespaces */ public function testGetTalkNamespaces() { $talkNS = MWNamespace::getTalkNamespaces(); @@ -420,6 +448,7 @@ class MWNamespaceTest extends MediaWikiTestCase { /** * Some namespaces are always capitalized per code definition * in MWNamespace::$alwaysCapitalizedNamespaces + * @covers MWNamespace::isCapitalized */ public function testIsCapitalizedHardcodedAssertions() { // NS_MEDIA and NS_FILE are treated the same @@ -451,6 +480,7 @@ class MWNamespaceTest extends MediaWikiTestCase { * * Global setting correctness is tested against the NS_PROJECT and * NS_PROJECT_TALK namespaces since they are not hardcoded nor specials + * @covers MWNamespace::isCapitalized */ public function testIsCapitalizedWithWgCapitalLinks() { global $wgCapitalLinks; @@ -475,6 +505,7 @@ class MWNamespaceTest extends MediaWikiTestCase { * testing the $wgCapitalLinkOverrides global. * * @todo split groups of assertions in autonomous testing functions + * @covers MWNamespace::isCapitalized */ public function testIsCapitalizedWithWgCapitalLinkOverrides() { global $wgCapitalLinkOverrides; @@ -507,6 +538,9 @@ class MWNamespaceTest extends MediaWikiTestCase { $this->assertIsCapitalized( NS_PROJECT ); } + /** + * @covers MWNamespace::hasGenderDistinction + */ public function testHasGenderDistinction() { // Namespaces with gender distinctions $this->assertTrue( MWNamespace::hasGenderDistinction( NS_USER ) ); @@ -519,6 +553,9 @@ class MWNamespaceTest extends MediaWikiTestCase { $this->assertFalse( MWNamespace::hasGenderDistinction( NS_TALK ) ); } + /** + * @covers MWNamespace::isNonincludable + */ public function testIsNonincludable() { global $wgNonincludableNamespaces; diff --git a/tests/phpunit/includes/MessageTest.php b/tests/phpunit/includes/MessageTest.php index 1e18f975e0..71ebd6a7d2 100644 --- a/tests/phpunit/includes/MessageTest.php +++ b/tests/phpunit/includes/MessageTest.php @@ -10,6 +10,9 @@ class MessageTest extends MediaWikiLangTestCase { ) ); } + /** + * @covers Message::exists + */ public function testExists() { $this->assertTrue( wfMessage( 'mainpage' )->exists() ); $this->assertTrue( wfMessage( 'mainpage' )->params( array() )->exists() ); @@ -19,6 +22,9 @@ class MessageTest extends MediaWikiLangTestCase { $this->assertFalse( wfMessage( 'i-dont-exist-evar' )->rawParams( 'foo', 123 )->exists() ); } + /** + * @covers Message::__construct + */ public function testKey() { $this->assertInstanceOf( 'Message', wfMessage( 'mainpage' ) ); $this->assertInstanceOf( 'Message', wfMessage( 'i-dont-exist-evar' ) ); @@ -28,6 +34,9 @@ class MessageTest extends MediaWikiLangTestCase { $this->assertEquals( '<i-dont-exist-evar>', wfMessage( 'i-dont-exist-evar' )->escaped() ); } + /** + * @covers Message::inLanguage + */ public function testInLanguage() { $this->assertEquals( 'Main Page', wfMessage( 'mainpage' )->inLanguage( 'en' )->text() ); $this->assertEquals( 'Заглавная страница', wfMessage( 'mainpage' )->inLanguage( 'ru' )->text() ); @@ -35,6 +44,9 @@ class MessageTest extends MediaWikiLangTestCase { $this->assertEquals( 'Заглавная страница', wfMessage( 'mainpage' )->inLanguage( Language::factory( 'ru' ) )->text() ); } + /** + * @covers Message::__construct + */ public function testMessageParams() { $this->assertEquals( 'Return to $1.', wfMessage( 'returnto' )->text() ); $this->assertEquals( 'Return to $1.', wfMessage( 'returnto', array() )->text() ); @@ -42,6 +54,10 @@ class MessageTest extends MediaWikiLangTestCase { $this->assertEquals( 'You have foo (bar).', wfMessage( 'youhavenewmessages', array( 'foo', 'bar' ) )->text() ); } + /** + * @covers Message::__construct + * @covers Message::rawParams + */ public function testMessageParamSubstitution() { $this->assertEquals( '(Заглавная страница)', wfMessage( 'parentheses', 'Заглавная страница' )->plain() ); $this->assertEquals( '(Заглавная страница $1)', wfMessage( 'parentheses', 'Заглавная страница $1' )->plain() ); @@ -49,6 +65,10 @@ class MessageTest extends MediaWikiLangTestCase { $this->assertEquals( '(Заглавная страница $1)', wfMessage( 'parentheses' )->rawParams( 'Заглавная страница $1' )->plain() ); } + /** + * @covers Message::__construct + * @covers Message::params + */ public function testDeliciouslyManyParams() { $msg = new RawMessage( '$1$2$3$4$5$6$7$8$9$10$11$12' ); // One less than above has placeholders @@ -59,6 +79,13 @@ class MessageTest extends MediaWikiLangTestCase { /** * FIXME: This should not need database, but Language#formatExpiry does (bug 55912) * @group Database + * @todo this should be split up into multiple test methods + * @covers Message::numParams + * @covers Message::durationParams + * @covers Message::expiryParams + * @covers Message::timeperiodParams + * @covers Message::sizeParams + * @covers Message::bitrateParams */ public function testMessageParamTypes() { $lang = Language::factory( 'en' ); @@ -106,12 +133,18 @@ class MessageTest extends MediaWikiLangTestCase { ); } + /** + * @covers Message::inContentLanguage + */ public function testInContentLanguageDisabled() { $this->setMwGlobals( 'wgLang', Language::factory( 'fr' ) ); $this->assertEquals( 'Main Page', wfMessage( 'mainpage' )->inContentLanguage()->plain(), 'ForceUIMsg disabled' ); } + /** + * @covers Message::inContentLanguage + */ public function testInContentLanguageEnabled() { $this->setMwGlobals( array( 'wgLang' => Language::factory( 'fr' ), @@ -123,6 +156,7 @@ class MessageTest extends MediaWikiLangTestCase { /** * @expectedException MWException + * @covers Message::inLanguage */ public function testInLanguageThrows() { wfMessage( 'foo' )->inLanguage( 123 ); diff --git a/tests/phpunit/includes/OutputPageTest.php b/tests/phpunit/includes/OutputPageTest.php index 56bb0fcef2..385cee5c32 100644 --- a/tests/phpunit/includes/OutputPageTest.php +++ b/tests/phpunit/includes/OutputPageTest.php @@ -6,6 +6,8 @@ * * @group Output * + * @todo factor tests in this class into providers and test methods + * */ class OutputPageTest extends MediaWikiTestCase { const SCREEN_MEDIA_QUERY = 'screen and (min-width: 982px)'; @@ -46,6 +48,7 @@ class OutputPageTest extends MediaWikiTestCase { /** * Tests print requests + * @covers OutputPage::transformCssMedia */ public function testPrintRequests() { $this->assertTransformCssMediaCase( array( @@ -79,6 +82,7 @@ class OutputPageTest extends MediaWikiTestCase { /** * Tests screen requests, without either query parameter set + * @covers OutputPage::transformCssMedia */ public function testScreenRequests() { $this->assertTransformCssMediaCase( array( @@ -114,6 +118,7 @@ class OutputPageTest extends MediaWikiTestCase { /** * Tests handheld behavior + * @covers OutputPage::transformCssMedia */ public function testHandheld() { $this->assertTransformCssMediaCase( array( diff --git a/tests/phpunit/includes/PathRouterTest.php b/tests/phpunit/includes/PathRouterTest.php index adfb215a78..8fea8cce11 100644 --- a/tests/phpunit/includes/PathRouterTest.php +++ b/tests/phpunit/includes/PathRouterTest.php @@ -1,10 +1,10 @@ * @author Daniel Kinzler */ + +/** + * @covers PageORMTableForTesting + */ class ORMTableTest extends MediaWikiTestCase { /** diff --git a/tests/phpunit/includes/db/TestORMRowTest.php b/tests/phpunit/includes/db/TestORMRowTest.php index f65642b800..c9459c9039 100644 --- a/tests/phpunit/includes/db/TestORMRowTest.php +++ b/tests/phpunit/includes/db/TestORMRowTest.php @@ -40,6 +40,9 @@ */ require_once __DIR__ . "/ORMRowTest.php"; +/** + * @covers TestORMRow + */ class TestORMRowTest extends ORMRowTest { /** diff --git a/tests/phpunit/includes/debug/MWDebugTest.php b/tests/phpunit/includes/debug/MWDebugTest.php index 6926b1c835..df7300066e 100644 --- a/tests/phpunit/includes/debug/MWDebugTest.php +++ b/tests/phpunit/includes/debug/MWDebugTest.php @@ -21,6 +21,9 @@ class MWDebugTest extends MediaWikiTestCase { parent::tearDown(); } + /** + * @covers MWDebug::log + */ public function testAddLog() { MWDebug::log( 'logging a string' ); $this->assertEquals( @@ -33,6 +36,9 @@ class MWDebugTest extends MediaWikiTestCase { ); } + /** + * @covers MWDebug::warning + */ public function testAddWarning() { MWDebug::warning( 'Warning message' ); $this->assertEquals( @@ -45,6 +51,9 @@ class MWDebugTest extends MediaWikiTestCase { ); } + /** + * @covers MWDebug::deprecated + */ public function testAvoidDuplicateDeprecations() { MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' ); MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' ); @@ -56,6 +65,9 @@ class MWDebugTest extends MediaWikiTestCase { ); } + /** + * @covers MWDebug::deprecated + */ public function testAvoidNonConsecutivesDuplicateDeprecations() { MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' ); MWDebug::warning( 'some warning' ); diff --git a/tests/phpunit/includes/jobqueue/JobQueueTest.php b/tests/phpunit/includes/jobqueue/JobQueueTest.php index 4e51c4fc16..3319490131 100644 --- a/tests/phpunit/includes/jobqueue/JobQueueTest.php +++ b/tests/phpunit/includes/jobqueue/JobQueueTest.php @@ -70,19 +70,31 @@ class JobQueueTest extends MediaWikiTestCase { /** * @dataProvider provider_queueLists + * @covers JobQueue::getWiki */ - public function testProperties( $queue, $recycles, $desc ) { + public function testGetWiki( $queue, $recycles, $desc ) { $queue = $this->$queue; if ( !$queue ) { $this->markTestSkipped( $desc ); } - $this->assertEquals( wfWikiID(), $queue->getWiki(), "Proper wiki ID ($desc)" ); + } + + /** + * @dataProvider provider_queueLists + * @covers JobQueue::getType + */ + public function testGetType( $queue, $recycles, $desc ) { + $queue = $this->$queue; + if ( !$queue ) { + $this->markTestSkipped( $desc ); + } $this->assertEquals( 'null', $queue->getType(), "Proper job type ($desc)" ); } /** * @dataProvider provider_queueLists + * @covers JobQueue */ public function testBasicOperations( $queue, $recycles, $desc ) { $queue = $this->$queue; @@ -157,6 +169,7 @@ class JobQueueTest extends MediaWikiTestCase { /** * @dataProvider provider_queueLists + * @covers JobQueue */ public function testBasicDeduplication( $queue, $recycles, $desc ) { $queue = $this->$queue; @@ -214,6 +227,7 @@ class JobQueueTest extends MediaWikiTestCase { /** * @dataProvider provider_queueLists + * @covers JobQueue */ public function testRootDeduplication( $queue, $recycles, $desc ) { $queue = $this->$queue; @@ -267,6 +281,7 @@ class JobQueueTest extends MediaWikiTestCase { /** * @dataProvider provider_fifoQueueLists + * @covers JobQueue */ public function testJobOrder( $queue, $recycles, $desc ) { $queue = $this->$queue; diff --git a/tests/phpunit/includes/json/FormatJsonTest.php b/tests/phpunit/includes/json/FormatJsonTest.php index eb024aba2a..3eeaaed533 100644 --- a/tests/phpunit/includes/json/FormatJsonTest.php +++ b/tests/phpunit/includes/json/FormatJsonTest.php @@ -1,5 +1,8 @@ + * @note Coverage will only ever show one of on of the Search* classes */ class SearchEngineTest extends MediaWikiLangTestCase { - protected $search, $pageList; + /** + * @var SearchEngine + */ + protected $search; + protected $pageList; /** * Checks for database type & version. diff --git a/tests/phpunit/includes/specials/QueryAllSpecialPagesTest.php b/tests/phpunit/includes/specials/QueryAllSpecialPagesTest.php index a806b4ac72..ba845ebe98 100644 --- a/tests/phpunit/includes/specials/QueryAllSpecialPagesTest.php +++ b/tests/phpunit/includes/specials/QueryAllSpecialPagesTest.php @@ -15,6 +15,9 @@ if ( !defined( 'MEDIAWIKI' ) ) { global $IP; require_once "$IP/includes/QueryPage.php"; // Needed to populate $wgQueryPages +/** + * @covers QueryPage + */ class QueryAllSpecialPagesTest extends MediaWikiTestCase { /** List query pages that can not be tested automatically */ -- 2.20.1