/**
* @group ContentHandler
+ *
+ * @note: We don't make assumptions about the main namespace.
+ * But we do expect the Help namespace to contain Wikitext.
+ *
*/
class TitleMethodsTest extends MediaWikiTestCase {
public function setup() {
global $wgExtraNamespaces, $wgNamespaceContentModels, $wgContLang;
- $wgExtraNamespaces[ 12302 ] = 'TEST-JS';
- $wgExtraNamespaces[ 12303 ] = 'TEST-JS_TALK';
+ $this->mergeMwGlobalArrayValue(
+ 'wgExtraNamespaces',
+ array(
+ 12302 => 'TEST-JS',
+ 12303 => 'TEST-JS_TALK',
+ )
+ );
- $wgNamespaceContentModels[ 12302 ] = CONTENT_MODEL_JAVASCRIPT;
+ $this->mergeMwGlobalArrayValue(
+ 'wgNamespaceContentModels',
+ array(
+ 12302 => CONTENT_MODEL_JAVASCRIPT,
+ )
+ );
MWNamespace::getCanonicalNamespaces( true ); # reset namespace cache
$wgContLang->resetNamespaces(); # reset namespace cache
}
public function teardown() {
- global $wgExtraNamespaces, $wgNamespaceContentModels, $wgContLang;
-
- unset( $wgExtraNamespaces[ 12302 ] );
- unset( $wgExtraNamespaces[ 12303 ] );
-
- unset( $wgNamespaceContentModels[ 12302 ] );
+ global $wgContLang;
MWNamespace::getCanonicalNamespaces( true ); # reset namespace cache
$wgContLang->resetNamespaces(); # reset namespace cache
}
- public function dataEquals() {
+ public static function provideEquals() {
return array(
array( 'Main Page', 'Main Page', true ),
array( 'Main Page', 'Not The Main Page', false ),
}
/**
- * @dataProvider dataEquals
+ * @dataProvider provideEquals
*/
public function testEquals( $titleA, $titleB, $expectedBool ) {
$titleA = Title::newFromText( $titleA );
$this->assertEquals( $expectedBool, $titleB->equals( $titleA ) );
}
- public function dataInNamespace() {
+ public static function provideInNamespace() {
return array(
array( 'Main Page', NS_MAIN, true ),
array( 'Main Page', NS_TALK, false ),
}
/**
- * @dataProvider dataInNamespace
+ * @dataProvider provideInNamespace
*/
public function testInNamespace( $title, $ns, $expectedBool ) {
$title = Title::newFromText( $title );
$this->assertFalse( $mainpage->inNamespaces( array( NS_PROJECT, NS_TEMPLATE ) ) );
}
- public function dataHasSubjectNamespace() {
+ public static function provideHasSubjectNamespace() {
return array(
array( 'Main Page', NS_MAIN, true ),
array( 'Main Page', NS_TALK, true ),
}
/**
- * @dataProvider dataHasSubjectNamespace
+ * @dataProvider provideHasSubjectNamespace
*/
public function testHasSubjectNamespace( $title, $ns, $expectedBool ) {
$title = Title::newFromText( $title );
public function dataGetContentModel() {
return array(
- array( 'Foo', CONTENT_MODEL_WIKITEXT ),
- array( 'Foo.js', CONTENT_MODEL_WIKITEXT ),
- array( 'Foo/bar.js', CONTENT_MODEL_WIKITEXT ),
+ array( 'Help:Foo', CONTENT_MODEL_WIKITEXT ),
+ array( 'Help:Foo.js', CONTENT_MODEL_WIKITEXT ),
+ array( 'Help:Foo/bar.js', CONTENT_MODEL_WIKITEXT ),
array( 'User:Foo', CONTENT_MODEL_WIKITEXT ),
array( 'User:Foo.js', CONTENT_MODEL_WIKITEXT ),
array( 'User:Foo/bar.js', CONTENT_MODEL_JAVASCRIPT ),
$this->assertTrue( $title->hasContentModel( $expectedModelId ) );
}
- public function dataIsCssOrJsPage() {
+ public static function provideIsCssOrJsPage() {
return array(
- array( 'Foo', false ),
- array( 'Foo.js', false ),
- array( 'Foo/bar.js', false ),
+ array( 'Help:Foo', false ),
+ array( 'Help:Foo.js', false ),
+ array( 'Help:Foo/bar.js', false ),
array( 'User:Foo', false ),
array( 'User:Foo.js', false ),
array( 'User:Foo/bar.js', false ),
}
/**
- * @dataProvider dataIsCssOrJsPage
+ * @dataProvider provideIsCssOrJsPage
*/
public function testIsCssOrJsPage( $title, $expectedBool ) {
$title = Title::newFromText( $title );
}
- public function dataIsCssJsSubpage() {
+ public static function provideIsCssJsSubpage() {
return array(
- array( 'Foo', false ),
- array( 'Foo.js', false ),
- array( 'Foo/bar.js', false ),
+ array( 'Help:Foo', false ),
+ array( 'Help:Foo.js', false ),
+ array( 'Help:Foo/bar.js', false ),
array( 'User:Foo', false ),
array( 'User:Foo.js', false ),
array( 'User:Foo/bar.js', true ),
}
/**
- * @dataProvider dataIsCssJsSubpage
+ * @dataProvider provideIsCssJsSubpage
*/
public function testIsCssJsSubpage( $title, $expectedBool ) {
$title = Title::newFromText( $title );
$this->assertEquals( $expectedBool, $title->isCssJsSubpage() );
}
- public function dataIsCssSubpage() {
+ public static function provideIsCssSubpage() {
return array(
- array( 'Foo', false ),
- array( 'Foo.css', false ),
+ array( 'Help:Foo', false ),
+ array( 'Help:Foo.css', false ),
array( 'User:Foo', false ),
array( 'User:Foo.js', false ),
array( 'User:Foo.css', false ),
}
/**
- * @dataProvider dataIsCssSubpage
+ * @dataProvider provideIsCssSubpage
*/
public function testIsCssSubpage( $title, $expectedBool ) {
$title = Title::newFromText( $title );
$this->assertEquals( $expectedBool, $title->isCssSubpage() );
}
- public function dataIsJsSubpage() {
+ public static function provideIsJsSubpage() {
return array(
- array( 'Foo', false ),
- array( 'Foo.css', false ),
+ array( 'Help:Foo', false ),
+ array( 'Help:Foo.css', false ),
array( 'User:Foo', false ),
array( 'User:Foo.js', false ),
array( 'User:Foo.css', false ),
}
/**
- * @dataProvider dataIsJsSubpage
+ * @dataProvider provideIsJsSubpage
*/
public function testIsJsSubpage( $title, $expectedBool ) {
$title = Title::newFromText( $title );
$this->assertEquals( $expectedBool, $title->isJsSubpage() );
}
- public function dataIsWikitextPage() {
+ public static function provideIsWikitextPage() {
return array(
- array( 'Foo', true ),
- array( 'Foo.js', true ),
- array( 'Foo/bar.js', true ),
+ array( 'Help:Foo', true ),
+ array( 'Help:Foo.js', true ),
+ array( 'Help:Foo/bar.js', true ),
array( 'User:Foo', true ),
array( 'User:Foo.js', true ),
array( 'User:Foo/bar.js', false ),
}
/**
- * @dataProvider dataIsWikitextPage
+ * @dataProvider provideIsWikitextPage
*/
public function testIsWikitextPage( $title, $expectedBool ) {
$title = Title::newFromText( $title );