Merge "PreferencesFormOOUI: Avoid Phan warning with weird signature of TabPanelLayout"
[lhc/web/wiklou.git] / tests / phpunit / includes / PagePropsTest.php
index 29c9e22..222b3e3 100644 (file)
@@ -1,13 +1,17 @@
 <?php
 
+use MediaWiki\MediaWikiServices;
+
 /**
+ * @covers PageProps
+ *
  * @group Database
  *     ^--- tell jenkins this test needs the database
  *
  * @group medium
  *     ^--- tell phpunit that these test cases may take longer than 2 seconds.
  */
-class TestPageProps extends MediaWikiLangTestCase {
+class PagePropsTest extends MediaWikiLangTestCase {
 
        /**
         * @var Title $title1
@@ -25,18 +29,20 @@ class TestPageProps extends MediaWikiLangTestCase {
        private $the_properties;
 
        protected function setUp() {
-               global $wgExtraNamespaces, $wgNamespaceContentModels, $wgContentHandlers, $wgContLang;
-
                parent::setUp();
 
-               $wgExtraNamespaces[12312] = 'Dummy';
-               $wgExtraNamespaces[12313] = 'Dummy_talk';
-
-               $wgNamespaceContentModels[12312] = 'DUMMY';
-               $wgContentHandlers['DUMMY'] = 'DummyContentHandlerForTesting';
+               $this->setMwGlobals( [
+                       'wgExtraNamespaces' => [
+                               12312 => 'Dummy',
+                               12313 => 'Dummy_talk',
+                       ],
+                       'wgNamespaceContentModels' => [ 12312 => 'DUMMY' ],
+               ] );
 
-               MWNamespace::getCanonicalNamespaces( true ); # reset namespace cache
-               $wgContLang->resetNamespaces(); # reset namespace cache
+               $this->mergeMwGlobalArrayValue(
+                       'wgContentHandlers',
+                       [ 'DUMMY' => 'DummyContentHandlerForTesting' ]
+               );
 
                if ( !$this->the_properties ) {
                        $this->the_properties = [
@@ -70,21 +76,6 @@ class TestPageProps extends MediaWikiLangTestCase {
                }
        }
 
-       protected function tearDown() {
-               global $wgExtraNamespaces, $wgNamespaceContentModels, $wgContentHandlers, $wgContLang;
-
-               parent::tearDown();
-
-               unset( $wgExtraNamespaces[12312] );
-               unset( $wgExtraNamespaces[12313] );
-
-               unset( $wgNamespaceContentModels[12312] );
-               unset( $wgContentHandlers['DUMMY'] );
-
-               MWNamespace::getCanonicalNamespaces( true ); # reset namespace cache
-               $wgContLang->resetNamespaces(); # reset namespace cache
-       }
-
        /**
         * Test getting a single property from a single page. The property was
         * set in setUp().
@@ -245,7 +236,8 @@ class TestPageProps extends MediaWikiLangTestCase {
                                ( $model === null || $model === CONTENT_MODEL_WIKITEXT )
                        ) {
                                $ns = $this->getDefaultWikitextNS();
-                               $page = MWNamespace::getCanonicalName( $ns ) . ':' . $page;
+                               $page = MediaWikiServices::getInstance()->getNamespaceInfo()->
+                                       getCanonicalName( $ns ) . ':' . $page;
                        }
 
                        $page = Title::newFromText( $page );