* @file
*/
-/**
- * Test class for MWNamespace.
- * @todo covers tags
- * @todo FIXME: this test file is a mess
- */
class MWNamespaceTest extends MediaWikiTestCase {
+
protected function setUp() {
parent::setUp();
] );
}
-# ### START OF TESTS #########################################################
-
/**
* @todo Write more texts, handle $wgAllowImageMoving setting
* @covers MWNamespace::isMovable
*/
public function testIsMovable() {
$this->assertFalse( MWNamespace::isMovable( NS_SPECIAL ) );
- # @todo FIXME: Write more tests!!
}
/**
$this->assertNull( MWNamespace::getAssociated( NS_SPECIAL ) );
}
- /**
- * @todo Implement testExists().
- */
- /*
- public function testExists() {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet. Rely on $wgCanonicalNamespaces.'
- );
- }
- */
-
/**
* Test MWNamespace::equals
* Note if we add a namespace registration system with keys like 'MAIN'
);
}
- /**
- * @todo Implement testGetCanonicalNamespaces().
- */
- /*
- public function testGetCanonicalNamespaces() {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet. Rely on $wgCanonicalNamespaces.'
- );
- }
- */
- /**
- * @todo Implement testGetCanonicalName().
- */
- /*
- public function testGetCanonicalName() {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet. Rely on $wgCanonicalNamespaces.'
- );
- }
- */
- /**
- * @todo Implement testGetCanonicalIndex().
- */
- /*
- public function testGetCanonicalIndex() {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet. Rely on $wgCanonicalNamespaces.'
- );
+ public function provideHasTalkNamespace() {
+ return [
+ [ NS_MEDIA, false ],
+ [ NS_SPECIAL, false ],
+
+ [ NS_MAIN, true ],
+ [ NS_TALK, true ],
+ [ NS_USER, true ],
+ [ NS_USER_TALK, true ],
+
+ [ 100, true ],
+ [ 101, true ],
+ ];
}
- */
/**
- * @todo Implement testGetValidNamespaces().
+ * @dataProvider provideHasTalkNamespace
+ * @covers MWNamespace::hasTalkNamespace
+ *
+ * @param int $index
+ * @param bool $expected
*/
- /*
- public function testGetValidNamespaces() {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet. Rely on $wgCanonicalNamespaces.'
- );
+ public function testHasTalkNamespace( $index, $expected ) {
+ $actual = MWNamespace::hasTalkNamespace( $index );
+ $this->assertSame( $actual, $expected, "NS $index" );
}
- */
/**
+ * @dataProvider provideHasTalkNamespace
* @covers MWNamespace::canTalk
+ *
+ * @param int $index
+ * @param bool $expected
*/
- public function testCanTalk() {
- $this->assertCanNotTalk( NS_MEDIA );
- $this->assertCanNotTalk( NS_SPECIAL );
-
- $this->assertCanTalk( NS_MAIN );
- $this->assertCanTalk( NS_TALK );
- $this->assertCanTalk( NS_USER );
- $this->assertCanTalk( NS_USER_TALK );
-
- // User defined namespaces
- $this->assertCanTalk( 100 );
- $this->assertCanTalk( 101 );
+ public function testCanTalk( $index, $expected ) {
+ $actual = MWNamespace::canTalk( $index );
+ $this->assertSame( $actual, $expected, "NS $index" );
}
/**