From: addshore Date: Thu, 24 Oct 2013 16:45:52 +0000 (+0100) Subject: @covers tags for unit tests X-Git-Tag: 1.31.0-rc.0~18393^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=749599fc3cc41670d3cadee14980c115f726e003 @covers tags for unit tests Change-Id: I2b486b38326bf23bd379efba2142034e24c0745f --- diff --git a/tests/phpunit/includes/LicensesTest.php b/tests/phpunit/includes/LicensesTest.php index 478a2ffc2a..63b2c395bd 100644 --- a/tests/phpunit/includes/LicensesTest.php +++ b/tests/phpunit/includes/LicensesTest.php @@ -1,5 +1,8 @@ makeTitleAndParserOutput( "Testing", 111 ); @@ -86,6 +89,9 @@ class LinksUpdateTest extends MediaWikiTestCase { ), $update->getRemovedLinks() ); } + /** + * @covers LinksUpdate::addExternalLink + */ public function testUpdate_externallinks() { list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", 111 ); @@ -96,6 +102,9 @@ class LinksUpdateTest extends MediaWikiTestCase { ) ); } + /** + * @covers LinksUpdate::addCategory + */ public function testUpdate_categorylinks() { $this->setMwGlobals( 'wgCategoryCollation', 'uppercase' ); @@ -108,6 +117,9 @@ class LinksUpdateTest extends MediaWikiTestCase { ) ); } + /** + * @covers LinksUpdate::addInterwikiLink + */ public function testUpdate_iwlinks() { list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", 111 ); @@ -119,6 +131,9 @@ class LinksUpdateTest extends MediaWikiTestCase { ) ); } + /** + * @covers LinksUpdate::addTemplate + */ public function testUpdate_templatelinks() { list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", 111 ); @@ -129,6 +144,9 @@ class LinksUpdateTest extends MediaWikiTestCase { ) ); } + /** + * @covers LinksUpdate::addImage + */ public function testUpdate_imagelinks() { list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", 111 ); @@ -139,6 +157,9 @@ class LinksUpdateTest extends MediaWikiTestCase { ) ); } + /** + * @covers LinksUpdate::addLanguageLink + */ public function testUpdate_langlinks() { list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", 111 ); @@ -149,6 +170,9 @@ class LinksUpdateTest extends MediaWikiTestCase { ) ); } + /** + * @covers LinksUpdate::setProperty + */ public function testUpdate_page_props() { list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", 111 ); diff --git a/tests/phpunit/includes/LocalFileTest.php b/tests/phpunit/includes/LocalFileTest.php index 2501c78305..694f4aef35 100644 --- a/tests/phpunit/includes/LocalFileTest.php +++ b/tests/phpunit/includes/LocalFileTest.php @@ -3,6 +3,7 @@ /** * These tests should work regardless of $wgCapitalLinks * @group Database + * @todo Split tests into providers and test methods */ class LocalFileTest extends MediaWikiTestCase { @@ -35,24 +36,36 @@ class LocalFileTest extends MediaWikiTestCase { $this->file_lc = $this->repo_lc->newFile( 'test!' ); } + /** + * @covers File::getHashPath + */ public function testGetHashPath() { $this->assertEquals( '', $this->file_hl0->getHashPath() ); $this->assertEquals( 'a/a2/', $this->file_hl2->getHashPath() ); $this->assertEquals( 'c/c4/', $this->file_lc->getHashPath() ); } + /** + * @covers File::getRel + */ public function testGetRel() { $this->assertEquals( 'Test!', $this->file_hl0->getRel() ); $this->assertEquals( 'a/a2/Test!', $this->file_hl2->getRel() ); $this->assertEquals( 'c/c4/test!', $this->file_lc->getRel() ); } + /** + * @covers File::getUrlRel + */ public function testGetUrlRel() { $this->assertEquals( 'Test%21', $this->file_hl0->getUrlRel() ); $this->assertEquals( 'a/a2/Test%21', $this->file_hl2->getUrlRel() ); $this->assertEquals( 'c/c4/test%21', $this->file_lc->getUrlRel() ); } + /** + * @covers File::getArchivePath + */ public function testGetArchivePath() { $this->assertEquals( 'mwstore://local-backend/test-public/archive', $this->file_hl0->getArchivePath() ); $this->assertEquals( 'mwstore://local-backend/test-public/archive/a/a2', $this->file_hl2->getArchivePath() ); @@ -60,6 +73,9 @@ class LocalFileTest extends MediaWikiTestCase { $this->assertEquals( 'mwstore://local-backend/test-public/archive/a/a2/!', $this->file_hl2->getArchivePath( '!' ) ); } + /** + * @covers File::getThumbPath + */ public function testGetThumbPath() { $this->assertEquals( 'mwstore://local-backend/test-thumb/Test!', $this->file_hl0->getThumbPath() ); $this->assertEquals( 'mwstore://local-backend/test-thumb/a/a2/Test!', $this->file_hl2->getThumbPath() ); @@ -67,6 +83,9 @@ class LocalFileTest extends MediaWikiTestCase { $this->assertEquals( 'mwstore://local-backend/test-thumb/a/a2/Test!/x', $this->file_hl2->getThumbPath( 'x' ) ); } + /** + * @covers File::getArchiveUrl + */ public function testGetArchiveUrl() { $this->assertEquals( '/testurl/archive', $this->file_hl0->getArchiveUrl() ); $this->assertEquals( '/testurl/archive/a/a2', $this->file_hl2->getArchiveUrl() ); @@ -74,6 +93,9 @@ class LocalFileTest extends MediaWikiTestCase { $this->assertEquals( '/testurl/archive/a/a2/%21', $this->file_hl2->getArchiveUrl( '!' ) ); } + /** + * @covers File::getThumbUrl + */ public function testGetThumbUrl() { $this->assertEquals( '/testurl/thumb/Test%21', $this->file_hl0->getThumbUrl() ); $this->assertEquals( '/testurl/thumb/a/a2/Test%21', $this->file_hl2->getThumbUrl() ); @@ -81,6 +103,9 @@ class LocalFileTest extends MediaWikiTestCase { $this->assertEquals( '/testurl/thumb/a/a2/Test%21/x', $this->file_hl2->getThumbUrl( 'x' ) ); } + /** + * @covers File::getArchiveVirtualUrl + */ public function testGetArchiveVirtualUrl() { $this->assertEquals( 'mwrepo://test/public/archive', $this->file_hl0->getArchiveVirtualUrl() ); $this->assertEquals( 'mwrepo://test/public/archive/a/a2', $this->file_hl2->getArchiveVirtualUrl() ); @@ -88,6 +113,9 @@ class LocalFileTest extends MediaWikiTestCase { $this->assertEquals( 'mwrepo://test/public/archive/a/a2/%21', $this->file_hl2->getArchiveVirtualUrl( '!' ) ); } + /** + * @covers File::getThumbVirtualUrl + */ public function testGetThumbVirtualUrl() { $this->assertEquals( 'mwrepo://test/thumb/Test%21', $this->file_hl0->getThumbVirtualUrl() ); $this->assertEquals( 'mwrepo://test/thumb/a/a2/Test%21', $this->file_hl2->getThumbVirtualUrl() ); @@ -95,11 +123,17 @@ class LocalFileTest extends MediaWikiTestCase { $this->assertEquals( 'mwrepo://test/thumb/a/a2/Test%21/%21', $this->file_hl2->getThumbVirtualUrl( '!' ) ); } + /** + * @covers File::getUrl + */ public function testGetUrl() { $this->assertEquals( '/testurl/Test%21', $this->file_hl0->getUrl() ); $this->assertEquals( '/testurl/a/a2/Test%21', $this->file_hl2->getUrl() ); } + /** + * @covers ::wfLocalFile + */ public function testWfLocalFile() { $file = wfLocalFile( "File:Some_file_that_probably_doesn't exist.png" ); $this->assertThat( $file, $this->isInstanceOf( 'LocalFile' ), 'wfLocalFile() returns LocalFile for valid Titles' ); diff --git a/tests/phpunit/includes/LocalisationCacheTest.php b/tests/phpunit/includes/LocalisationCacheTest.php index b34847aa14..f98410a1b8 100644 --- a/tests/phpunit/includes/LocalisationCacheTest.php +++ b/tests/phpunit/includes/LocalisationCacheTest.php @@ -1,5 +1,8 @@ testMinifyOutput( $code, $expectedOutput ); diff --git a/tests/phpunit/includes/libs/GenericArrayObjectTest.php b/tests/phpunit/includes/libs/GenericArrayObjectTest.php index 7436c43c8d..e2ec47416c 100644 --- a/tests/phpunit/includes/libs/GenericArrayObjectTest.php +++ b/tests/phpunit/includes/libs/GenericArrayObjectTest.php @@ -83,6 +83,8 @@ abstract class GenericArrayObjectTest extends MediaWikiTestCase { * @since 1.20 * * @param array $elements + * + * @covers GenericArrayObject::__construct */ public function testConstructor( array $elements ) { $arrayObject = $this->getNew( $elements ); @@ -96,6 +98,8 @@ abstract class GenericArrayObjectTest extends MediaWikiTestCase { * @since 1.20 * * @param array $elements + * + * @covers GenericArrayObject::isEmpty */ public function testIsEmpty( array $elements ) { $arrayObject = $this->getNew( $elements ); @@ -109,6 +113,8 @@ abstract class GenericArrayObjectTest extends MediaWikiTestCase { * @since 1.20 * * @param GenericArrayObject $list + * + * @covers GenericArrayObject::offsetUnset */ public function testUnset( GenericArrayObject $list ) { if ( $list->isEmpty() ) { @@ -134,6 +140,8 @@ abstract class GenericArrayObjectTest extends MediaWikiTestCase { * @since 1.20 * * @param array $elements + * + * @covers GenericArrayObject::append */ public function testAppend( array $elements ) { $list = $this->getNew(); @@ -163,6 +171,8 @@ abstract class GenericArrayObjectTest extends MediaWikiTestCase { * @since 1.20 * * @param callback $function + * + * @covers GenericArrayObject::getObjectType */ protected function checkTypeChecks( $function ) { $excption = null; @@ -194,6 +204,8 @@ abstract class GenericArrayObjectTest extends MediaWikiTestCase { * @since 1.20 * * @param array $elements + * + * @covers GenericArrayObject::offsetSet */ public function testOffsetSet( array $elements ) { if ( $elements === array() ) { @@ -247,6 +259,10 @@ abstract class GenericArrayObjectTest extends MediaWikiTestCase { * @since 1.21 * * @param GenericArrayObject $list + * + * @covers GenericArrayObject::getSerializationData + * @covers GenericArrayObject::serialize + * @covers GenericArrayObject::unserialize */ public function testSerialization( GenericArrayObject $list ) { $serialization = serialize( $list ); diff --git a/tests/phpunit/includes/libs/IEUrlExtensionTest.php b/tests/phpunit/includes/libs/IEUrlExtensionTest.php index 66fe915afb..b7071230a3 100644 --- a/tests/phpunit/includes/libs/IEUrlExtensionTest.php +++ b/tests/phpunit/includes/libs/IEUrlExtensionTest.php @@ -2,8 +2,13 @@ /** * Tests for IEUrlExtension::findIE6Extension + * @todo tests below for findIE6Extension should be split into... + * ...a dataprovider and test method. */ class IEUrlExtensionTest extends MediaWikiTestCase { + /** + * @covers IEUrlExtension::findIE6Extension + */ public function testSimple() { $this->assertEquals( 'y', @@ -12,6 +17,9 @@ class IEUrlExtensionTest extends MediaWikiTestCase { ); } + /** + * @covers IEUrlExtension::findIE6Extension + */ public function testSimpleNoExt() { $this->assertEquals( '', @@ -20,6 +28,9 @@ class IEUrlExtensionTest extends MediaWikiTestCase { ); } + /** + * @covers IEUrlExtension::findIE6Extension + */ public function testEmpty() { $this->assertEquals( '', @@ -28,6 +39,9 @@ class IEUrlExtensionTest extends MediaWikiTestCase { ); } + /** + * @covers IEUrlExtension::findIE6Extension + */ public function testQuestionMark() { $this->assertEquals( '', @@ -36,6 +50,9 @@ class IEUrlExtensionTest extends MediaWikiTestCase { ); } + /** + * @covers IEUrlExtension::findIE6Extension + */ public function testExtQuestionMark() { $this->assertEquals( 'x', @@ -44,6 +61,9 @@ class IEUrlExtensionTest extends MediaWikiTestCase { ); } + /** + * @covers IEUrlExtension::findIE6Extension + */ public function testQuestionMarkExt() { $this->assertEquals( 'x', @@ -52,6 +72,9 @@ class IEUrlExtensionTest extends MediaWikiTestCase { ); } + /** + * @covers IEUrlExtension::findIE6Extension + */ public function testInvalidChar() { $this->assertEquals( '', @@ -60,6 +83,9 @@ class IEUrlExtensionTest extends MediaWikiTestCase { ); } + /** + * @covers IEUrlExtension::findIE6Extension + */ public function testInvalidCharThenExtension() { $this->assertEquals( 'x', @@ -68,6 +94,9 @@ class IEUrlExtensionTest extends MediaWikiTestCase { ); } + /** + * @covers IEUrlExtension::findIE6Extension + */ public function testMultipleQuestionMarks() { $this->assertEquals( 'c', @@ -76,6 +105,9 @@ class IEUrlExtensionTest extends MediaWikiTestCase { ); } + /** + * @covers IEUrlExtension::findIE6Extension + */ public function testExeException() { $this->assertEquals( 'd', @@ -84,6 +116,9 @@ class IEUrlExtensionTest extends MediaWikiTestCase { ); } + /** + * @covers IEUrlExtension::findIE6Extension + */ public function testExeException2() { $this->assertEquals( 'exe', @@ -92,6 +127,9 @@ class IEUrlExtensionTest extends MediaWikiTestCase { ); } + /** + * @covers IEUrlExtension::findIE6Extension + */ public function testHash() { $this->assertEquals( '', @@ -100,6 +138,9 @@ class IEUrlExtensionTest extends MediaWikiTestCase { ); } + /** + * @covers IEUrlExtension::findIE6Extension + */ public function testHash2() { $this->assertEquals( '', @@ -108,6 +149,9 @@ class IEUrlExtensionTest extends MediaWikiTestCase { ); } + /** + * @covers IEUrlExtension::findIE6Extension + */ public function testDotAtEnd() { $this->assertEquals( '', @@ -116,6 +160,9 @@ class IEUrlExtensionTest extends MediaWikiTestCase { ); } + /** + * @covers IEUrlExtension::findIE6Extension + */ public function testTwoDots() { $this->assertEquals( 'z', diff --git a/tests/phpunit/includes/libs/JavaScriptMinifierTest.php b/tests/phpunit/includes/libs/JavaScriptMinifierTest.php index ab72e3619f..62ee45a6cc 100644 --- a/tests/phpunit/includes/libs/JavaScriptMinifierTest.php +++ b/tests/phpunit/includes/libs/JavaScriptMinifierTest.php @@ -118,6 +118,7 @@ class JavaScriptMinifierTest extends MediaWikiTestCase { /** * @dataProvider provideCases + * @covers JavaScriptMinifier::minify */ public function testJavaScriptMinifierOutput( $code, $expectedOutput ) { $minified = JavaScriptMinifier::minify( $code ); @@ -152,6 +153,7 @@ class JavaScriptMinifierTest extends MediaWikiTestCase { /** * @dataProvider provideBug32548 + * @covers JavaScriptMinifier::minify */ public function testBug32548Exponent( $num ) { // Long line breaking was being incorrectly done between the base and diff --git a/tests/phpunit/includes/logging/LogFormatterTest.php b/tests/phpunit/includes/logging/LogFormatterTest.php index e8ccf433f9..9650fb1b34 100755 --- a/tests/phpunit/includes/logging/LogFormatterTest.php +++ b/tests/phpunit/includes/logging/LogFormatterTest.php @@ -61,6 +61,9 @@ class LogFormatterTest extends MediaWikiLangTestCase { return $logEntry; } + /** + * @covers LogFormatter::newFromEntry + */ public function testNormalLogParams() { $entry = $this->newLogEntry( 'test', array() ); $formatter = LogFormatter::newFromEntry( $entry ); @@ -99,6 +102,10 @@ class LogFormatterTest extends MediaWikiLangTestCase { $this->assertEquals( $titleLink, $paramsWithoutTools[2]['raw'] ); } + /** + * @covers LogFormatter::newFromEntry + * @covers LogFormatter::getActionText + */ public function testLogParamsTypeRaw() { $params = array( '4:raw:raw' => Linker::link( $this->title, null, array(), array() ) ); $expected = Linker::link( $this->title, null, array(), array() ); @@ -112,6 +119,10 @@ class LogFormatterTest extends MediaWikiLangTestCase { $this->assertEquals( $expected, $logParam ); } + /** + * @covers LogFormatter::newFromEntry + * @covers LogFormatter::getActionText + */ public function testLogParamsTypeMsg() { $params = array( '4:msg:msg' => 'log-description-phpunit' ); $expected = wfMessage( 'log-description-phpunit' )->text(); @@ -125,6 +136,10 @@ class LogFormatterTest extends MediaWikiLangTestCase { $this->assertEquals( $expected, $logParam ); } + /** + * @covers LogFormatter::newFromEntry + * @covers LogFormatter::getActionText + */ public function testLogParamsTypeMsgContent() { $params = array( '4:msg-content:msgContent' => 'log-description-phpunit' ); $expected = wfMessage( 'log-description-phpunit' )->inContentLanguage()->text(); @@ -138,6 +153,10 @@ class LogFormatterTest extends MediaWikiLangTestCase { $this->assertEquals( $expected, $logParam ); } + /** + * @covers LogFormatter::newFromEntry + * @covers LogFormatter::getActionText + */ public function testLogParamsTypeNumber() { global $wgLang; @@ -153,6 +172,10 @@ class LogFormatterTest extends MediaWikiLangTestCase { $this->assertEquals( $expected, $logParam ); } + /** + * @covers LogFormatter::newFromEntry + * @covers LogFormatter::getActionText + */ public function testLogParamsTypeUserLink() { $params = array( '4:user-link:userLink' => $this->user->getName() ); $expected = Linker::userLink( @@ -169,6 +192,10 @@ class LogFormatterTest extends MediaWikiLangTestCase { $this->assertEquals( $expected, $logParam ); } + /** + * @covers LogFormatter::newFromEntry + * @covers LogFormatter::getActionText + */ public function testLogParamsTypeTitleLink() { $params = array( '4:title-link:titleLink' => $this->title->getText() ); $expected = Linker::link( $this->title, null, array(), array() ); @@ -182,6 +209,10 @@ class LogFormatterTest extends MediaWikiLangTestCase { $this->assertEquals( $expected, $logParam ); } + /** + * @covers LogFormatter::newFromEntry + * @covers LogFormatter::getActionText + */ public function testLogParamsTypePlain() { $params = array( '4:plain:plain' => 'Some plain text' ); $expected = 'Some plain text'; @@ -195,6 +226,10 @@ class LogFormatterTest extends MediaWikiLangTestCase { $this->assertEquals( $expected, $logParam ); } + /** + * @covers LogFormatter::newFromEntry + * @covers LogFormatter::getComment + */ public function testLogComment() { $entry = $this->newLogEntry( 'test', array() ); $formatter = LogFormatter::newFromEntry( $entry ); diff --git a/tests/phpunit/includes/media/ExifTest.php b/tests/phpunit/includes/media/ExifTest.php index dea36b039c..4cd2e8e3bb 100644 --- a/tests/phpunit/includes/media/ExifTest.php +++ b/tests/phpunit/includes/media/ExifTest.php @@ -1,4 +1,8 @@