*/
class ArticleTablesTest extends MediaWikiLangTestCase {
+ /**
+ * @covers Title::getTemplateLinksFrom
+ * @covers Title::getLinksFrom
+ */
public function testbug14404() {
global $wgContLang, $wgLanguageCode, $wgLang;
$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;
/**
* @depends testImplementsSetMagic
+ * @covers Article::__call
*/
public function testImplementsCallMagic() {
$this->article->mLatest = 33;
$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,
/**
* 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' );
$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 ) );
- }
}
*/
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;
}
}
- 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" );
}
* 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' );
* had. Regression bug 29116.
*
* @dataProvider provideBug29116Data
+ * @covers Block::newFromTarget
*/
public function testBug29116NewFromTargetWithEmptyIp( $vagueTarget ) {
$block = Block::newFromTarget( 'UTBlockee', $vagueTarget );
);
}
+ /**
+ * @covers Block::prevents
+ */
public function testBlockedUserCanNotCreateAccount() {
$username = 'BlockedUserToCreateAccountWith';
$u = User::newFromName( $username );
);
}
+ /**
+ * @covers Block::insert
+ */
public function testCrappyCrossWikiBlocks() {
// Delete the last round's block if it's still there
$oldBlock = Block::newFromTarget( 'UserOnForeignWiki' );
/**
* @dataProvider providerXff
+ * @covers Block::getBlocksForIPList
+ * @covers Block::chooseBlock
*/
public function testBlocksOnXff( $xff, $exCount, $exResult ) {
$list = array_map( 'trim', explode( ',', $xff ) );
/**
* Test the CDB reader/writer
+ * @covers CdbWriter_PHP
+ * @covers CdbWriter_DBA
*/
class CdbTest extends MediaWikiTestCase {
<?php
+
+/**
+ * Class CollationTest
+ * @covers Collation
+ * @covers IcuCollation
+ * @covers IdentityCollation
+ * @covers UppercaseCollation
+ */
class CollationTest extends MediaWikiLangTestCase {
protected function setUp() {
parent::setUp();
$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' ),
$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' ),
/**
* Test for DiffHistoryBlob::xdiffAdler32()
* @dataProvider provideXdiffAdler32
+ * @covers DiffHistoryBlob::xdiffAdler32
*/
public function testXdiffAdler32( $input ) {
$xdiffHash = substr( xdiff_string_rabdiff( $input, '' ), 0, 4 );
/**
* @dataProvider provideExtractSectionTitle
+ * @covers EditPage::extractSectionTitle
*/
public function testExtractSectionTitle( $section, $title ) {
$extracted = EditPage::extractSectionTitle( $section );
* 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 );
}
return $page;
}
+ /**
+ * @todo split into a dataprovider and test method
+ * @covers EditPage
+ */
public function testCreatePage() {
$this->assertEdit(
'EditPageTest_testCreatePage',
/**
* @dataProvider provideSectionEdit
+ * @covers EditPage
*/
public function testSectionEdit( $base, $section, $text, $summary, $expected ) {
$edit = array(
/**
* @dataProvider provideAutoMerge
+ * @covers EditPage
*/
public function testAutoMerge( $baseUser, $text, $adamsEdit, $bertasEdit,
$expectedCode, $expectedText, $message = null
class ExternalStoreTest extends MediaWikiTestCase {
+ /**
+ * @covers ExternalStore::fetchFromURL
+ */
public function testExternalFetchFromURL() {
$this->setMwGlobals( 'wgExternalStores', false );
*/
class ExtraParserTest extends MediaWikiTestCase {
+ /** @var ParserOptions */
+ protected $options;
+ /** @var Parser */
+ protected $parser;
+
protected function setUp() {
parent::setUp();
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";
$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__ );
$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 );
/**
* cleanSig() makes all templates substs and removes tildes
+ * @covers Parser::cleanSig
*/
public function testCleanSig() {
$title = Title::newFromText( __FUNCTION__ );
/**
* cleanSig() should do nothing if disabled
+ * @covers Parser::cleanSig
*/
public function testCleanSigDisabled() {
$this->setMwGlobals( 'wgCleanSignatures', false );
/**
* cleanSigInSig() just removes tildes
* @dataProvider provideStringsForCleanSigInSig
+ * @covers Parser::cleanSigInSig
*/
public function testCleanSigInSig( $in, $out ) {
$this->assertEquals( Parser::cleanSigInSig( $in ), $out );
);
}
+ /**
+ * @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 );
$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" );
/**
* Templates and comments are not affected, but noinclude/onlyinclude is.
+ * @covers Parser::getPreloadText
*/
public function testGetPreloadText() {
$title = Title::newFromText( __FUNCTION__ );
/**
* @group Database
+ * @covers Parser::parse
*/
public function testTrackingCategory() {
$title = Title::newFromText( __FUNCTION__ );
/**
* @group Database
+ * @covers Parser::parse
*/
public function testTrackingCategorySpecial() {
// Special pages shouldn't have tracking cats.
class FauxRequestTest extends MediaWikiTestCase {
+ /**
+ * @covers FauxRequest::setHeader
+ * @covers FauxRequest::getHeader
+ */
public function testGetSetHeader() {
$value = 'test/test';
*/
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' );
$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' );
*/
protected $object;
-
/**
* A new fresh and empty FormOptions object to test initialization
* with.
$this->object = new FormOptionsExposed();
}
+ /**
+ * @covers FormOptionsExposed::add
+ */
public function testAddStringOption() {
$this->object->add( 'foo', 'string value' );
$this->assertEquals(
);
}
+ /**
+ * @covers FormOptionsExposed::add
+ */
public function testAddIntegers() {
$this->object->add( 'one', 1 );
$this->object->add( 'negone', -1 );
/**
* Reuse helpers above assertGuessBoolean assertGuessInt assertGuessString
+ * @covers FormOptions::guessType
*/
public function testGuessTypeDetection() {
$this->assertGuessBoolean( true );
/**
* @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 );
<?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(
'fieldname' => 'test',
);
+ /**
+ * @covers HTMLCheckMatrix::__construct
+ */
public function testPlainInstantiation() {
try {
$form = new HTMLCheckMatrix( array() );
$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(
$this->assertTrue( $called );
}
+ /**
+ * @covers HTMLFormField::validate
+ */
public function testValidateRequiresArrayInput() {
$field = new HTMLCheckMatrix( self::$defaultOptions );
$this->assertEquals( false, $this->validate( $field, null ) );
$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() ) );
* foreach ( $field->filterDataForSubmit( $data ) as $k => $v ) {
* $user->setOption( $k, $v );
* }
+ * @covers HTMLFormField::filterDataForSubmit
*/
public function testValuesForcedOnRemainOn() {
$field = new HTMLCheckMatrix( self::$defaultOptions + array(
$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' ),
* @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 ) );
/**
* @dataProvider provideHooks
+ * @covers ::wfRunHooks
*/
public function testOldStyleHooks( $msg, array $hook, $expectedFoo, $expectedBar ) {
global $wgHooks;
/**
* @dataProvider provideHooks
+ * @covers Hooks::register
+ * @covers Hooks::run
*/
public function testNewStyleHooks( $msg, $hook, $expectedFoo, $expectedBar ) {
$foo = $bar = 'original';
$this->assertSame( $expectedBar, $bar, $msg );
}
+ /**
+ * @covers Hooks::isRegistered
+ * @covers Hooks::register
+ * @covers Hooks::getHandlers
+ * @covers Hooks::run
+ */
public function testNewStyleHookInteraction() {
global $wgHooks;
/**
* @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;
/**
* @expectedException FatalError
+ * @covers Hooks::run
*/
public function testFatalError() {
Hooks::register( 'MediaWikiHooksTest001', function () {
class HtmlFormatterTest extends MediaWikiTestCase {
/**
* @dataProvider getHtmlData
+ * @covers HtmlFormatter::getText
*/
public function testTransform( $input, $expected, $callback = false ) {
$input = self::normalize( $input );
) );
}
+ /**
+ * @covers Html::element
+ */
public function testElementBasics() {
$this->assertEquals(
'<img>',
/**
* @dataProvider dataXmlMimeType
+ * @covers Html::isXmlMimeType
*/
public function testXmlMimeType( $mimetype, $isXmlMimeType ) {
$this->assertEquals( $isXmlMimeType, Html::isXmlMimeType( $mimetype ) );
}
+ /**
+ * @covers HTML::expandAttributes
+ */
public function testExpandAttributesSkipsNullAndFalse() {
### EMPTY ########
);
}
+ /**
+ * @covers HTML::expandAttributes
+ */
public function testExpandAttributesForBooleans() {
$this->assertEquals(
'',
/**
* Test for Html::expandAttributes()
* Please note it output a string prefixed with a space!
+ * @covers Html::expandAttributes
*/
public function testExpandAttributesVariousExpansions() {
### NOT EMPTY ####
* 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
/**
* 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(
* The later will take precedence.
*
* Feature added by r96188
+ * @covers Html::expandAttributes
*/
public function testValueIsAuthoritativeInSpaceSeparatedAttributesArrays() {
$this->assertEquals(
);
}
+ /**
+ * @covers Html::namespaceSelector
+ */
public function testNamespaceSelector() {
$this->assertEquals(
'<select id=namespace name=namespace>' . "\n" .
/**
* @dataProvider provideHtml5InputTypes
+ * @covers Html::element
*/
public function testHtmlElementAcceptsNewHtml5TypesInHtml5Mode( $HTML5InputType ) {
$this->assertEquals(
return $ret;
}
+ /**
+ * @covers Html::expandAttributes
+ */
public function testFormValidationBlacklist() {
$this->assertEmpty(
Html::expandAttributes( array( 'min' => 1, 'max' => 100, 'pattern' => 'abc', 'required' => true, 'step' => 2 ) ),
<?php
class LanguageConverterTest extends MediaWikiLangTestCase {
+ /** @var LanguageToTest */
protected $lang = null;
+ /** @var TestConverter */
protected $lc = null;
protected function setUp() {
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' );
$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' );
$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' );
$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' );
$this->assertEquals( 'tg-latn', $this->lc->getPreferredVariant() );
}
+ /**
+ * @covers LanguageConverter::getPreferredVariant
+ */
public function testGetPreferredVariantUserOption() {
global $wgUser;
$this->assertEquals( 'tg-latn', $this->lc->getPreferredVariant() );
}
+ /**
+ * @covers LanguageConverter::getPreferredVariant
+ * @covers LanguageConverter::getUserVariant
+ */
public function testGetPreferredVariantUserOptionForForeignLanguage() {
global $wgContLang, $wgUser;
$this->assertEquals( 'tg-latn', $this->lc->getPreferredVariant() );
}
+ /**
+ * @covers LanguageConverter::getPreferredVariant
+ * @covers LanguageConverter::getUserVariant
+ * @covers LanguageConverter::getURLVariant
+ */
public function testGetPreferredVariantHeaderUserVsUrl() {
global $wgContLang, $wgRequest, $wgUser;
$this->assertEquals( 'tg', $this->lc->getPreferredVariant() );
}
-
+ /**
+ * @covers LanguageConverter::getPreferredVariant
+ */
public function testGetPreferredVariantDefaultLanguageVariant() {
global $wgDefaultLanguageVariant;
$this->assertEquals( 'tg-latn', $this->lc->getPreferredVariant() );
}
+ /**
+ * @covers LanguageConverter::getPreferredVariant
+ * @covers LanguageConverter::getURLVariant
+ */
public function testGetPreferredVariantDefaultLanguageVsUrlVariant() {
global $wgDefaultLanguageVariant, $wgRequest, $wgContLang;
$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 ) );
+ }
}