Addshore has uploaded a new change for review.
https://gerrit.wikimedia.org/r/91588
Change subject: @covers tags for inclues/*Test
......................................................................
@covers tags for inclues/*Test
Change-Id: Id28acdd8fe0028bf1e46344cfed131076c8f4c95
---
M tests/phpunit/includes/ArticleTablesTest.php
M tests/phpunit/includes/ArticleTest.php
M tests/phpunit/includes/BlockTest.php
M tests/phpunit/includes/CdbTest.php
M tests/phpunit/includes/CollationTest.php
M tests/phpunit/includes/DiffHistoryBlobTest.php
M tests/phpunit/includes/EditPageTest.php
M tests/phpunit/includes/ExternalStoreTest.php
M tests/phpunit/includes/ExtraParserTest.php
M tests/phpunit/includes/FauxRequestTest.php
M tests/phpunit/includes/FauxResponseTest.php
M tests/phpunit/includes/FormOptionsInitializationTest.php
M tests/phpunit/includes/FormOptionsTest.php
M tests/phpunit/includes/HTMLCheckMatrixTest.php
M tests/phpunit/includes/HashRingTest.php
M tests/phpunit/includes/HooksTest.php
M tests/phpunit/includes/HtmlFormatterTest.php
M tests/phpunit/includes/HtmlTest.php
M tests/phpunit/includes/LanguageConverterTest.php
M tests/phpunit/includes/WikiPageTest.php
20 files changed, 241 insertions(+), 27 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/88/91588/1
diff --git a/tests/phpunit/includes/ArticleTablesTest.php
b/tests/phpunit/includes/ArticleTablesTest.php
index 0f159ae..c749598 100644
--- a/tests/phpunit/includes/ArticleTablesTest.php
+++ b/tests/phpunit/includes/ArticleTablesTest.php
@@ -5,6 +5,10 @@
*/
class ArticleTablesTest extends MediaWikiLangTestCase {
+ /**
+ * @covers Title::getTemplateLinksFrom
+ * @covers Title::getLinksFrom
+ */
public function testbug14404() {
global $wgContLang, $wgLanguageCode, $wgLang;
diff --git a/tests/phpunit/includes/ArticleTest.php
b/tests/phpunit/includes/ArticleTest.php
index b4d6dca..84f900f 100644
--- a/tests/phpunit/includes/ArticleTest.php
+++ b/tests/phpunit/includes/ArticleTest.php
@@ -25,12 +25,16 @@
$this->article = null;
}
+ /**
+ * @covers Article::__get
+ */
public function testImplementsGetMagic() {
$this->assertEquals( false, $this->article->mLatest, "Article
__get magic" );
}
/**
* @depends testImplementsGetMagic
+ * @covers Article::__set
*/
public function testImplementsSetMagic() {
$this->article->mLatest = 2;
@@ -39,6 +43,7 @@
/**
* @depends testImplementsSetMagic
+ * @covers Article::__call
*/
public function testImplementsCallMagic() {
$this->article->mLatest = 33;
@@ -46,6 +51,10 @@
$this->assertEquals( 33, $this->article->getLatest(), "Article
__call magic" );
}
+ /**
+ * @covers Article::__get
+ * @covers Article::__set
+ */
public function testGetOrSetOnNewProperty() {
$this->article->ext_someNewProperty = 12;
$this->assertEquals( 12, $this->article->ext_someNewProperty,
@@ -58,6 +67,11 @@
/**
* Checks for the existence of the backwards compatibility static
functions (forwarders to WikiPage class)
+ * @covers Article::selectFields
+ * @covers Article::onArticleCreate
+ * @covers Article::onArticleDelete
+ * @covers Article::onArticleEdit
+ * @covers Article::getAutosummary
*/
public function testStaticFunctions() {
$this->hideDeprecated( 'Article::getAutosummary' );
@@ -74,19 +88,5 @@
"Article static functions" );
$this->assertTrue( is_string( CategoryPage::getAutosummary( '',
'', 0 ) ),
"Article static functions" );
- }
-
- public function testWikiPageFactory() {
- $title = Title::makeTitle( NS_FILE, 'Someimage.png' );
- $page = WikiPage::factory( $title );
- $this->assertEquals( 'WikiFilePage', get_class( $page ) );
-
- $title = Title::makeTitle( NS_CATEGORY, 'SomeCategory' );
- $page = WikiPage::factory( $title );
- $this->assertEquals( 'WikiCategoryPage', get_class( $page ) );
-
- $title = Title::makeTitle( NS_MAIN, 'SomePage' );
- $page = WikiPage::factory( $title );
- $this->assertEquals( 'WikiPage', get_class( $page ) );
}
}
diff --git a/tests/phpunit/includes/BlockTest.php
b/tests/phpunit/includes/BlockTest.php
index 21de098..f0049fe 100644
--- a/tests/phpunit/includes/BlockTest.php
+++ b/tests/phpunit/includes/BlockTest.php
@@ -6,7 +6,9 @@
*/
class BlockTest extends MediaWikiLangTestCase {
- private $block, $madeAt;
+ /** @var Block */
+ private $block;
+ private $madeAt;
/* variable used to save up the blockID we insert in this test suite */
private $blockId;
@@ -66,11 +68,17 @@
}
}
- public function testInitializerFunctionsReturnCorrectBlock() {
- // $this->dumpBlocks();
-
+ /**
+ * @covers Block::newFromTarget
+ */
+ public function testINewFromTargetReturnsCorrectBlock() {
$this->assertTrue( $this->block->equals( Block::newFromTarget(
'UTBlockee' ) ), "newFromTarget() returns the same block as the one that was
made" );
+ }
+ /**
+ * @covers Block::newFromID
+ */
+ public function testINewFromIDReturnsCorrectBlock() {
$this->assertTrue( $this->block->equals( Block::newFromID(
$this->blockId ) ), "newFromID() returns the same block as the one that was
made" );
}
@@ -90,6 +98,7 @@
* This stopped working with r84475 and friends: regression being fixed
for bug 29116.
*
* @dataProvider provideBug29116Data
+ * @covers Block::load
*/
public function testBug29116LoadWithEmptyIp( $vagueTarget ) {
$this->hideDeprecated( 'Block::load' );
@@ -110,6 +119,7 @@
* had. Regression bug 29116.
*
* @dataProvider provideBug29116Data
+ * @covers Block::newFromTarget
*/
public function testBug29116NewFromTargetWithEmptyIp( $vagueTarget ) {
$block = Block::newFromTarget( 'UTBlockee', $vagueTarget );
@@ -124,6 +134,9 @@
);
}
+ /**
+ * @covers Block::prevents
+ */
public function testBlockedUserCanNotCreateAccount() {
$username = 'BlockedUserToCreateAccountWith';
$u = User::newFromName( $username );
@@ -184,6 +197,9 @@
);
}
+ /**
+ * @covers Block::insert
+ */
public function testCrappyCrossWikiBlocks() {
// Delete the last round's block if it's still there
$oldBlock = Block::newFromTarget( 'UserOnForeignWiki' );
@@ -343,6 +359,8 @@
/**
* @dataProvider providerXff
+ * @covers Block::getBlocksForIPList
+ * @covers Block::chooseBlock
*/
public function testBlocksOnXff( $xff, $exCount, $exResult ) {
$list = array_map( 'trim', explode( ',', $xff ) );
diff --git a/tests/phpunit/includes/CdbTest.php
b/tests/phpunit/includes/CdbTest.php
index e3d9da7..4832ada 100644
--- a/tests/phpunit/includes/CdbTest.php
+++ b/tests/phpunit/includes/CdbTest.php
@@ -2,6 +2,8 @@
/**
* Test the CDB reader/writer
+ * @covers CdbWriter_PHP
+ * @covers CdbWriter_DBA
*/
class CdbTest extends MediaWikiTestCase {
diff --git a/tests/phpunit/includes/CollationTest.php
b/tests/phpunit/includes/CollationTest.php
index 43bb394..c6a7169 100644
--- a/tests/phpunit/includes/CollationTest.php
+++ b/tests/phpunit/includes/CollationTest.php
@@ -1,4 +1,12 @@
<?php
+
+/**
+ * Class CollationTest
+ * @covers Collation
+ * @covers IcuCollation
+ * @covers IdentityCollation
+ * @covers UppercaseCollation
+ */
class CollationTest extends MediaWikiLangTestCase {
protected function setUp() {
parent::setUp();
@@ -30,7 +38,7 @@
$this->assertStringStartsWith( $baseBin, $extendedBin, "$base
is not a prefix of $extended" );
}
- function prefixDataProvider() {
+ public static function prefixDataProvider() {
return array(
array( 'en', 'A', 'AA' ),
array( 'en', 'A', 'AAA' ),
@@ -63,7 +71,7 @@
$this->assertStringStartsNotWith( $baseBin, $extendedBin,
"$base is a prefix of $extended" );
}
- function notPrefixDataProvider() {
+ public static function notPrefixDataProvider() {
return array(
array( 'en', 'A', 'B' ),
array( 'en', 'AC', 'ABC' ),
diff --git a/tests/phpunit/includes/DiffHistoryBlobTest.php
b/tests/phpunit/includes/DiffHistoryBlobTest.php
index a4d5b91..76a9a10 100644
--- a/tests/phpunit/includes/DiffHistoryBlobTest.php
+++ b/tests/phpunit/includes/DiffHistoryBlobTest.php
@@ -23,6 +23,7 @@
/**
* Test for DiffHistoryBlob::xdiffAdler32()
* @dataProvider provideXdiffAdler32
+ * @covers DiffHistoryBlob::xdiffAdler32
*/
public function testXdiffAdler32( $input ) {
$xdiffHash = substr( xdiff_string_rabdiff( $input, '' ), 0, 4 );
diff --git a/tests/phpunit/includes/EditPageTest.php
b/tests/phpunit/includes/EditPageTest.php
index 87272a4..7d2b04f 100644
--- a/tests/phpunit/includes/EditPageTest.php
+++ b/tests/phpunit/includes/EditPageTest.php
@@ -13,6 +13,7 @@
/**
* @dataProvider provideExtractSectionTitle
+ * @covers EditPage::extractSectionTitle
*/
public function testExtractSectionTitle( $section, $title ) {
$extracted = EditPage::extractSectionTitle( $section );
@@ -59,7 +60,7 @@
* wrapper around assertEquals() which calls rrtrim() to normalize the
* expected and actual texts.
*/
- function assertEditedTextEquals( $expected, $actual, $msg = '' ) {
+ protected function assertEditedTextEquals( $expected, $actual, $msg =
'' ) {
return $this->assertEquals( rtrim( $expected ), rtrim( $actual
), $msg );
}
@@ -172,6 +173,10 @@
return $page;
}
+ /**
+ * @todo split into a dataprovider and test method
+ * @covers EditPage
+ */
public function testCreatePage() {
$this->assertEdit(
'EditPageTest_testCreatePage',
@@ -338,6 +343,7 @@
/**
* @dataProvider provideSectionEdit
+ * @covers EditPage
*/
public function testSectionEdit( $base, $section, $text, $summary,
$expected ) {
$edit = array(
@@ -432,6 +438,7 @@
/**
* @dataProvider provideAutoMerge
+ * @covers EditPage
*/
public function testAutoMerge( $baseUser, $text, $adamsEdit,
$bertasEdit,
$expectedCode, $expectedText, $message = null
diff --git a/tests/phpunit/includes/ExternalStoreTest.php
b/tests/phpunit/includes/ExternalStoreTest.php
index fcffcbc..ba155a4 100644
--- a/tests/phpunit/includes/ExternalStoreTest.php
+++ b/tests/phpunit/includes/ExternalStoreTest.php
@@ -5,6 +5,9 @@
class ExternalStoreTest extends MediaWikiTestCase {
+ /**
+ * @covers ExternalStore::fetchFromURL
+ */
public function testExternalFetchFromURL() {
$this->setMwGlobals( 'wgExternalStores', false );
diff --git a/tests/phpunit/includes/ExtraParserTest.php
b/tests/phpunit/includes/ExtraParserTest.php
index 6c67beb..dc19154 100644
--- a/tests/phpunit/includes/ExtraParserTest.php
+++ b/tests/phpunit/includes/ExtraParserTest.php
@@ -5,6 +5,11 @@
*/
class ExtraParserTest extends MediaWikiTestCase {
+ /** @var ParserOptions */
+ protected $options;
+ /** @var Parser */
+ protected $parser;
+
protected function setUp() {
parent::setUp();
@@ -26,7 +31,10 @@
MagicWord::clearCache();
}
- // Bug 8689 - Long numeric lines kill the parser
+ /**
+ * Bug 8689 - Long numeric lines kill the parser
+ * @covers Parser::parse
+ */
public function testBug8689() {
global $wgUser;
$longLine = '1.' . str_repeat( '1234567890', 100000 ) . "\n";
@@ -37,13 +45,19 @@
$this->parser->parse( $longLine, $t, $options
)->getText() );
}
- /* Test the parser entry points */
+ /**
+ * Test the parser entry points
+ * @covers Parser::parse
+ */
public function testParse() {
$title = Title::newFromText( __FUNCTION__ );
$parserOutput = $this->parser->parse( "Test\n{{Foo}}\n{{Bar}}",
$title, $this->options );
$this->assertEquals( "<p>Test\nContent of
<i>Template:Foo</i>\nContent of <i>Template:Bar</i>\n</p>",
$parserOutput->getText() );
}
+ /**
+ * @covers Parser::preSaveTransform
+ */
public function testPreSaveTransform() {
global $wgUser;
$title = Title::newFromText( __FUNCTION__ );
@@ -52,6 +66,9 @@
$this->assertEquals( "Test\nContent of
''Template:Foo''\n{{Bar}}", $outputText );
}
+ /**
+ * @covers Parser::preprocess
+ */
public function testPreprocess() {
$title = Title::newFromText( __FUNCTION__ );
$outputText = $this->parser->preprocess(
"Test\n{{Foo}}\n{{Bar}}", $title, $this->options );
@@ -61,6 +78,7 @@
/**
* cleanSig() makes all templates substs and removes tildes
+ * @covers Parser::cleanSig
*/
public function testCleanSig() {
$title = Title::newFromText( __FUNCTION__ );
@@ -71,6 +89,7 @@
/**
* cleanSig() should do nothing if disabled
+ * @covers Parser::cleanSig
*/
public function testCleanSigDisabled() {
$this->setMwGlobals( 'wgCleanSignatures', false );
@@ -84,6 +103,7 @@
/**
* cleanSigInSig() just removes tildes
* @dataProvider provideStringsForCleanSigInSig
+ * @covers Parser::cleanSigInSig
*/
public function testCleanSigInSig( $in, $out ) {
$this->assertEquals( Parser::cleanSigInSig( $in ), $out );
@@ -97,6 +117,9 @@
);
}
+ /**
+ * @covers Parser::getSection
+ */
public function testGetSection() {
$outputText2 = $this->parser->getSection( "Section 0\n==
Heading 1 ==\nSection 1\n=== Heading 2 ===\nSection 2\n== Heading 3 ==\nSection
3\n", 2 );
$outputText1 = $this->parser->getSection( "Section 0\n==
Heading 1 ==\nSection 1\n=== Heading 2 ===\nSection 2\n== Heading 3 ==\nSection
3\n", 1 );
@@ -105,6 +128,9 @@
$this->assertEquals( "== Heading 1 ==\nSection 1\n=== Heading 2
===\nSection 2", $outputText1 );
}
+ /**
+ * @covers Parser::replaceSection
+ */
public function testReplaceSection() {
$outputText = $this->parser->replaceSection( "Section 0\n==
Heading 1 ==\nSection 1\n=== Heading 2 ===\nSection 2\n== Heading 3 ==\nSection
3\n", 1, "New section 1" );
@@ -113,6 +139,7 @@
/**
* Templates and comments are not affected, but noinclude/onlyinclude
is.
+ * @covers Parser::getPreloadText
*/
public function testGetPreloadText() {
$title = Title::newFromText( __FUNCTION__ );
@@ -133,6 +160,7 @@
/**
* @group Database
+ * @covers Parser::parse
*/
public function testTrackingCategory() {
$title = Title::newFromText( __FUNCTION__ );
@@ -146,6 +174,7 @@
/**
* @group Database
+ * @covers Parser::parse
*/
public function testTrackingCategorySpecial() {
// Special pages shouldn't have tracking cats.
diff --git a/tests/phpunit/includes/FauxRequestTest.php
b/tests/phpunit/includes/FauxRequestTest.php
index 9f3aa11..3246410 100644
--- a/tests/phpunit/includes/FauxRequestTest.php
+++ b/tests/phpunit/includes/FauxRequestTest.php
@@ -2,6 +2,10 @@
class FauxRequestTest extends MediaWikiTestCase {
+ /**
+ * @covers FauxRequest::setHeader
+ * @covers FauxRequest::getHeader
+ */
public function testGetSetHeader() {
$value = 'test/test';
diff --git a/tests/phpunit/includes/FauxResponseTest.php
b/tests/phpunit/includes/FauxResponseTest.php
index f9ba1b3..7f41cfd 100644
--- a/tests/phpunit/includes/FauxResponseTest.php
+++ b/tests/phpunit/includes/FauxResponseTest.php
@@ -23,19 +23,28 @@
*/
class FauxResponseTest extends MediaWikiTestCase {
- var $response;
+ /** @var FauxResponse */
+ protected $response;
protected function setUp() {
parent::setUp();
$this->response = new FauxResponse;
}
+ /**
+ * @covers FauxResponse::getcookie
+ * @covers FauxResponse::setcookie
+ */
public function testCookie() {
$this->assertEquals( null, $this->response->getcookie( 'key' ),
'Non-existing cookie' );
$this->response->setcookie( 'key', 'val' );
$this->assertEquals( 'val', $this->response->getcookie( 'key'
), 'Existing cookie' );
}
+ /**
+ * @covers FauxResponse::getheader
+ * @covers FauxResponse::header
+ */
public function testHeader() {
$this->assertEquals( null, $this->response->getheader(
'Location' ), 'Non-existing header' );
@@ -52,6 +61,9 @@
$this->assertEquals( 'http://localhost/',
$this->response->getheader( 'LOCATION' ), 'Get header case insensitive' );
}
+ /**
+ * @covers FauxResponse::getStatusCode
+ */
public function testResponseCode() {
$this->response->header( 'HTTP/1.1 200' );
$this->assertEquals( 200, $this->response->getStatusCode(),
'Header with no message' );
diff --git a/tests/phpunit/includes/FormOptionsInitializationTest.php
b/tests/phpunit/includes/FormOptionsInitializationTest.php
index fb2304d..1531b56 100644
--- a/tests/phpunit/includes/FormOptionsInitializationTest.php
+++ b/tests/phpunit/includes/FormOptionsInitializationTest.php
@@ -35,7 +35,6 @@
*/
protected $object;
-
/**
* A new fresh and empty FormOptions object to test initialization
* with.
@@ -45,6 +44,9 @@
$this->object = new FormOptionsExposed();
}
+ /**
+ * @covers FormOptionsExposed::add
+ */
public function testAddStringOption() {
$this->object->add( 'foo', 'string value' );
$this->assertEquals(
@@ -60,6 +62,9 @@
);
}
+ /**
+ * @covers FormOptionsExposed::add
+ */
public function testAddIntegers() {
$this->object->add( 'one', 1 );
$this->object->add( 'negone', -1 );
diff --git a/tests/phpunit/includes/FormOptionsTest.php
b/tests/phpunit/includes/FormOptionsTest.php
index 0a13cfe..08d6ba8 100644
--- a/tests/phpunit/includes/FormOptionsTest.php
+++ b/tests/phpunit/includes/FormOptionsTest.php
@@ -60,6 +60,7 @@
/**
* Reuse helpers above assertGuessBoolean assertGuessInt
assertGuessString
+ * @covers FormOptions::guessType
*/
public function testGuessTypeDetection() {
$this->assertGuessBoolean( true );
@@ -78,12 +79,14 @@
/**
* @expectedException MWException
+ * @covers FormOptions::guessType
*/
public function testGuessTypeOnArrayThrowException() {
$this->object->guessType( array( 'foo' ) );
}
/**
* @expectedException MWException
+ * @covers FormOptions::guessType
*/
public function testGuessTypeOnNullThrowException() {
$this->object->guessType( null );
diff --git a/tests/phpunit/includes/HTMLCheckMatrixTest.php
b/tests/phpunit/includes/HTMLCheckMatrixTest.php
index 5bbafd3..39c3959 100644
--- a/tests/phpunit/includes/HTMLCheckMatrixTest.php
+++ b/tests/phpunit/includes/HTMLCheckMatrixTest.php
@@ -1,7 +1,8 @@
<?php
/**
- * Unit tests for the HTMLCheckMatrix form field
+ * Unit tests for the HTMLCheckMatrix + HTMLFormField
+ * @todo the tests for the two classes could be split up
*/
class HtmlCheckMatrixTest extends MediaWikiTestCase {
static private $defaultOptions = array(
@@ -10,6 +11,9 @@
'fieldname' => 'test',
);
+ /**
+ * @covers HTMLCheckMatrix::__construct
+ */
public function testPlainInstantiation() {
try {
$form = new HTMLCheckMatrix( array() );
@@ -21,11 +25,17 @@
$this->fail( 'Expected MWException indicating missing
parameters but none was thrown.' );
}
+ /**
+ * @covers HTMLCheckMatrix::__construct
+ */
public function testInstantiationWithMinimumRequiredParameters() {
$form = new HTMLCheckMatrix( self::$defaultOptions );
$this->assertTrue( true ); // form instantiation must throw
exception on failure
}
+ /**
+ * @covers HTMLFormField::validate
+ */
public function testValidateCallsUserDefinedValidationCallback() {
$called = false;
$field = new HTMLCheckMatrix( self::$defaultOptions + array(
@@ -38,6 +48,9 @@
$this->assertTrue( $called );
}
+ /**
+ * @covers HTMLFormField::validate
+ */
public function testValidateRequiresArrayInput() {
$field = new HTMLCheckMatrix( self::$defaultOptions );
$this->assertEquals( false, $this->validate( $field, null ) );
@@ -47,11 +60,17 @@
$this->assertEquals( true, $this->validate( $field, array() ) );
}
+ /**
+ * @covers HTMLFormField::validate
+ */
public function testValidateAllowsOnlyKnownTags() {
$field = new HTMLCheckMatrix( self::$defaultOptions );
$this->assertInternalType( 'string', $this->validate( $field,
array( 'foo' ) ) );
}
+ /**
+ * @covers HTMLFormField::validate
+ */
public function testValidateAcceptsPartialTagList() {
$field = new HTMLCheckMatrix( self::$defaultOptions );
$this->assertTrue( $this->validate( $field, array() ) );
@@ -65,6 +84,7 @@
* foreach ( $field->filterDataForSubmit( $data ) as $k => $v ) {
* $user->setOption( $k, $v );
* }
+ * @covers HTMLFormField::filterDataForSubmit
*/
public function testValuesForcedOnRemainOn() {
$field = new HTMLCheckMatrix( self::$defaultOptions + array(
@@ -79,6 +99,9 @@
$this->assertEquals( $expected, $field->filterDataForSubmit(
array() ) );
}
+ /**
+ * @covers HTMLFormField::filterDataForSubmit
+ */
public function testValuesForcedOffRemainOff() {
$field = new HTMLCheckMatrix( self::$defaultOptions + array(
'force-options-off' => array( 'c1-r2', 'c2-r2' ),
diff --git a/tests/phpunit/includes/HashRingTest.php
b/tests/phpunit/includes/HashRingTest.php
index 65f1369..68dfea1 100644
--- a/tests/phpunit/includes/HashRingTest.php
+++ b/tests/phpunit/includes/HashRingTest.php
@@ -4,6 +4,9 @@
* @group HashRing
*/
class HashRingTest extends MediaWikiTestCase {
+ /**
+ * @covers HashRing
+ */
public function testHashRing() {
$ring = new HashRing( array( 's1' => 1, 's2' => 1, 's3' => 2,
's4' => 2, 's5' => 2, 's6' => 3 ) );
diff --git a/tests/phpunit/includes/HooksTest.php
b/tests/phpunit/includes/HooksTest.php
index 81dd487..87af6c1 100644
--- a/tests/phpunit/includes/HooksTest.php
+++ b/tests/phpunit/includes/HooksTest.php
@@ -35,6 +35,7 @@
/**
* @dataProvider provideHooks
+ * @covers ::wfRunHooks
*/
public function testOldStyleHooks( $msg, array $hook, $expectedFoo,
$expectedBar ) {
global $wgHooks;
@@ -49,6 +50,8 @@
/**
* @dataProvider provideHooks
+ * @covers Hooks::register
+ * @covers Hooks::run
*/
public function testNewStyleHooks( $msg, $hook, $expectedFoo,
$expectedBar ) {
$foo = $bar = 'original';
@@ -60,6 +63,12 @@
$this->assertSame( $expectedBar, $bar, $msg );
}
+ /**
+ * @covers Hooks::isRegistered
+ * @covers Hooks::register
+ * @covers Hooks::getHandlers
+ * @covers Hooks::run
+ */
public function testNewStyleHookInteraction() {
global $wgHooks;
@@ -82,12 +91,16 @@
/**
* @expectedException MWException
+ * @covers Hooks::run
*/
public function testUncallableFunction() {
Hooks::register( 'MediaWikiHooksTest001',
'ThisFunctionDoesntExist' );
Hooks::run( 'MediaWikiHooksTest001', array() );
}
+ /**
+ * @covers Hooks::run
+ */
public function testFalseReturn() {
Hooks::register( 'MediaWikiHooksTest001', function ( &$foo ) {
return false;
@@ -104,6 +117,7 @@
/**
* @expectedException FatalError
+ * @covers Hooks::run
*/
public function testFatalError() {
Hooks::register( 'MediaWikiHooksTest001', function () {
diff --git a/tests/phpunit/includes/HtmlFormatterTest.php
b/tests/phpunit/includes/HtmlFormatterTest.php
index a37df74..7ef0b60 100644
--- a/tests/phpunit/includes/HtmlFormatterTest.php
+++ b/tests/phpunit/includes/HtmlFormatterTest.php
@@ -6,6 +6,7 @@
class HtmlFormatterTest extends MediaWikiTestCase {
/**
* @dataProvider getHtmlData
+ * @covers HtmlFormatter::getText
*/
public function testTransform( $input, $expected, $callback = false ) {
$input = self::normalize( $input );
diff --git a/tests/phpunit/includes/HtmlTest.php
b/tests/phpunit/includes/HtmlTest.php
index 1c62d03..21372a0 100644
--- a/tests/phpunit/includes/HtmlTest.php
+++ b/tests/phpunit/includes/HtmlTest.php
@@ -41,6 +41,9 @@
) );
}
+ /**
+ * @covers Html::element
+ */
public function testElementBasics() {
$this->assertEquals(
'<img>',
@@ -89,11 +92,15 @@
/**
* @dataProvider dataXmlMimeType
+ * @covers Html::isXmlMimeType
*/
public function testXmlMimeType( $mimetype, $isXmlMimeType ) {
$this->assertEquals( $isXmlMimeType, Html::isXmlMimeType(
$mimetype ) );
}
+ /**
+ * @covers HTML::expandAttributes
+ */
public function testExpandAttributesSkipsNullAndFalse() {
### EMPTY ########
@@ -111,6 +118,9 @@
);
}
+ /**
+ * @covers HTML::expandAttributes
+ */
public function testExpandAttributesForBooleans() {
$this->assertEquals(
'',
@@ -146,6 +156,7 @@
/**
* Test for Html::expandAttributes()
* Please note it output a string prefixed with a space!
+ * @covers Html::expandAttributes
*/
public function testExpandAttributesVariousExpansions() {
### NOT EMPTY ####
@@ -198,6 +209,7 @@
* Html::expandAttributes has special features for HTML
* attributes that use space separated lists and also
* allows arrays to be used as values.
+ * @covers Html::expandAttributes
*/
public function testExpandAttributesListValueAttributes() {
### STRING VALUES
@@ -249,6 +261,7 @@
/**
* Test feature added by r96188, let pass attributes values as
* a PHP array. Restricted to class,rel, accesskey.
+ * @covers Html::expandAttributes
*/
public function
testExpandAttributesSpaceSeparatedAttributesWithBoolean() {
$this->assertEquals(
@@ -273,6 +286,7 @@
* The later will take precedence.
*
* Feature added by r96188
+ * @covers Html::expandAttributes
*/
public function
testValueIsAuthoritativeInSpaceSeparatedAttributesArrays() {
$this->assertEquals(
@@ -285,6 +299,9 @@
);
}
+ /**
+ * @covers Html::namespaceSelector
+ */
public function testNamespaceSelector() {
$this->assertEquals(
'<select id=namespace name=namespace>' . "\n" .
@@ -415,6 +432,7 @@
/**
* @dataProvider provideHtml5InputTypes
+ * @covers Html::element
*/
public function testHtmlElementAcceptsNewHtml5TypesInHtml5Mode(
$HTML5InputType ) {
$this->assertEquals(
@@ -617,6 +635,9 @@
return $ret;
}
+ /**
+ * @covers Html::expandAttributes
+ */
public function testFormValidationBlacklist() {
$this->assertEmpty(
Html::expandAttributes( array( 'min' => 1, 'max' =>
100, 'pattern' => 'abc', 'required' => true, 'step' => 2 ) ),
diff --git a/tests/phpunit/includes/LanguageConverterTest.php
b/tests/phpunit/includes/LanguageConverterTest.php
index 7c2134b..d4ccca9 100644
--- a/tests/phpunit/includes/LanguageConverterTest.php
+++ b/tests/phpunit/includes/LanguageConverterTest.php
@@ -1,7 +1,9 @@
<?php
class LanguageConverterTest extends MediaWikiLangTestCase {
+ /** @var LanguageToTest */
protected $lang = null;
+ /** @var TestConverter */
protected $lc = null;
protected function setUp() {
@@ -30,10 +32,17 @@
parent::tearDown();
}
+ /**
+ * @covers LanguageConverter::getPreferredVariant
+ */
public function testGetPreferredVariantDefaults() {
$this->assertEquals( 'tg', $this->lc->getPreferredVariant() );
}
+ /**
+ * @covers LanguageConverter::getPreferredVariant
+ * @covers LanguageConverter::getHeaderVariant
+ */
public function testGetPreferredVariantHeaders() {
global $wgRequest;
$wgRequest->setHeader( 'Accept-Language', 'tg-latn' );
@@ -41,6 +50,10 @@
$this->assertEquals( 'tg-latn',
$this->lc->getPreferredVariant() );
}
+ /**
+ * @covers LanguageConverter::getPreferredVariant
+ * @covers LanguageConverter::getHeaderVariant
+ */
public function testGetPreferredVariantHeaderWeight() {
global $wgRequest;
$wgRequest->setHeader( 'Accept-Language', 'tg;q=1' );
@@ -48,6 +61,10 @@
$this->assertEquals( 'tg', $this->lc->getPreferredVariant() );
}
+ /**
+ * @covers LanguageConverter::getPreferredVariant
+ * @covers LanguageConverter::getHeaderVariant
+ */
public function testGetPreferredVariantHeaderWeight2() {
global $wgRequest;
$wgRequest->setHeader( 'Accept-Language', 'tg-latn;q=1' );
@@ -55,6 +72,10 @@
$this->assertEquals( 'tg-latn',
$this->lc->getPreferredVariant() );
}
+ /**
+ * @covers LanguageConverter::getPreferredVariant
+ * @covers LanguageConverter::getHeaderVariant
+ */
public function testGetPreferredVariantHeaderMulti() {
global $wgRequest;
$wgRequest->setHeader( 'Accept-Language', 'en, tg-latn;q=1' );
@@ -62,6 +83,9 @@
$this->assertEquals( 'tg-latn',
$this->lc->getPreferredVariant() );
}
+ /**
+ * @covers LanguageConverter::getPreferredVariant
+ */
public function testGetPreferredVariantUserOption() {
global $wgUser;
@@ -75,6 +99,10 @@
$this->assertEquals( 'tg-latn',
$this->lc->getPreferredVariant() );
}
+ /**
+ * @covers LanguageConverter::getPreferredVariant
+ * @covers LanguageConverter::getUserVariant
+ */
public function testGetPreferredVariantUserOptionForForeignLanguage() {
global $wgContLang, $wgUser;
@@ -89,6 +117,11 @@
$this->assertEquals( 'tg-latn',
$this->lc->getPreferredVariant() );
}
+ /**
+ * @covers LanguageConverter::getPreferredVariant
+ * @covers LanguageConverter::getUserVariant
+ * @covers LanguageConverter::getURLVariant
+ */
public function testGetPreferredVariantHeaderUserVsUrl() {
global $wgContLang, $wgRequest, $wgUser;
@@ -103,7 +136,9 @@
$this->assertEquals( 'tg', $this->lc->getPreferredVariant() );
}
-
+ /**
+ * @covers LanguageConverter::getPreferredVariant
+ */
public function testGetPreferredVariantDefaultLanguageVariant() {
global $wgDefaultLanguageVariant;
@@ -111,6 +146,10 @@
$this->assertEquals( 'tg-latn',
$this->lc->getPreferredVariant() );
}
+ /**
+ * @covers LanguageConverter::getPreferredVariant
+ * @covers LanguageConverter::getURLVariant
+ */
public function testGetPreferredVariantDefaultLanguageVsUrlVariant() {
global $wgDefaultLanguageVariant, $wgRequest, $wgContLang;
diff --git a/tests/phpunit/includes/WikiPageTest.php
b/tests/phpunit/includes/WikiPageTest.php
index e0d786b..1258eb1 100644
--- a/tests/phpunit/includes/WikiPageTest.php
+++ b/tests/phpunit/includes/WikiPageTest.php
@@ -1071,4 +1071,21 @@
$this->assertEquals( $expected, $text );
}
+
+ /**
+ * @covers WikiPage::factory
+ */
+ public function testWikiPageFactory() {
+ $title = Title::makeTitle( NS_FILE, 'Someimage.png' );
+ $page = WikiPage::factory( $title );
+ $this->assertEquals( 'WikiFilePage', get_class( $page ) );
+
+ $title = Title::makeTitle( NS_CATEGORY, 'SomeCategory' );
+ $page = WikiPage::factory( $title );
+ $this->assertEquals( 'WikiCategoryPage', get_class( $page ) );
+
+ $title = Title::makeTitle( NS_MAIN, 'SomePage' );
+ $page = WikiPage::factory( $title );
+ $this->assertEquals( 'WikiPage', get_class( $page ) );
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/91588
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id28acdd8fe0028bf1e46344cfed131076c8f4c95
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits