/**
* Test class for MWNamespace.
* Generated by PHPUnit on 2011-02-20 at 21:01:55.
+ * @todo covers tags
+ * @todo FIXME: this test file is a mess
*
*/
class MWNamespaceTest extends MediaWikiTestCase {
) );
}
-#### START OF TESTS #########################################################
+# ### START OF TESTS #########################################################
/**
* @todo Write more texts, handle $wgAllowImageMoving setting
+ * @covers MWNamespace::isMovable
*/
public function testIsMovable() {
- $this->assertFalse( MWNamespace::isMovable( NS_CATEGORY ) );
+ $this->assertFalse( MWNamespace::isMovable( NS_SPECIAL ) );
# @todo FIXME: Write more tests!!
}
/**
* Please make sure to change testIsTalk() if you change the assertions below
+ * @covers MWNamespace::isSubject
*/
public function testIsSubject() {
// Special namespaces
/**
* Reverse of testIsSubject().
* Please update testIsSubject() if you change assertions below
+ * @covers MWNamespace::isTalk
*/
public function testIsTalk() {
// Special namespaces
}
/**
+ * @covers MWNamespace::getSubject
*/
public function testGetSubject() {
// Special namespaces are their own subjects
* Regular getTalk() calls
* Namespaces without a talk page (NS_MEDIA, NS_SPECIAL) are tested in
* the function testGetTalkExceptions()
+ * @covers MWNamespace::getTalk
*/
public function testGetTalk() {
$this->assertEquals( NS_TALK, MWNamespace::getTalk( NS_MAIN ) );
* Exceptions with getTalk()
* NS_MEDIA does not have talk pages. MediaWiki raise an exception for them.
* @expectedException MWException
+ * @covers MWNamespace::getTalk
*/
public function testGetTalkExceptionsForNsMedia() {
$this->assertNull( MWNamespace::getTalk( NS_MEDIA ) );
* Exceptions with getTalk()
* NS_SPECIAL does not have talk pages. MediaWiki raise an exception for them.
* @expectedException MWException
+ * @covers MWNamespace::getTalk
*/
public function testGetTalkExceptionsForNsSpecial() {
$this->assertNull( MWNamespace::getTalk( NS_SPECIAL ) );
* Regular getAssociated() calls
* Namespaces without an associated page (NS_MEDIA, NS_SPECIAL) are tested in
* the function testGetAssociatedExceptions()
+ * @covers MWNamespace::getAssociated
*/
public function testGetAssociated() {
$this->assertEquals( NS_TALK, MWNamespace::getAssociated( NS_MAIN ) );
$this->assertEquals( NS_MAIN, MWNamespace::getAssociated( NS_TALK ) );
}
- ### Exceptions with getAssociated()
- ### NS_MEDIA and NS_SPECIAL do not have talk pages. MediaWiki raises
- ### an exception for them.
+ # ## Exceptions with getAssociated()
+ # ## NS_MEDIA and NS_SPECIAL do not have talk pages. MediaWiki raises
+ # ## an exception for them.
/**
* @expectedException MWException
+ * @covers MWNamespace::getAssociated
*/
public function testGetAssociatedExceptionsForNsMedia() {
$this->assertNull( MWNamespace::getAssociated( NS_MEDIA ) );
/**
* @expectedException MWException
+ * @covers MWNamespace::getAssociated
*/
public function testGetAssociatedExceptionsForNsSpecial() {
$this->assertNull( MWNamespace::getAssociated( NS_SPECIAL ) );
* Note if we add a namespace registration system with keys like 'MAIN'
* we should add tests here for equivilance on things like 'MAIN' == 0
* and 'MAIN' == NS_MAIN.
+ * @covers MWNamespace::equals
*/
public function testEquals() {
$this->assertTrue( MWNamespace::equals( NS_MAIN, NS_MAIN ) );
}
/**
- * Test MWNamespace::subjectEquals
+ * @covers MWNamespace::subjectEquals
*/
public function testSubjectEquals() {
$this->assertSameSubject( NS_MAIN, NS_MAIN );
$this->assertDifferentSubject( NS_SPECIAL, NS_MAIN );
}
+ /**
+ * @covers MWNamespace::subjectEquals
+ */
public function testSpecialAndMediaAreDifferentSubjects() {
$this->assertDifferentSubject(
NS_MEDIA, NS_SPECIAL,
*/
/**
+ * @covers MWNamespace::canTalk
*/
public function testCanTalk() {
$this->assertCanNotTalk( NS_MEDIA );
}
/**
+ * @covers MWNamespace::isContent
*/
public function testIsContent() {
// NS_MAIN is a content namespace per DefaultSettings.php
/**
* Similar to testIsContent() but alters the $wgContentNamespaces
* global variable.
+ * @covers MWNamespace::isContent
*/
public function testIsContentAdvanced() {
global $wgContentNamespaces;
$this->assertIsContent( NS_MAIN );
}
+ /**
+ * @covers MWNamespace::isWatchable
+ */
public function testIsWatchable() {
// Specials namespaces are not watchable
$this->assertIsNotWatchable( NS_MEDIA );
$this->assertIsWatchable( 101 );
}
+ /**
+ * @covers MWNamespace::hasSubpages
+ */
public function testHasSubpages() {
global $wgNamespacesWithSubpages;
}
/**
+ * @covers MWNamespace::getContentNamespaces
*/
public function testGetContentNamespaces() {
global $wgContentNamespaces;
}
/**
+ * @covers MWNamespace::getSubjectNamespaces
*/
public function testGetSubjectNamespaces() {
$subjectsNS = MWNamespace::getSubjectNamespaces();
}
/**
+ * @covers MWNamespace::getTalkNamespaces
*/
public function testGetTalkNamespaces() {
$talkNS = MWNamespace::getTalkNamespaces();
/**
* Some namespaces are always capitalized per code definition
* in MWNamespace::$alwaysCapitalizedNamespaces
+ * @covers MWNamespace::isCapitalized
*/
public function testIsCapitalizedHardcodedAssertions() {
// NS_MEDIA and NS_FILE are treated the same
*
* Global setting correctness is tested against the NS_PROJECT and
* NS_PROJECT_TALK namespaces since they are not hardcoded nor specials
+ * @covers MWNamespace::isCapitalized
*/
public function testIsCapitalizedWithWgCapitalLinks() {
global $wgCapitalLinks;
* testing the $wgCapitalLinkOverrides global.
*
* @todo split groups of assertions in autonomous testing functions
+ * @covers MWNamespace::isCapitalized
*/
public function testIsCapitalizedWithWgCapitalLinkOverrides() {
global $wgCapitalLinkOverrides;
$this->assertIsCapitalized( NS_PROJECT );
}
+ /**
+ * @covers MWNamespace::hasGenderDistinction
+ */
public function testHasGenderDistinction() {
// Namespaces with gender distinctions
$this->assertTrue( MWNamespace::hasGenderDistinction( NS_USER ) );
$this->assertFalse( MWNamespace::hasGenderDistinction( NS_TALK ) );
}
+ /**
+ * @covers MWNamespace::isNonincludable
+ */
public function testIsNonincludable() {
global $wgNonincludableNamespaces;
$this->assertFalse( MWNamespace::isNonincludable( NS_TEMPLATE ) );
}
- ####### HELPERS ###########################################################
+ # ###### HELPERS ###########################################################
function __call( $method, $args ) {
// Call the real method if it exists
if ( method_exists( $this, $method ) ) {
return $this->$method( $args );
}
- if ( preg_match( '/^assert(Has|Is|Can)(Not|)(Subject|Talk|Watchable|Content|Subpages|Capitalized)$/', $method, $m ) ) {
+ if ( preg_match(
+ '/^assert(Has|Is|Can)(Not|)(Subject|Talk|Watchable|Content|Subpages|Capitalized)$/',
+ $method,
+ $m
+ ) ) {
# Interprets arguments:
$ns = $args[0];
$msg = isset( $args[1] ) ? $args[1] : " dummy message";