Merge "Fixed dependencies for jquery.collapsibleTabs"
[lhc/web/wiklou.git] / tests / phpunit / includes / TitleMethodsTest.php
index de8f18f..44fd690 100644 (file)
@@ -2,34 +2,43 @@
 
 /**
  * @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 ),
@@ -42,7 +51,7 @@ class TitleMethodsTest extends MediaWikiTestCase {
        }
 
        /**
-        * @dataProvider dataEquals
+        * @dataProvider provideEquals
         */
        public function testEquals( $titleA, $titleB, $expectedBool ) {
                $titleA = Title::newFromText( $titleA );
@@ -52,7 +61,7 @@ class TitleMethodsTest extends MediaWikiTestCase {
                $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 ),
@@ -66,7 +75,7 @@ class TitleMethodsTest extends MediaWikiTestCase {
        }
 
        /**
-        * @dataProvider dataInNamespace
+        * @dataProvider provideInNamespace
         */
        public function testInNamespace( $title, $ns, $expectedBool ) {
                $title = Title::newFromText( $title );
@@ -81,7 +90,7 @@ class TitleMethodsTest extends MediaWikiTestCase {
                $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 ),
@@ -95,7 +104,7 @@ class TitleMethodsTest extends MediaWikiTestCase {
        }
 
        /**
-        * @dataProvider dataHasSubjectNamespace
+        * @dataProvider provideHasSubjectNamespace
         */
        public function testHasSubjectNamespace( $title, $ns, $expectedBool ) {
                $title = Title::newFromText( $title );
@@ -104,9 +113,9 @@ class TitleMethodsTest extends MediaWikiTestCase {
 
        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 ),
@@ -143,11 +152,11 @@ class TitleMethodsTest extends MediaWikiTestCase {
                $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 ),
@@ -166,7 +175,7 @@ class TitleMethodsTest extends MediaWikiTestCase {
        }
 
        /**
-        * @dataProvider dataIsCssOrJsPage
+        * @dataProvider provideIsCssOrJsPage
         */
        public function testIsCssOrJsPage( $title, $expectedBool ) {
                $title = Title::newFromText( $title );
@@ -174,11 +183,11 @@ class TitleMethodsTest extends MediaWikiTestCase {
        }
 
 
-       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 ),
@@ -195,17 +204,17 @@ class TitleMethodsTest extends MediaWikiTestCase {
        }
 
        /**
-        * @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 ),
@@ -215,17 +224,17 @@ class TitleMethodsTest extends MediaWikiTestCase {
        }
 
        /**
-        * @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 ),
@@ -235,18 +244,18 @@ class TitleMethodsTest extends MediaWikiTestCase {
        }
 
        /**
-        * @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 ),
@@ -266,7 +275,7 @@ class TitleMethodsTest extends MediaWikiTestCase {
        }
 
        /**
-        * @dataProvider dataIsWikitextPage
+        * @dataProvider provideIsWikitextPage
         */
        public function testIsWikitextPage( $title, $expectedBool ) {
                $title = Title::newFromText( $title );