class HttpTest extends MediaWikiTestCase {
/**
* @dataProvider cookieDomains
+ * @covers Cookie::validateCookieDomain
*/
- function testValidateCookieDomain( $expected, $domain, $origin = null ) {
+ public function testValidateCookieDomain( $expected, $domain, $origin = null ) {
if ( $origin ) {
$ok = Cookie::validateCookieDomain( $domain, $origin );
$msg = "$domain against origin $origin";
* Test Http::isValidURI()
* @bug 27854 : Http::isValidURI is too lax
* @dataProvider provideURI
+ * @covers Http::isValidURI
*/
function testIsValidUri( $expect, $URI, $message = '' ) {
$this->assertEquals(
* rewritten when bug 29232 is taken care of (high-level handling of
* HTTP redirects).
*/
- function testRelativeRedirections() {
+ public function testRelativeRedirections() {
$h = MWHttpRequestTester::factory( 'http://oldsite/file.ext' );
# Forge a Location header
<?php
/**
- * Tests for IP validity functions. Ported from /t/inc/IP.t by avar.
+ * Tests for IP validity functions.
+ *
+ * Ported from /t/inc/IP.t by avar.
+ *
* @group IP
+ * @todo Test methods in this call should be split into a method and a
+ * dataprovider.
*/
class IPTest extends MediaWikiTestCase {
<?php
/**
- * Tests for the PathRouter parsing
+ * Tests for the PathRouter parsing.
+ *
+ * @todo Add covers tags.
*/
class PathRouterTest extends MediaWikiTestCase {
+ /**
+ * @var PathRouter
+ */
+ protected $basicRouter;
+
protected function setUp() {
parent::setUp();
$router = new PathRouter;
* @group Database
*/
class PreferencesTest extends MediaWikiTestCase {
- /** Array of User objects */
+ /**
+ * @var User[]
+ */
private $prefUsers;
+ /**
+ * @var RequestContext
+ */
private $context;
- function __construct() {
+ public function __construct() {
parent::__construct();
$this->prefUsers['noemail'] = new User;
* Placeholder to verify bug 34302
* @covers Preferences::profilePreferences
*/
- function testEmailFieldsWhenUserHasNoEmail() {
+ public function testEmailFieldsWhenUserHasNoEmail() {
$prefs = $this->prefsFor( 'noemail' );
$this->assertArrayHasKey( 'cssclass',
$prefs['emailaddress']
* Placeholder to verify bug 34302
* @covers Preferences::profilePreferences
*/
- function testEmailFieldsWhenUserEmailNotAuthenticated() {
+ public function testEmailFieldsWhenUserEmailNotAuthenticated() {
$prefs = $this->prefsFor( 'notauth' );
$this->assertArrayHasKey( 'cssclass',
$prefs['emailaddress']
* Placeholder to verify bug 34302
* @covers Preferences::profilePreferences
*/
- function testEmailFieldsWhenUserEmailIsAuthenticated() {
+ public function testEmailFieldsWhenUserEmailIsAuthenticated() {
$prefs = $this->prefsFor( 'auth' );
$this->assertArrayHasKey( 'cssclass',
$prefs['emailaddress']
}
/** Helper */
- function prefsFor( $user_key ) {
+ protected function prefsFor( $user_key ) {
$preferences = array();
Preferences::profilePreferences(
$this->prefUsers[$user_key]
protected $user_comment;
protected $context;
- function __construct() {
+ public function __construct() {
parent::__construct();
$this->title = Title::newFromText( 'SomeTitle' );
/**
* @covers LogFormatter::getIRCActionText
*/
- function testIrcMsgForLogTypeBlock() {
+ public function testIrcMsgForLogTypeBlock() {
$sep = $this->context->msg( 'colon-separator' )->text();
# block/block
/**
* @covers LogFormatter::getIRCActionText
*/
- function testIrcMsgForLogTypeDelete() {
+ public function testIrcMsgForLogTypeDelete() {
$sep = $this->context->msg( 'colon-separator' )->text();
# delete/delete
/**
* @covers LogFormatter::getIRCActionText
*/
- function testIrcMsgForLogTypeNewusers() {
+ public function testIrcMsgForLogTypeNewusers() {
$this->assertIRCComment(
'New user account',
'newusers', 'newusers',
/**
* @covers LogFormatter::getIRCActionText
*/
- function testIrcMsgForLogTypeMove() {
+ public function testIrcMsgForLogTypeMove() {
$move_params = array(
'4::target' => $this->target->getPrefixedText(),
'5::noredir' => 0,
/**
* @covers LogFormatter::getIRCActionText
*/
- function testIrcMsgForLogTypePatrol() {
+ public function testIrcMsgForLogTypePatrol() {
# patrol/patrol
$this->assertIRCComment(
$this->context->msg( 'patrol-log-line', 'revision 777', '[[SomeTitle]]', '' )->plain(),
/**
* @covers LogFormatter::getIRCActionText
*/
- function testIrcMsgForLogTypeProtect() {
+ public function testIrcMsgForLogTypeProtect() {
$protectParams = array(
'[edit=sysop] (indefinite) [move=sysop] (indefinite)'
);
/**
* @covers LogFormatter::getIRCActionText
*/
- function testIrcMsgForLogTypeUpload() {
+ public function testIrcMsgForLogTypeUpload() {
$sep = $this->context->msg( 'colon-separator' )->text();
# upload/upload
* --
*/
/*
- function testIrcMsgForBlankingAES() {
+ public function testIrcMsgForBlankingAES() {
// $this->context->msg( 'autosumm-blank', .. );
}
- function testIrcMsgForReplaceAES() {
+ public function testIrcMsgForReplaceAES() {
// $this->context->msg( 'autosumm-replace', .. );
}
- function testIrcMsgForRollbackAES() {
+ public function testIrcMsgForRollbackAES() {
// $this->context->msg( 'revertpage', .. );
}
- function testIrcMsgForUndoAES() {
+ public function testIrcMsgForUndoAES() {
// $this->context->msg( 'undo-summary', .. );
}
*/
* @param $expected String Expected IRC text without colors codes
* @param $type String Log type (move, delete, suppress, patrol ...)
* @param $action String A log type action
+ * @param $params
* @param $comment String (optional) A comment for the log action
* @param $msg String (optional) A message for PHPUnit :-)
*/
- function assertIRCComment( $expected, $type, $action, $params, $comment = null, $msg = '' ) {
+ protected function assertIRCComment( $expected, $type, $action, $params, $comment = null, $msg = '' ) {
$logEntry = new ManualLogEntry( $type, $action );
$logEntry->setPerformer( $this->user );
/**
* Test the relationship between title and wikipage in RequestContext
+ * @covers RequestContext::getWikiPage
+ * @covers RequestContext::getTitle
*/
public function testWikiPageTitle() {
$context = new RequestContext();
"When a title is updated the WikiPage should be purged and recreated on-demand with the new title." );
}
+ /**
+ * @covers RequestContext::importScopedSession
+ */
public function testImportScopedSession() {
$context = RequestContext::getMain();
/**
* @dataProvider providePackedModules
+ * @covers ResourceLoader::makePackedModulesString
*/
public function testMakePackedModulesString( $desc, $modules, $packed ) {
$this->assertEquals( $packed, ResourceLoader::makePackedModulesString( $modules ), $desc );
/**
* @dataProvider providePackedModules
+ * @covers ResourceLoaderContext::expandModuleNames
*/
public function testexpandModuleNames( $desc, $modules, $packed ) {
$this->assertEquals( $modules, ResourceLoaderContext::expandModuleNames( $packed ), $desc );
'iwlinks' ) );
}
- public function setUp() {
+ protected function setUp() {
global $wgExtraNamespaces, $wgNamespaceContentModels, $wgContentHandlers, $wgContLang;
parent::setUp();
* @dataProvider provideUserWasLastToEdit
*/
public function testUserWasLastToEdit( $sinceIdx, $expectedLast ) {
- $userA = \User::newFromName( "RevisionStorageTest_userA" );
- $userB = \User::newFromName( "RevisionStorageTest_userB" );
+ $userA = User::newFromName( "RevisionStorageTest_userA" );
+ $userB = User::newFromName( "RevisionStorageTest_userB" );
if ( $userA->getId() === 0 ) {
- $userA = \User::createNew( $userA->getName() );
+ $userA = User::createNew( $userA->getName() );
}
if ( $userB->getId() === 0 ) {
- $userB = \User::createNew( $userB->getName() );
+ $userB = User::createNew( $userB->getName() );
}
$ns = $this->getDefaultWikitextNS();
*/
class RevisionTest_ContentHandlerUseDB extends RevisionStorageTest {
- function setUp() {
+ protected function setUp() {
$this->setMwGlobals( 'wgContentHandlerUseDB', false );
$dbw = wfGetDB( DB_MASTER );
parent::tearDown();
}
- function testGetRevisionText() {
+ /**
+ * @covers Revision::getRevisionText
+ */
+ public function testGetRevisionText() {
$row = new stdClass;
$row->old_flags = '';
$row->old_text = 'This is a bunch of revision text.';
Revision::getRevisionText( $row ) );
}
- function testGetRevisionTextGzip() {
+ /**
+ * @covers Revision::getRevisionText
+ */
+ public function testGetRevisionTextGzip() {
$this->checkPHPExtension( 'zlib' );
$row = new stdClass;
Revision::getRevisionText( $row ) );
}
- function testGetRevisionTextUtf8Native() {
+ /**
+ * @covers Revision::getRevisionText
+ */
+ public function testGetRevisionTextUtf8Native() {
$row = new stdClass;
$row->old_flags = 'utf-8';
$row->old_text = "Wiki est l'\xc3\xa9cole superieur !";
Revision::getRevisionText( $row ) );
}
- function testGetRevisionTextUtf8Legacy() {
+ /**
+ * @covers Revision::getRevisionText
+ */
+ public function testGetRevisionTextUtf8Legacy() {
$row = new stdClass;
$row->old_flags = '';
$row->old_text = "Wiki est l'\xe9cole superieur !";
Revision::getRevisionText( $row ) );
}
- function testGetRevisionTextUtf8NativeGzip() {
+ /**
+ * @covers Revision::getRevisionText
+ */
+ public function testGetRevisionTextUtf8NativeGzip() {
$this->checkPHPExtension( 'zlib' );
$row = new stdClass;
Revision::getRevisionText( $row ) );
}
- function testGetRevisionTextUtf8LegacyGzip() {
+ /**
+ * @covers Revision::getRevisionText
+ */
+ public function testGetRevisionTextUtf8LegacyGzip() {
$this->checkPHPExtension( 'zlib' );
$row = new stdClass;
Revision::getRevisionText( $row ) );
}
- function testCompressRevisionTextUtf8() {
+ /**
+ * @covers Revision::compressRevisionText
+ */
+ public function testCompressRevisionTextUtf8() {
$row = new stdClass;
$row->old_text = "Wiki est l'\xc3\xa9cole superieur !";
$row->old_flags = Revision::compressRevisionText( $row->old_text );
Revision::getRevisionText( $row ), "getRevisionText" );
}
- function testCompressRevisionTextUtf8Gzip() {
+ /**
+ * @covers Revision::compressRevisionText
+ */
+ public function testCompressRevisionTextUtf8Gzip() {
$this->checkPHPExtension( 'zlib' );
$this->setMwGlobals( 'wgCompressRevisions', true );
* @param string $text
* @param string $title
* @param string $model
+ * @param null $format
+ *
* @return Revision
*/
function newTestRevision( $text, $title = "Test", $model = CONTENT_MODEL_WIKITEXT, $format = null ) {
/**
* @group Database
* @dataProvider dataGetContentModel
+ * @covers Revision::getContentModel
*/
- function testGetContentModel( $text, $title, $model, $format, $expectedModel ) {
+ public function testGetContentModel( $text, $title, $model, $format, $expectedModel ) {
$rev = $this->newTestRevision( $text, $title, $model, $format );
$this->assertEquals( $expectedModel, $rev->getContentModel() );
/**
* @group Database
* @dataProvider dataGetContentFormat
+ * @covers Revision::getContentFormat
*/
- function testGetContentFormat( $text, $title, $model, $format, $expectedFormat ) {
+ public function testGetContentFormat( $text, $title, $model, $format, $expectedFormat ) {
$rev = $this->newTestRevision( $text, $title, $model, $format );
$this->assertEquals( $expectedFormat, $rev->getContentFormat() );
/**
* @group Database
* @dataProvider dataGetContentHandler
+ * @covers Revision::getContentHandler
*/
- function testGetContentHandler( $text, $title, $model, $format, $expectedClass ) {
+ public function testGetContentHandler( $text, $title, $model, $format, $expectedClass ) {
$rev = $this->newTestRevision( $text, $title, $model, $format );
$this->assertEquals( $expectedClass, get_class( $rev->getContentHandler() ) );
/**
* @group Database
* @dataProvider dataGetContent
+ * @covers Revision::getContent
*/
- function testGetContent( $text, $title, $model, $format, $audience, $expectedSerialization ) {
+ public function testGetContent( $text, $title, $model, $format, $audience, $expectedSerialization ) {
$rev = $this->newTestRevision( $text, $title, $model, $format );
$content = $rev->getContent( $audience );
/**
* @group Database
* @dataProvider dataGetText
+ * @covers Revision::getText
*/
- function testGetText( $text, $title, $model, $format, $audience, $expectedText ) {
+ public function testGetText( $text, $title, $model, $format, $audience, $expectedText ) {
$this->hideDeprecated( 'Revision::getText' );
$rev = $this->newTestRevision( $text, $title, $model, $format );
/**
* @group Database
* @dataProvider dataGetText
+ * @covers Revision::getRawText
*/
- function testGetRawText( $text, $title, $model, $format, $audience, $expectedText ) {
+ public function testGetRawText( $text, $title, $model, $format, $audience, $expectedText ) {
$this->hideDeprecated( 'Revision::getRawText' );
$rev = $this->newTestRevision( $text, $title, $model, $format );
$this->assertEquals( $expected_hash, $rev->getSha1() );
}
+ /**
+ * @covers Revision::__construct
+ */
public function testConstructWithText() {
$this->hideDeprecated( "Revision::getText" );
$this->assertEquals( CONTENT_MODEL_JAVASCRIPT, $rev->getContentModel() );
}
+ /**
+ * @covers Revision::__construct
+ */
public function testConstructWithContent() {
$this->hideDeprecated( "Revision::getText" );
* Tests whether $rev->getContent() returns a clone when needed.
*
* @group Database
+ * @covers Revision::getContent
*/
- function testGetContentClone() {
+ public function testGetContentClone() {
$content = new RevisionTestModifyableContent( "foo" );
$rev = new Revision(
* Tests whether $rev->getContent() returns the same object repeatedly if appropriate.
*
* @group Database
+ * @covers Revision::getContent
*/
- function testGetContentUncloned() {
+ public function testGetContentUncloned() {
$rev = $this->newTestRevision( "hello", "testGetContentUncloned_dummy", CONTENT_MODEL_WIKITEXT );
$content = $rev->getContent( Revision::RAW );
$content2 = $rev->getContent( Revision::RAW );
<?php
+/**
+ * @todo Tests covering decodeCharReferences can be refactored into a single
+ * method and dataprovider.
+ */
class SanitizerTest extends MediaWikiTestCase {
protected function setUp() {
AutoLoader::loadClass( 'Sanitizer' );
}
- function testDecodeNamedEntities() {
+ /**
+ * @covers Sanitizer::decodeCharReferences
+ */
+ public function testDecodeNamedEntities() {
$this->assertEquals(
"\xc3\xa9cole",
Sanitizer::decodeCharReferences( 'école' ),
);
}
- function testDecodeNumericEntities() {
+ /**
+ * @covers Sanitizer::decodeCharReferences
+ */
+ public function testDecodeNumericEntities() {
$this->assertEquals(
"\xc4\x88io bonas dans l'\xc3\xa9cole!",
Sanitizer::decodeCharReferences( "Ĉio bonas dans l'école!" ),
);
}
- function testDecodeMixedEntities() {
+ /**
+ * @covers Sanitizer::decodeCharReferences
+ */
+ public function testDecodeMixedEntities() {
$this->assertEquals(
"\xc4\x88io bonas dans l'\xc3\xa9cole!",
Sanitizer::decodeCharReferences( "Ĉio bonas dans l'école!" ),
);
}
- function testDecodeMixedComplexEntities() {
+ /**
+ * @covers Sanitizer::decodeCharReferences
+ */
+ public function testDecodeMixedComplexEntities() {
$this->assertEquals(
"\xc4\x88io bonas dans l'\xc3\xa9cole! (mais pas Ĉio dans l'école)",
Sanitizer::decodeCharReferences(
);
}
- function testInvalidAmpersand() {
+ /**
+ * @covers Sanitizer::decodeCharReferences
+ */
+ public function testInvalidAmpersand() {
$this->assertEquals(
'a & b',
Sanitizer::decodeCharReferences( 'a & b' ),
);
}
- function testInvalidEntities() {
+ /**
+ * @covers Sanitizer::decodeCharReferences
+ */
+ public function testInvalidEntities() {
$this->assertEquals(
'&foo;',
Sanitizer::decodeCharReferences( '&foo;' ),
);
}
- function testInvalidNumberedEntities() {
+ /**
+ * @covers Sanitizer::decodeCharReferences
+ */
+ public function testInvalidNumberedEntities() {
$this->assertEquals( UTF8_REPLACEMENT, Sanitizer::decodeCharReferences( "�" ), 'Invalid numbered entity' );
}
* @param String $tag Name of an HTML5 element (ie: 'video')
* @param Boolean $escaped Wheter sanitizer let the tag in or escape it (ie: '<video>')
*/
- function testRemovehtmltagsOnHtml5Tags( $tag, $escaped ) {
+ public function testRemovehtmltagsOnHtml5Tags( $tag, $escaped ) {
$this->setMwGlobals( array(
'wgUseTidy' => false
) );
/**
* @dataProvider dataRemoveHTMLtags
+ * @covers Sanitizer::removeHTMLtags
*/
- function testRemoveHTMLtags( $input, $output, $msg = null ) {
+ public function testRemoveHTMLtags( $input, $output, $msg = null ) {
$GLOBALS['wgUseTidy'] = false;
$this->assertEquals( $output, Sanitizer::removeHTMLtags( $input ), $msg );
}
* @dataProvider provideTagAttributesToDecode
* @covers Sanitizer::decodeTagAttributes
*/
- function testDecodeTagAttributes( $expected, $attributes, $message = '' ) {
+ public function testDecodeTagAttributes( $expected, $attributes, $message = '' ) {
$this->assertEquals( $expected,
Sanitizer::decodeTagAttributes( $attributes ),
$message
* @dataProvider provideDeprecatedAttributes
* @covers Sanitizer::fixTagAttributes
*/
- function testDeprecatedAttributesUnaltered( $inputAttr, $inputEl, $message = '' ) {
+ public function testDeprecatedAttributesUnaltered( $inputAttr, $inputEl, $message = '' ) {
$this->assertEquals( " $inputAttr",
Sanitizer::fixTagAttributes( $inputAttr, $inputEl ),
$message
* @dataProvider provideCssCommentsFixtures
* @covers Sanitizer::checkCss
*/
- function testCssCommentsChecking( $expected, $css, $message = '' ) {
+ public function testCssCommentsChecking( $expected, $css, $message = '' ) {
$this->assertEquals( $expected,
Sanitizer::checkCss( $css ),
$message
/**
* @dataProvider provideAttributeSupport
+ * @covers Sanitizer::fixTagAttributes
*/
- function testAttributeSupport( $tag, $attributes, $expected, $message ) {
+ public function testAttributeSupport( $tag, $attributes, $expected, $message ) {
$this->assertEquals( $expected,
Sanitizer::fixTagAttributes( $attributes, $tag ),
$message
<?php
+/**
+ * @covers Sanitizer::validateEmail
+ * @TODO all test methods in this class should be refactored and...
+ * use a single test method and a single data provider...
+ */
class SanitizerValidateEmailTest extends MediaWikiTestCase {
private function checkEmail( $addr, $expected = true, $msg = '' ) {
$this->checkEmail( $addr, false, $msg );
}
- function testEmailWellKnownUserAtHostDotTldAreValid() {
+ public function testEmailWellKnownUserAtHostDotTldAreValid() {
$this->valid( 'user@example.com' );
$this->valid( 'user@example.museum' );
}
- function testEmailWithUpperCaseCharactersAreValid() {
+ public function testEmailWithUpperCaseCharactersAreValid() {
$this->valid( 'USER@example.com' );
$this->valid( 'user@EXAMPLE.COM' );
$this->valid( 'user@Example.com' );
$this->valid( 'USER@eXAMPLE.com' );
}
- function testEmailWithAPlusInUserName() {
+ public function testEmailWithAPlusInUserName() {
$this->valid( 'user+sub@example.com' );
$this->valid( 'user+@example.com' );
}
- function testEmailDoesNotNeedATopLevelDomain() {
+ public function testEmailDoesNotNeedATopLevelDomain() {
$this->valid( "user@localhost" );
$this->valid( "FooBar@localdomain" );
$this->valid( "nobody@mycompany" );
}
- function testEmailWithWhiteSpacesBeforeOrAfterAreInvalids() {
+ public function testEmailWithWhiteSpacesBeforeOrAfterAreInvalids() {
$this->invalid( " user@host.com" );
$this->invalid( "user@host.com " );
$this->invalid( "\tuser@host.com" );
$this->invalid( "user@host.com\t" );
}
- function testEmailWithWhiteSpacesAreInvalids() {
+ public function testEmailWithWhiteSpacesAreInvalids() {
$this->invalid( "User user@host" );
$this->invalid( "first last@mycompany" );
$this->invalid( "firstlast@my company" );
}
- // bug 26948 : comma were matched by an incorrect regexp range
- function testEmailWithCommasAreInvalids() {
+ /**
+ * bug 26948 : comma were matched by an incorrect regexp range
+ */
+ public function testEmailWithCommasAreInvalids() {
$this->invalid( "user,foo@example.org" );
$this->invalid( "userfoo@ex,ample.org" );
}
- function testEmailWithHyphens() {
+ public function testEmailWithHyphens() {
$this->valid( "user-foo@example.org" );
$this->valid( "userfoo@ex-ample.org" );
}
- function testEmailDomainCanNotBeginWithDot() {
+ public function testEmailDomainCanNotBeginWithDot() {
$this->invalid( "user@." );
$this->invalid( "user@.localdomain" );
$this->invalid( "user@localdomain." );
$this->invalid( ".@a............" );
}
- function testEmailWithFunnyCharacters() {
+ public function testEmailWithFunnyCharacters() {
$this->valid( "\$user!ex{this}@123.com" );
}
- function testEmailTopLevelDomainCanBeNumerical() {
+ public function testEmailTopLevelDomainCanBeNumerical() {
$this->valid( "user@example.1234" );
}
- function testEmailWithoutAtSignIsInvalid() {
+ public function testEmailWithoutAtSignIsInvalid() {
$this->invalid( 'useràexample.com' );
}
- function testEmailWithOneCharacterDomainIsValid() {
+ public function testEmailWithOneCharacterDomainIsValid() {
$this->valid( 'user@a' );
}
}
}
class SiteConfigurationTest extends MediaWikiTestCase {
- var $mConf;
+
+ /**
+ * @var SiteConfiguration
+ */
+ protected $mConf;
protected function setUp() {
parent::setUp();
$GLOBALS['global'] = array( 'global' => 'global' );
}
- function testSiteFromDb() {
+ /**
+ * @covers SiteConfiguration::siteFromDB
+ */
+ public function testSiteFromDb() {
$this->assertEquals(
array( 'wikipedia', 'en' ),
$this->mConf->siteFromDB( 'enwiki' ),
);
}
- function testGetLocalDatabases() {
+ /**
+ * @covers SiteConfiguration::getLocalDatabases
+ */
+ public function testGetLocalDatabases() {
$this->assertEquals(
array( 'enwiki', 'dewiki', 'frwiki' ),
$this->mConf->getLocalDatabases(),
);
}
- function testGetConfVariables() {
+ /**
+ * @covers SiteConfiguration::get
+ */
+ public function testGetConfVariables() {
$this->assertEquals(
'enwiki',
$this->mConf->get( 'simple', 'enwiki', 'wiki' ),
);
}
- function testSiteFromDbWithCallback() {
+ /**
+ * @covers SiteConfiguration::siteFromDB
+ */
+ public function testSiteFromDbWithCallback() {
$this->mConf->siteParamsCallback = 'getSiteParams';
$this->assertEquals(
);
}
- function testParameterReplacement() {
+ /**
+ * @covers SiteConfiguration::get
+ */
+ public function testParameterReplacement() {
$this->mConf->siteParamsCallback = 'getSiteParams';
$this->assertEquals(
);
}
- function testGetAllGlobals() {
+ /**
+ * @covers SiteConfiguration::getAll
+ */
+ public function testGetAllGlobals() {
$this->mConf->siteParamsCallback = 'getSiteParams';
$getall = array(
class TemplateCategoriesTest extends MediaWikiLangTestCase {
+ /**
+ * @covers Title::getParentCategories
+ */
function testTemplateCategories() {
$title = Title::newFromText( "Categorized from template" );
$page = WikiPage::factory( $title );
$user = new User();
$user->mRights = array( 'createpage', 'edit', 'purge' );
- $page->doEditContent( new WikitextContent( '{{Categorising template}}' ), 'Create a page with a template', 0, false, $user );
+ $page->doEditContent(
+ new WikitextContent( '{{Categorising template}}' ),
+ 'Create a page with a template',
+ 0,
+ false,
+ $user
+ );
+
$this->assertEquals(
array()
, $title->getParentCategories()
);
$template = WikiPage::factory( Title::newFromText( 'Template:Categorising template' ) );
- $template->doEditContent( new WikitextContent( '[[Category:Solved bugs]]' ), 'Add a category through a template', 0, false, $user );
+
+ $template->doEditContent(
+ new WikitextContent( '[[Category:Solved bugs]]' ),
+ 'Add a category through a template',
+ 0,
+ false,
+ $user
+ );
// Run the job queue
JobQueueGroup::destroySingletons();
<?php
-/* Wraps the user object, so we can also retain full access to properties like password if we log in via the API */
+/**
+ * Wraps the user object, so we can also retain full access to properties like password if we log in via the API
+ */
class TestUser {
public $username;
public $password;
public $groups;
public $user;
- function __construct( $username, $realname = 'Real Name', $email = 'sample@example.com', $groups = array() ) {
+ public function __construct( $username, $realname = 'Real Name', $email = 'sample@example.com', $groups = array() ) {
$this->username = $username;
$this->realname = $realname;
$this->email = $email;
}
/**
- * Test offset usage for a given language::userAdjust
+ * Test offset usage for a given Language::userAdjust
* @dataProvider dataUserAdjust
+ * @covers Language::userAdjust
*/
public function testUserAdjust( $date, $localTZoffset, $expected ) {
global $wgContLang;
/**
* Test parsing of valid timestamps and outputing to MW format.
* @dataProvider provideValidTimestamps
+ * @covers MWTimestamp::getTimestamp
*/
- function testValidParse( $format, $original, $expected ) {
+ public function testValidParse( $format, $original, $expected ) {
$timestamp = new MWTimestamp( $original );
$this->assertEquals( $expected, $timestamp->getTimestamp( TS_MW ) );
}
/**
* Test outputting valid timestamps to different formats.
* @dataProvider provideValidTimestamps
+ * @covers MWTimestamp::getTimestamp
*/
- function testValidOutput( $format, $expected, $original ) {
+ public function testValidOutput( $format, $expected, $original ) {
$timestamp = new MWTimestamp( $original );
$this->assertEquals( $expected, (string)$timestamp->getTimestamp( $format ) );
}
/**
* Test an invalid timestamp.
* @expectedException TimestampException
+ * @covers MWTimestamp
*/
- function testInvalidParse() {
+ public function testInvalidParse() {
new MWTimestamp( "This is not a timestamp." );
}
/**
* Test requesting an invalid output format.
* @expectedException TimestampException
+ * @covers MWTimestamp::getTimestamp
*/
- function testInvalidOutput() {
+ public function testInvalidOutput() {
$timestamp = new MWTimestamp( '1343761268' );
$timestamp->getTimestamp( 98 );
}
}
/**
- * @test
* @dataProvider provideHumanTimestampTests
+ * @covers MWTimestamp::getHumanTimestamp
*/
public function testHumanTimestamp(
$tsTime, // The timestamp to format
}
/**
- * @test
* @dataProvider provideRelativeTimestampTests
+ * @covers MWTimestamp::getRelativeTimestamp
*/
public function testRelativeTimestamp(
$tsTime, // The timestamp to format
*
* @note: We don't make assumptions about the main namespace.
* But we do expect the Help namespace to contain Wikitext.
- *
*/
class TitleMethodsTest extends MediaWikiTestCase {
/**
* @dataProvider provideEquals
+ * @covers Title::equals
*/
public function testEquals( $titleA, $titleB, $expectedBool ) {
$titleA = Title::newFromText( $titleA );
/**
* @dataProvider provideInNamespace
+ * @covers Title::inNamespace
*/
public function testInNamespace( $title, $ns, $expectedBool ) {
$title = Title::newFromText( $title );
$this->assertEquals( $expectedBool, $title->inNamespace( $ns ) );
}
+ /**
+ * @covers Title::inNamespaces
+ */
public function testInNamespaces() {
$mainpage = Title::newFromText( 'Main Page' );
$this->assertTrue( $mainpage->inNamespaces( NS_MAIN, NS_USER ) );
/**
* @dataProvider provideHasSubjectNamespace
+ * @covers Title::hasSubjectNamespace
*/
public function testHasSubjectNamespace( $title, $ns, $expectedBool ) {
$title = Title::newFromText( $title );
/**
* @dataProvider dataGetContentModel
+ * @covers Title::getContentModel
*/
public function testGetContentModel( $title, $expectedModelId ) {
$title = Title::newFromText( $title );
/**
* @dataProvider dataGetContentModel
+ * @covers Title::hasContentModel
*/
public function testHasContentModel( $title, $expectedModelId ) {
$title = Title::newFromText( $title );
/**
* @dataProvider provideIsCssOrJsPage
+ * @covers Title::isCssOrJsPage
*/
public function testIsCssOrJsPage( $title, $expectedBool ) {
$title = Title::newFromText( $title );
$this->assertEquals( $expectedBool, $title->isCssOrJsPage() );
}
-
public static function provideIsCssJsSubpage() {
return array(
array( 'Help:Foo', false ),
/**
* @dataProvider provideIsCssJsSubpage
+ * @covers Title::isCssJsSubpage
*/
public function testIsCssJsSubpage( $title, $expectedBool ) {
$title = Title::newFromText( $title );
/**
* @dataProvider provideIsCssSubpage
+ * @covers Title::isCssSubpage
*/
public function testIsCssSubpage( $title, $expectedBool ) {
$title = Title::newFromText( $title );
/**
* @dataProvider provideIsJsSubpage
+ * @covers Title::isJsSubpage
*/
public function testIsJsSubpage( $title, $expectedBool ) {
$title = Title::newFromText( $title );
/**
* @dataProvider provideIsWikitextPage
+ * @covers Title::isWikitextPage
*/
public function testIsWikitextPage( $title, $expectedBool ) {
$title = Title::newFromText( $title );
/**
* @group Database
+ * @todo covers tags
*/
class TitlePermissionTest extends MediaWikiLangTestCase {
}
}
- function setUserPerm( $perm ) {
+ protected function setUserPerm( $perm ) {
// Setting member variables is evil!!!
if ( is_array( $perm ) ) {
}
}
- function setTitle( $ns, $title = "Main_Page" ) {
+ protected function setTitle( $ns, $title = "Main_Page" ) {
$this->title = Title::makeTitle( $ns, $title );
}
- function setUser( $userName = null ) {
+ protected function setUser( $userName = null ) {
if ( $userName === 'anon' ) {
$this->user = $this->anonUser;
} elseif ( $userName === null || $userName === $this->userName ) {
}
}
- function testQuickPermissions() {
+ /**
+ * @todo This test method should be split up into separate test methods and
+ * data providers
+ */
+ public function testQuickPermissions() {
global $wgContLang;
$prefix = $wgContLang->getFormattedNsText( NS_PROJECT );
}
}
- function runGroupPermissions( $action, $result, $result2 = null ) {
+ protected function runGroupPermissions( $action, $result, $result2 = null ) {
global $wgGroupPermissions;
if ( $result2 === null ) {
$this->assertEquals( $result2, $res );
}
- function testSpecialsAndNSPermissions() {
+ /**
+ * @todo This test method should be split up into separate test methods and
+ * data providers
+ */
+ public function testSpecialsAndNSPermissions() {
global $wgNamespaceProtection;
$this->setUser( $this->userName );
$this->title->userCan( 'bogus', $this->user ) );
}
- function testCssAndJavascriptPermissions() {
+ /**
+ * @todo This test method should be split up into separate test methods and
+ * data providers
+ */
+ public function testCssAndJavascriptPermissions() {
$this->setUser( $this->userName );
$this->setTitle( NS_USER, $this->userName . '/test.js' );
);
}
- function runCSSandJSPermissions( $result0, $result1, $result2, $result3, $result4 ) {
+ protected function runCSSandJSPermissions( $result0, $result1, $result2, $result3, $result4 ) {
$this->setUserPerm( '' );
$this->assertEquals( $result0,
$this->title->getUserPermissionsErrors( 'bogus',
$this->user ) );
}
- function testPageRestrictions() {
+ /**
+ * @todo This test method should be split up into separate test methods and
+ * data providers
+ */
+ public function testPageRestrictions() {
global $wgContLang;
$prefix = $wgContLang->getFormattedNsText( NS_PROJECT );
$this->user ) );
}
- function testCascadingSourcesRestrictions() {
+ public function testCascadingSourcesRestrictions() {
$this->setTitle( NS_MAIN, "test page" );
$this->setUserPerm( array( "edit", "bogus" ) );
$this->title->getUserPermissionsErrors( 'edit', $this->user ) );
}
- function testActionPermissions() {
+ /**
+ * @todo This test method should be split up into separate test methods and
+ * data providers
+ */
+ public function testActionPermissions() {
$this->setUserPerm( array( "createpage" ) );
$this->setTitle( NS_MAIN, "test page" );
$this->title->mTitleProtection['pt_create_perm'] = '';
$this->title->userCan( 'move-target', $this->user ) );
}
- function testUserBlock() {
+ public function testUserBlock() {
global $wgEmailConfirmToEdit, $wgEmailAuthentication;
$wgEmailConfirmToEdit = true;
$wgEmailAuthentication = true;
<?php
/**
- *
* @group Database
* ^--- needed for language cache stuff
*/
) );
}
- function testLegalChars() {
+ /**
+ * @covers Title::legalChars
+ */
+ public function testLegalChars() {
$titlechars = Title::legalChars();
foreach ( range( 1, 255 ) as $num ) {
/**
* See also mediawiki.Title.test.js
+ * @covers Title::secureAndSplit
+ * @todo This method should be split into 2 separate tests each with a provider
*/
- function testSecureAndSplit() {
+ public function testSecureAndSplit() {
// Valid
foreach ( array(
'Sandbox',
/**
* @dataProvider provideConvertByteClassToUnicodeClass
+ * @covers Title::convertByteClassToUnicodeClass
*/
- function testConvertByteClassToUnicodeClass( $byteClass, $unicodeClass ) {
+ public function testConvertByteClassToUnicodeClass( $byteClass, $unicodeClass ) {
$this->assertEquals( $unicodeClass, Title::convertByteClassToUnicodeClass( $byteClass ) );
}
/**
* @dataProvider provideBug31100
+ * @covers Title::fixSpecialName
*/
- function testBug31100FixSpecialName( $text, $expectedParam ) {
+ public function testBug31100FixSpecialName( $text, $expectedParam ) {
$title = Title::newFromText( $text );
$fixed = $title->fixSpecialName();
$stuff = explode( '/', $fixed->getDBkey(), 2 );
* @group Database
* @param string $source
* @param string $target
- * @param array|string|true $expected Required error
+ * @param array|string|bool $expected Required error
* @dataProvider provideTestIsValidMoveOperation
+ * @covers Title::isValidMoveOperation
*/
- function testIsValidMoveOperation( $source, $target, $expected ) {
+ public function testIsValidMoveOperation( $source, $target, $expected ) {
$title = Title::newFromText( $source );
$nt = Title::newFromText( $target );
$errors = $title->isValidMoveOperation( $nt, false );
/**
* Provides test parameter values for testIsValidMoveOperation()
*/
- function dataTestIsValidMoveOperation() {
+ public function dataTestIsValidMoveOperation() {
return array(
array( 'Test', 'Test', 'selfmove' ),
array( 'File:Test.jpg', 'Page', 'imagenocrossnamespace' )
* @param array $whitelistRegexp
* @param string $source
* @param string $action
- * @param array|string|true $expected Required error
+ * @param array|string|bool $expected Required error
*
* @covers Title::checkReadPermissions
* @dataProvider dataWgWhitelistReadRegexp
*/
- function testWgWhitelistReadRegexp( $whitelistRegexp, $source, $action, $expected ) {
+ public function testWgWhitelistReadRegexp( $whitelistRegexp, $source, $action, $expected ) {
// $wgWhitelistReadRegexp must be an array. Since the provided test cases
// usually have only one regex, it is more concise to write the lonely regex
// as a string. Thus we cast to an array() to honor $wgWhitelistReadRegexp
/**
* Provides test parameter values for testWgWhitelistReadRegexp()
*/
- function dataWgWhitelistReadRegexp() {
+ public function dataWgWhitelistReadRegexp() {
$ALLOWED = true;
$DISALLOWED = false;
);
}
- function flattenErrorsArray( $errors ) {
+ public function flattenErrorsArray( $errors ) {
$result = array();
foreach ( $errors as $error ) {
$result[] = $error[0];
}
/**
- * @dataProvider provideCasesForGetpageviewlanguage
+ * @dataProvider provideGetPageViewLanguage
+ * @covers Title::getPageViewLanguage
*/
- function testGetpageviewlanguage( $expected, $titleText, $contLang, $lang, $variant, $msg = '' ) {
+ public function testGetPageViewLanguage( $expected, $titleText, $contLang, $lang, $variant, $msg = '' ) {
global $wgLanguageCode, $wgContLang, $wgLang, $wgDefaultLanguageVariant, $wgAllowUserJs;
// Setup environnement for this test
);
}
- public static function provideCasesForGetpageviewlanguage() {
+ public static function provideGetPageViewLanguage() {
# Format:
# - expected
# - Title name
/**
* @dataProvider provideBaseTitleCases
+ * @covers Title::getBaseText
*/
- function testExtractingBaseTextFromTitle( $title, $expected, $msg = '' ) {
+ public function testGetBaseText( $title, $expected, $msg = '' ) {
$title = Title::newFromText( $title );
$this->assertEquals( $expected,
$title->getBaseText(),
/**
* @dataProvider provideRootTitleCases
+ * @covers Title::getRootText
*/
- function testExtractingRootTextFromTitle( $title, $expected, $msg = '' ) {
+ public function testGetRootText( $title, $expected, $msg = '' ) {
$title = Title::newFromText( $title );
$this->assertEquals( $expected,
$title->getRootText(),
/**
* @todo Handle $wgNamespacesWithSubpages cases
* @dataProvider provideSubpageTitleCases
+ * @covers Title::getSubpageText
*/
- function testExtractingSubpageTextFromTitle( $title, $expected, $msg = '' ) {
+ public function testGetSubpageText( $title, $expected, $msg = '' ) {
$title = Title::newFromText( $title );
$this->assertEquals( $expected,
$title->getSubpageText(),
<?php
class UIDGeneratorTest extends MediaWikiTestCase {
+
/**
* @dataProvider provider_testTimestampedUID
+ * @covers UIDGenerator::newTimestampedUID128
+ * @covers UIDGenerator::newTimestampedUID88
*/
public function testTimestampedUID( $method, $digitlen, $bits, $tbits, $hostbits ) {
$id = call_user_func( array( 'UIDGenerator', $method ) );
/**
* array( method, length, bits, hostbits )
+ * NOTE: When adding a new method name here please update the covers tags for the tests!
*/
public static function provider_testTimestampedUID() {
return array(
);
}
+ /**
+ * @covers UIDGenerator::newUUIDv4
+ */
public function testUUIDv4() {
for ( $i = 0; $i < 100; $i++ ) {
$id = UIDGenerator::newUUIDv4();
$this->assertEquals( true,
preg_match( '!^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$!', $id ),
"UID $id has the right format" );
+ }
+ }
+ /**
+ * @covers UIDGenerator::newRawUUIDv4
+ */
+ public function testRawUUIDv4() {
+ for ( $i = 0; $i < 100; $i++ ) {
$id = UIDGenerator::newRawUUIDv4();
$this->assertEquals( true,
preg_match( '!^[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15}$!', $id ),
"UID $id has the right format" );
+ }
+ }
+ /**
+ * @covers UIDGenerator::newRawUUIDv4
+ */
+ public function testRawUUIDv4QuickRand() {
+ for ( $i = 0; $i < 100; $i++ ) {
$id = UIDGenerator::newRawUUIDv4( UIDGenerator::QUICK_RAND );
$this->assertEquals( true,
preg_match( '!^[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15}$!', $id ),
"UID $id has the right format" );
}
}
+
}
);
}
+ /**
+ * @covers User::getGroupPermissions
+ */
public function testGroupPermissions() {
$rights = User::getGroupPermissions( array( 'unittesters' ) );
$this->assertContains( 'runtest', $rights );
$this->assertNotContains( 'nukeworld', $rights );
}
+ /**
+ * @covers User::getGroupPermissions
+ */
public function testRevokePermissions() {
$rights = User::getGroupPermissions( array( 'unittesters', 'formertesters' ) );
$this->assertNotContains( 'runtest', $rights );
$this->assertNotContains( 'nukeworld', $rights );
}
+ /**
+ * @covers User::getRights
+ */
public function testUserPermissions() {
$rights = $this->user->getRights();
$this->assertContains( 'runtest', $rights );
/**
* @dataProvider provideGetGroupsWithPermission
+ * @covers User::getGroupsWithPermission
*/
public function testGetGroupsWithPermission( $expected, $right ) {
$result = User::getGroupsWithPermission( $right );
/**
* @dataProvider provideUserNames
+ * @covers User::isValidUserName
*/
public function testIsValidUserName( $username, $result, $message ) {
$this->assertEquals( $this->user->isValidUserName( $username ), $result, $message );
/**
* Test User::editCount
* @group medium
+ * @covers User::getEditCount
*/
public function testEditCount() {
$user = User::newFromName( 'UnitTestUser' );
/**
* Test changing user options.
+ * @covers User::setOption
+ * @covers User::getOption
*/
public function testOptions() {
$user = User::newFromName( 'UnitTestUser' );
/**
* Bug 37963
* Make sure defaults are loaded when setOption is called.
+ * @covers User::loadOptions
*/
public function testAnonOptions() {
global $wgDefaultUserOptions;
/**
* @dataProvider provideDetectServer
+ * @covers WebRequest::detectServer
*/
function testDetectServer( $expected, $input, $description ) {
$_SERVER = $input;
/**
* @dataProvider provideGetIP
+ * @covers WebRequest::getIP
*/
function testGetIP( $expected, $input, $squid, $xffList, $private, $description ) {
$_SERVER = $input;
/**
* @expectedException MWException
+ * @covers WebRequest::getIP
*/
function testGetIpLackOfRemoteAddrThrowAnException() {
$request = new WebRequest();
/**
* @dataProvider provideLanguageData
+ * @covers WebRequest::getAcceptLang
*/
function testAcceptLang( $acceptLanguageHeader, $expectedLanguages, $description ) {
$_SERVER = array( 'HTTP_ACCEPT_LANGUAGE' => $acceptLanguageHeader );
<?php
+
/**
* @group ContentHandler
* @group Database
* ^--- important, causes temporary tables to be used instead of the real database
* @group medium
**/
-
class WikiPageTest extends MediaWikiLangTestCase {
- var $pages_to_delete;
+ protected $pages_to_delete;
function __construct( $name = null, array $data = array(), $dataName = '' ) {
parent::__construct( $name, $data, $dataName );
return $page;
}
+ /**
+ * @covers WikiPage::doEditContent
+ */
public function testDoEditContent() {
$page = $this->newPage( "WikiPageTest_testDoEditContent" );
$title = $page->getTitle();
$this->assertEquals( 2, $n, 'pagelinks should contain two links from the page' );
}
+ /**
+ * @covers WikiPage::doEdit
+ */
public function testDoEdit() {
$this->hideDeprecated( "WikiPage::doEdit" );
$this->hideDeprecated( "WikiPage::getText" );
$this->assertEquals( 2, $n, 'pagelinks should contain two links from the page' );
}
+ /**
+ * @covers WikiPage::doQuickEdit
+ */
public function testDoQuickEdit() {
global $wgUser;
$this->assertEquals( $text, $page->getText() );
}
+ /**
+ * @covers WikiPage::doQuickEditContent
+ */
public function testDoQuickEditContent() {
global $wgUser;
$this->assertTrue( $content->equals( $page->getContent() ) );
}
+ /**
+ * @covers WikiPage::doDeleteArticle
+ */
public function testDoDeleteArticle() {
$page = $this->createPage( "WikiPageTest_testDoDeleteArticle", "[[original text]] foo", CONTENT_MODEL_WIKITEXT );
$id = $page->getId();
$this->assertEquals( 0, $n, 'pagelinks should contain no more links from the page' );
}
+ /**
+ * @covers WikiPage::doDeleteUpdates
+ */
public function testDoDeleteUpdates() {
$page = $this->createPage( "WikiPageTest_testDoDeleteArticle", "[[original text]] foo", CONTENT_MODEL_WIKITEXT );
$id = $page->getId();
$this->assertEquals( 0, $n, 'pagelinks should contain no more links from the page' );
}
+ /**
+ * @covers WikiPage::getRevision
+ */
public function testGetRevision() {
$page = $this->newPage( "WikiPageTest_testGetRevision" );
$this->assertEquals( "some text", $rev->getContent()->getNativeData() );
}
+ /**
+ * @covers WikiPage::getContent
+ */
public function testGetContent() {
$page = $this->newPage( "WikiPageTest_testGetContent" );
$this->assertEquals( "some text", $content->getNativeData() );
}
+ /**
+ * @covers WikiPage::getText
+ */
public function testGetText() {
$this->hideDeprecated( "WikiPage::getText" );
$this->assertEquals( "some text", $text );
}
+ /**
+ * @covers WikiPage::getRawText
+ */
public function testGetRawText() {
$this->hideDeprecated( "WikiPage::getRawText" );
$this->assertEquals( "some text", $text );
}
+ /**
+ * @covers WikiPage::getContentModel
+ */
public function testGetContentModel() {
global $wgContentHandlerUseDB;
$this->assertEquals( CONTENT_MODEL_JAVASCRIPT, $page->getContentModel() );
}
+ /**
+ * @covers WikiPage::getContentHandler
+ */
public function testGetContentHandler() {
global $wgContentHandlerUseDB;
$this->assertEquals( 'JavaScriptContentHandler', get_class( $page->getContentHandler() ) );
}
+ /**
+ * @covers WikiPage::exists
+ */
public function testExists() {
$page = $this->newPage( "WikiPageTest_testExists" );
$this->assertFalse( $page->exists() );
/**
* @dataProvider provideHasViewableContent
+ * @covers WikiPage::hasViewableContent
*/
public function testHasViewableContent( $title, $viewable, $create = false ) {
$page = $this->newPage( $title );
/**
* @dataProvider provideGetRedirectTarget
+ * @covers WikiPage::getRedirectTarget
*/
public function testGetRedirectTarget( $title, $model, $text, $target ) {
$page = $this->createPage( $title, $text, $model );
/**
* @dataProvider provideGetRedirectTarget
+ * @covers WikiPage::isRedirect
*/
public function testIsRedirect( $title, $model, $text, $target ) {
$page = $this->createPage( $title, $text, $model );
/**
* @dataProvider provideIsCountable
+ * @covers WikiPage::isCountable
*/
public function testIsCountable( $title, $model, $text, $mode, $expected ) {
global $wgContentHandlerUseDB;
/**
* @dataProvider provideGetParserOutput
+ * @covers WikiPage::getParserOutput
*/
public function testGetParserOutput( $model, $text, $expectedHtml ) {
$page = $this->createPage( 'WikiPageTest_testGetParserOutput', $text, $model );
return $po;
}
+ /**
+ * @covers WikiPage::getParserOutput
+ */
public function testGetParserOutput_nonexisting() {
static $count = 0;
$count++;
$this->assertFalse( $po, "getParserOutput() shall return false for non-existing pages." );
}
+ /**
+ * @covers WikiPage::getParserOutput
+ */
public function testGetParserOutput_badrev() {
$page = $this->createPage( 'WikiPageTest_testGetParserOutput', "dummy", CONTENT_MODEL_WIKITEXT );
/**
* @dataProvider dataReplaceSection
+ * @covers WikiPage::replaceSection
*/
public function testReplaceSection( $title, $model, $text, $section, $with, $sectionTitle, $expected ) {
$this->hideDeprecated( "WikiPage::replaceSection" );
/**
* @dataProvider dataReplaceSection
+ * @covers WikiPage::replaceSectionContent
*/
public function testReplaceSectionContent( $title, $model, $text, $section, $with, $sectionTitle, $expected ) {
$page = $this->createPage( $title, $text, $model );
/**
* @todo FIXME: the above rollback test is better, but it keeps failing in jenkins for some reason.
+ * @covers WikiPage::doRollback
*/
public function testDoRollback() {
$admin = new User();
/**
* @dataProvider provideGetAutoSummary
+ * @covers WikiPage::getAutosummary
*/
public function testGetAutosummary( $old, $new, $flags, $expected ) {
$this->hideDeprecated( "WikiPage::getAutosummary" );
/**
* @dataProvider provideGetAutoDeleteReason
+ * @covers WikiPage::getAutoDeleteReason
*/
public function testGetAutoDeleteReason( $edits, $expectedResult, $expectedHistory ) {
global $wgUser;
/**
* @dataProvider providePreSaveTransform
+ * @covers WikiPage::preSaveTransform
*/
public function testPreSaveTransform( $text, $expected ) {
$this->hideDeprecated( 'WikiPage::preSaveTransform' );
*/
class WikiPageTest_ContentHandlerUseDB extends WikiPageTest {
- function setUp() {
+ protected function setUp() {
parent::setUp();
$this->setMwGlobals( 'wgContentHandlerUseDB', false );
}
}
+ /**
+ * @covers WikiPage::getContentModel
+ */
public function testGetContentModel() {
$page = $this->createPage( "WikiPageTest_testGetContentModel", "some text", CONTENT_MODEL_JAVASCRIPT );
$this->assertEquals( CONTENT_MODEL_WIKITEXT, $page->getContentModel() );
}
+ /**
+ * @covers WikiPage::getContentHandler
+ */
public function testGetContentHandler() {
$page = $this->createPage( "WikiPageTest_testGetContentHandler", "some text", CONTENT_MODEL_JAVASCRIPT );
<?php
+
+/**
+ * @group Xml
+ */
class XmlJs extends MediaWikiTestCase {
- public function testConstruction() {
- $obj = new XmlJsCode( null );
- $this->assertNull( $obj->value );
- $obj = new XmlJsCode( '' );
- $this->assertSame( $obj->value, '' );
+
+ /**
+ * @covers XmlJsCode::__construct
+ * @dataProvider provideConstruction
+ */
+ public function testConstruction( $value ) {
+ $obj = new XmlJsCode( $value );
+ $this->assertEquals( $value, $obj->value );
}
+
+ public function provideConstruction(){
+ return array(
+ array( null ),
+ array( '' ),
+ );
+ }
+
}
<?php
-// TODO
+/**
+ * @group Xml
+ */
class XmlSelectTest extends MediaWikiTestCase {
+
+ /**
+ * @var XmlSelect
+ */
protected $select;
protected function setUp() {
$this->select = null;
}
- ### START OF TESTS ###
-
+ /**
+ * @covers XmlSelect::__construct
+ */
public function testConstructWithoutParameters() {
$this->assertEquals( '<select></select>', $this->select->getHTML() );
}
/**
* Parameters are $name (false), $id (false), $default (false)
* @dataProvider provideConstructionParameters
+ * @covers XmlSelect::__construct
*/
public function testConstructParameters( $name, $id, $default, $expected ) {
$this->select = new XmlSelect( $name, $id, $default );
* - $id (default: false)
* - $default (default: false)
* Provides a fourth parameters representing the expected HTML output
- *
*/
public static function provideConstructionParameters() {
return array(
);
}
- # Begin XmlSelect::addOption() similar to Xml::option
+ /**
+ * @covers XmlSelect::addOption
+ */
public function testAddOption() {
$this->select->addOption( 'foo' );
$this->assertEquals( '<select><option value="foo">foo</option></select>', $this->select->getHTML() );
}
+ /**
+ * @covers XmlSelect::addOption
+ */
public function testAddOptionWithDefault() {
$this->select->addOption( 'foo', true );
$this->assertEquals( '<select><option value="1">foo</option></select>', $this->select->getHTML() );
}
+ /**
+ * @covers XmlSelect::addOption
+ */
public function testAddOptionWithFalse() {
$this->select->addOption( 'foo', false );
$this->assertEquals( '<select><option value="foo">foo</option></select>', $this->select->getHTML() );
}
+ /**
+ * @covers XmlSelect::addOption
+ */
public function testAddOptionWithValueZero() {
$this->select->addOption( 'foo', 0 );
$this->assertEquals( '<select><option value="0">foo</option></select>', $this->select->getHTML() );
}
- # End XmlSelect::addOption() similar to Xml::option
-
+ /**
+ * @covers XmlSelect::setDefault
+ */
public function testSetDefault() {
$this->select->setDefault( 'bar1' );
$this->select->addOption( 'foo1' );
* Adding default later on should set the correct selection or
* raise an exception.
* To handle this, we need to render the options in getHtml()
+ * @covers XmlSelect::setDefault
*/
public function testSetDefaultAfterAddingOptions() {
$this->select->addOption( 'foo1' );
'<option value="foo2">foo2</option></select>', $this->select->getHTML() );
}
+ /**
+ * @covers XmlSelect::setAttribute
+ * @covers XmlSelect::getAttribute
+ */
public function testGetAttributes() {
# create some attributes
$this->select->setAttribute( 'dummy', 0x777 );
<?php
+/**
+ * @group Xml
+ */
class XmlTest extends MediaWikiTestCase {
protected function setUp() {
/**
* PHPUnit tests for XMLTypeCheck.
* @author physikerwelt
- * @group ?
+ * @group Xml
* @covers XMLTypeCheck
*/
class XmlTypeCheckTest extends MediaWikiTestCase {
* NOTE: this test is more like an integration test than a unit test
*/
class ZipDirectoryReaderTest extends MediaWikiTestCase {
- var $zipDir, $entries;
+ protected $zipDir;
+ protected $entries;
protected function setUp() {
parent::setUp();