From 2df1b0f0bea6d005756a2bf4e66860c9d060cd22 Mon Sep 17 00:00:00 2001 From: addshore Date: Fri, 18 Oct 2013 12:53:29 +0200 Subject: [PATCH] Add @covers tags for /content files Change-Id: Ied40e5afb1027f7d8ff46ffbf722ff6558eed880 --- .../includes/content/ContentHandlerTest.php | 17 ++++++++++ .../includes/content/CssContentTest.php | 7 ++++ .../content/JavaScriptContentTest.php | 15 +++++++++ .../includes/content/TextContentTest.php | 32 +++++++++++++++++++ .../content/WikitextContentHandlerTest.php | 13 ++++++++ .../includes/content/WikitextContentTest.php | 18 +++++++++++ 6 files changed, 102 insertions(+) diff --git a/tests/phpunit/includes/content/ContentHandlerTest.php b/tests/phpunit/includes/content/ContentHandlerTest.php index c3455133e2..aedf594d26 100644 --- a/tests/phpunit/includes/content/ContentHandlerTest.php +++ b/tests/phpunit/includes/content/ContentHandlerTest.php @@ -70,6 +70,7 @@ class ContentHandlerTest extends MediaWikiTestCase { /** * @dataProvider dataGetDefaultModelFor + * @covers ContentHandler::getDefaultModelFor */ public function testGetDefaultModelFor( $title, $expectedModelId ) { $title = Title::newFromText( $title ); @@ -78,6 +79,7 @@ class ContentHandlerTest extends MediaWikiTestCase { /** * @dataProvider dataGetDefaultModelFor + * @covers ContentHandler::getForTitle */ public function testGetForTitle( $title, $expectedContentModel ) { $title = Title::newFromText( $title ); @@ -97,6 +99,7 @@ class ContentHandlerTest extends MediaWikiTestCase { /** * @dataProvider dataGetLocalizedName + * @covers ContentHandler::getLocalizedName */ public function testGetLocalizedName( $id, $expected ) { $name = ContentHandler::getLocalizedName( $id ); @@ -131,6 +134,7 @@ class ContentHandlerTest extends MediaWikiTestCase { /** * @dataProvider dataGetPageLanguage + * @covers ContentHandler::getPageLanguage */ public function testGetPageLanguage( $title, $expected ) { if ( is_string( $title ) ) { @@ -155,6 +159,7 @@ class ContentHandlerTest extends MediaWikiTestCase { /** * @dataProvider dataGetContentText_Null + * @covers ContentHandler::getContentText */ public function testGetContentText_Null( $contentHandlerTextFallback ) { $this->setMwGlobals( 'wgContentHandlerTextFallback', $contentHandlerTextFallback ); @@ -175,6 +180,7 @@ class ContentHandlerTest extends MediaWikiTestCase { /** * @dataProvider dataGetContentText_TextContent + * @covers ContentHandler::getContentText */ public function testGetContentText_TextContent( $contentHandlerTextFallback ) { $this->setMwGlobals( 'wgContentHandlerTextFallback', $contentHandlerTextFallback ); @@ -188,6 +194,7 @@ class ContentHandlerTest extends MediaWikiTestCase { /** * ContentHandler::getContentText should have thrown an exception for non-text Content object * @expectedException MWException + * @covers ContentHandler::getContentText */ public function testGetContentText_NonTextContent_fail() { $this->setMwGlobals( 'wgContentHandlerTextFallback', 'fail' ); @@ -197,6 +204,9 @@ class ContentHandlerTest extends MediaWikiTestCase { ContentHandler::getContentText( $content ); } + /** + * @covers ContentHandler::getContentText + */ public function testGetContentText_NonTextContent_serialize() { $this->setMwGlobals( 'wgContentHandlerTextFallback', 'serialize' ); @@ -206,6 +216,9 @@ class ContentHandlerTest extends MediaWikiTestCase { $this->assertEquals( $content->serialize(), $text ); } + /** + * @covers ContentHandler::getContentText + */ public function testGetContentText_NonTextContent_ignore() { $this->setMwGlobals( 'wgContentHandlerTextFallback', 'ignore' ); @@ -241,6 +254,7 @@ class ContentHandlerTest extends MediaWikiTestCase { /** * @dataProvider dataMakeContent + * @covers ContentHandler::makeContent */ public function testMakeContent( $data, $title, $modelId, $format, $expectedModelId, $expectedNativeData, $shouldFail ) { $title = Title::newFromText( $title ); @@ -270,6 +284,9 @@ class ContentHandlerTest extends MediaWikiTestCase { } */ + /** + * @covers ContentHandler::runLegacyHooks + */ public function testRunLegacyHooks() { Hooks::register( 'testRunLegacyHooks', __CLASS__ . '::dummyHookHandler' ); diff --git a/tests/phpunit/includes/content/CssContentTest.php b/tests/phpunit/includes/content/CssContentTest.php index 1c458203c7..bd6d41fe6f 100644 --- a/tests/phpunit/includes/content/CssContentTest.php +++ b/tests/phpunit/includes/content/CssContentTest.php @@ -50,12 +50,18 @@ class CssContentTest extends MediaWikiTestCase { ); } + /** + * @covers CssContent::getModel + */ public function testGetModel() { $content = $this->newContent( 'hello world.' ); $this->assertEquals( CONTENT_MODEL_CSS, $content->getModel() ); } + /** + * @covers CssContent::getContentHandler + */ public function testGetContentHandler() { $content = $this->newContent( 'hello world.' ); @@ -73,6 +79,7 @@ class CssContentTest extends MediaWikiTestCase { /** * @dataProvider dataEquals + * @covers CssContent::equals */ public function testEquals( Content $a, Content $b = null, $equal = false ) { $this->assertEquals( $equal, $a->equals( $b ) ); diff --git a/tests/phpunit/includes/content/JavaScriptContentTest.php b/tests/phpunit/includes/content/JavaScriptContentTest.php index 5c1ff8fb99..c8616ff006 100644 --- a/tests/phpunit/includes/content/JavaScriptContentTest.php +++ b/tests/phpunit/includes/content/JavaScriptContentTest.php @@ -89,6 +89,9 @@ class JavaScriptContentTest extends TextContentTest { ); } + /** + * @covers JavaScriptContent::addSectionHeader + */ public function testAddSectionHeader() { $content = $this->newContent( 'hello world' ); $c = $content->addSectionHeader( 'test' ); @@ -233,6 +236,9 @@ class JavaScriptContentTest extends TextContentTest { ); } + /** + * @covers JavaScriptContent::matchMagicWord + */ public function testMatchMagicWord() { $mw = MagicWord::get( "staticredirect" ); @@ -240,6 +246,9 @@ class JavaScriptContentTest extends TextContentTest { $this->assertFalse( $content->matchMagicWord( $mw ), "should not have matched magic word, since it's not wikitext" ); } + /** + * @covers JavaScriptContent::updateRedirect + */ public function testUpdateRedirect() { $target = Title::newFromText( "testUpdateRedirect_target" ); @@ -249,12 +258,18 @@ class JavaScriptContentTest extends TextContentTest { $this->assertTrue( $content->equals( $newContent ), "content should be unchanged since it's not wikitext" ); } + /** + * @covers JavaScriptContent::getModel + */ public function testGetModel() { $content = $this->newContent( "hello world." ); $this->assertEquals( CONTENT_MODEL_JAVASCRIPT, $content->getModel() ); } + /** + * @covers JavaScriptContent::getContentHandler + */ public function testGetContentHandler() { $content = $this->newContent( "hello world." ); diff --git a/tests/phpunit/includes/content/TextContentTest.php b/tests/phpunit/includes/content/TextContentTest.php index c7138b7dde..a1f099f31f 100644 --- a/tests/phpunit/includes/content/TextContentTest.php +++ b/tests/phpunit/includes/content/TextContentTest.php @@ -51,6 +51,7 @@ class TextContentTest extends MediaWikiLangTestCase { /** * @dataProvider dataGetParserOutput + * @covers TextContent::getParserOutput */ public function testGetParserOutput( $title, $model, $text, $expectedHtml, $expectedFields = null ) { $title = Title::newFromText( $title ); @@ -96,6 +97,7 @@ class TextContentTest extends MediaWikiLangTestCase { /** * @dataProvider dataPreSaveTransform + * @covers TextContent::preSaveTransform */ public function testPreSaveTransform( $text, $expected ) { global $wgContLang; @@ -119,6 +121,7 @@ class TextContentTest extends MediaWikiLangTestCase { /** * @dataProvider dataPreloadTransform + * @covers TextContent::preloadTransform */ public function testPreloadTransform( $text, $expected ) { global $wgContLang; @@ -140,6 +143,7 @@ class TextContentTest extends MediaWikiLangTestCase { /** * @dataProvider dataGetRedirectTarget + * @covers TextContent::getRedirectTarget */ public function testGetRedirectTarget( $text, $expected ) { $content = $this->newContent( $text ); @@ -154,6 +158,7 @@ class TextContentTest extends MediaWikiLangTestCase { /** * @dataProvider dataGetRedirectTarget + * @covers TextContent::isRedirect */ public function testIsRedirect( $text, $expected ) { $content = $this->newContent( $text ); @@ -209,6 +214,7 @@ class TextContentTest extends MediaWikiLangTestCase { /** * @dataProvider dataIsCountable * @group Database + * @covers TextContent::isCountable */ public function testIsCountable( $text, $hasLinks, $mode, $expected ) { $this->setMwGlobals( 'wgArticleCountMethod', $mode ); @@ -240,6 +246,7 @@ class TextContentTest extends MediaWikiLangTestCase { /** * @dataProvider dataGetTextForSummary + * @covers TextContent::getTextForSummary */ public function testGetTextForSummary( $text, $maxlength, $expected ) { $content = $this->newContent( $text ); @@ -247,12 +254,18 @@ class TextContentTest extends MediaWikiLangTestCase { $this->assertEquals( $expected, $content->getTextForSummary( $maxlength ) ); } + /** + * @covers TextContent::getTextForSearchIndex + */ public function testGetTextForSearchIndex() { $content = $this->newContent( 'hello world.' ); $this->assertEquals( 'hello world.', $content->getTextForSearchIndex() ); } + /** + * @covers TextContent::copy + */ public function testCopy() { $content = $this->newContent( 'hello world.' ); $copy = $content->copy(); @@ -261,30 +274,45 @@ class TextContentTest extends MediaWikiLangTestCase { $this->assertEquals( 'hello world.', $copy->getNativeData() ); } + /** + * @covers TextContent::getSize + */ public function testGetSize() { $content = $this->newContent( 'hello world.' ); $this->assertEquals( 12, $content->getSize() ); } + /** + * @covers TextContent::getNativeData + */ public function testGetNativeData() { $content = $this->newContent( 'hello world.' ); $this->assertEquals( 'hello world.', $content->getNativeData() ); } + /** + * @covers TextContent::getWikitextForTransclusion + */ public function testGetWikitextForTransclusion() { $content = $this->newContent( 'hello world.' ); $this->assertEquals( 'hello world.', $content->getWikitextForTransclusion() ); } + /** + * @covers TextContent::getModel + */ public function testGetModel() { $content = $this->newContent( "hello world." ); $this->assertEquals( CONTENT_MODEL_TEXT, $content->getModel() ); } + /** + * @covers TextContent::getContentHandler + */ public function testGetContentHandler() { $content = $this->newContent( "hello world." ); @@ -302,6 +330,7 @@ class TextContentTest extends MediaWikiLangTestCase { /** * @dataProvider dataIsEmpty + * @covers TextContent::isEmpty */ public function testIsEmpty( $text, $empty ) { $content = $this->newContent( $text ); @@ -321,6 +350,7 @@ class TextContentTest extends MediaWikiLangTestCase { /** * @dataProvider dataEquals + * @covers TextContent::equals */ public function testEquals( Content $a, Content $b = null, $equal = false ) { $this->assertEquals( $equal, $a->equals( $b ) ); @@ -342,6 +372,7 @@ class TextContentTest extends MediaWikiLangTestCase { /** * @dataProvider dataGetDeletionUpdates + * @covers TextContent::getDeletionUpdates */ public function testDeletionUpdates( $title, $model, $text, $expectedStuff ) { $ns = $this->getDefaultWikitextNS(); @@ -410,6 +441,7 @@ class TextContentTest extends MediaWikiLangTestCase { /** * @dataProvider provideConvert + * @covers TextContent::convert */ public function testConvert( $text, $model, $lossy, $expectedNative ) { $content = $this->newContent( $text ); diff --git a/tests/phpunit/includes/content/WikitextContentHandlerTest.php b/tests/phpunit/includes/content/WikitextContentHandlerTest.php index d213251583..75a727840b 100644 --- a/tests/phpunit/includes/content/WikitextContentHandlerTest.php +++ b/tests/phpunit/includes/content/WikitextContentHandlerTest.php @@ -16,6 +16,9 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase { $this->handler = ContentHandler::getForModelID( CONTENT_MODEL_WIKITEXT ); } + /** + * @covers WikitextContentHandler::serializeContent + */ public function testSerializeContent() { $content = new WikitextContent( 'hello world' ); @@ -30,6 +33,9 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase { } } + /** + * @covers WikitextContentHandler::unserializeContent + */ public function testUnserializeContent() { $content = $this->handler->unserializeContent( 'hello world' ); $this->assertEquals( 'hello world', $content->getNativeData() ); @@ -45,6 +51,9 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase { } } + /** + * @covers WikitextContentHandler::makeEmptyContent + */ public function testMakeEmptyContent() { $content = $this->handler->makeEmptyContent(); @@ -64,6 +73,7 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase { * @dataProvider provideMakeRedirectContent * @param Title|string $title Title object or string for Title::newFromText() * @param string $expected Serialized form of the content object built + * @covers WikitextContentHandler::makeRedirectContent */ public function testMakeRedirectContent( $title, $expected ) { global $wgContLang; @@ -92,6 +102,7 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase { /** * @dataProvider dataIsSupportedFormat + * @covers WikitextContentHandler::isSupportedFormat */ public function testIsSupportedFormat( $format, $supported ) { $this->assertEquals( $supported, $this->handler->isSupportedFormat( $format ) ); @@ -131,6 +142,7 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase { /** * @dataProvider dataMerge3 + * @covers WikitextContentHandler::merge3 */ public function testMerge3( $old, $mine, $yours, $expected ) { $this->checkHasDiff3(); @@ -188,6 +200,7 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase { /** * @dataProvider dataGetAutosummary + * @covers WikitextContentHandler::getAutosummary */ public function testGetAutosummary( $old, $new, $flags, $expected ) { $oldContent = is_null( $old ) ? null : new WikitextContent( $old ); diff --git a/tests/phpunit/includes/content/WikitextContentTest.php b/tests/phpunit/includes/content/WikitextContentTest.php index 37b01fdeaf..9f20073d2d 100644 --- a/tests/phpunit/includes/content/WikitextContentTest.php +++ b/tests/phpunit/includes/content/WikitextContentTest.php @@ -64,6 +64,7 @@ more stuff /** * @dataProvider dataGetSecondaryDataUpdates * @group Database + * @covers WikitextContent::getSecondaryDataUpdates */ public function testGetSecondaryDataUpdates( $title, $model, $text, $expectedStuff ) { $ns = $this->getDefaultWikitextNS(); @@ -116,6 +117,7 @@ just a test" /** * @dataProvider dataGetSection + * @covers WikitextContent::getSection */ public function testGetSection( $text, $sectionId, $expectedText ) { $content = $this->newContent( $text ); @@ -167,6 +169,7 @@ just a test" /** * @dataProvider dataReplaceSection + * @covers WikitextContent::replaceSection */ public function testReplaceSection( $text, $section, $with, $sectionTitle, $expected ) { $content = $this->newContent( $text ); @@ -175,6 +178,9 @@ just a test" $this->assertEquals( $expected, is_null( $c ) ? null : $c->getNativeData() ); } + /** + * @covers WikitextContent::addSectionHeader + */ public function testAddSectionHeader() { $content = $this->newContent( 'hello world' ); $content = $content->addSectionHeader( 'test' ); @@ -319,6 +325,9 @@ just a test" ); } + /** + * @covers WikitextContent::matchMagicWord + */ public function testMatchMagicWord() { $mw = MagicWord::get( "staticredirect" ); @@ -329,6 +338,9 @@ just a test" $this->assertFalse( $content->matchMagicWord( $mw ), "should not have matched magic word" ); } + /** + * @covers WikitextContent::updateRedirect + */ public function testUpdateRedirect() { $target = Title::newFromText( "testUpdateRedirect_target" ); @@ -348,12 +360,18 @@ just a test" $this->assertEquals( $target->getFullText(), $newContent->getRedirectTarget()->getFullText() ); } + /** + * @covers WikitextContent::getModel + */ public function testGetModel() { $content = $this->newContent( "hello world." ); $this->assertEquals( CONTENT_MODEL_WIKITEXT, $content->getModel() ); } + /** + * @covers WikitextContent::getContentHandler + */ public function testGetContentHandler() { $content = $this->newContent( "hello world." ); -- 2.20.1