Merge "Fix RevisionStorageTest with non-wikitext NS_MAIN"
[lhc/web/wiklou.git] / tests / phpunit / includes / ParserOptionsTest.php
index 9c50cc4..5b2adaf 100644 (file)
@@ -5,15 +5,19 @@ class ParserOptionsTest extends MediaWikiTestCase {
        private $popts;
        private $pcache;
 
-       function setUp() {
-               global $wgContLang, $wgUser, $wgLanguageCode;
-               $wgContLang = Language::factory( $wgLanguageCode );
-               $this->popts = new ParserOptions( $wgUser );
-               $this->pcache = ParserCache::singleton();
-       }
+       protected function setUp() {
+               global $wgLanguageCode, $wgUser;
+               parent::setUp();
+
+               $langObj = Language::factory( $wgLanguageCode );
+
+               $this->setMwGlobals( array(
+                       'wgContLang' => $langObj,
+                       'wgUseDynamicDates' => true,
+               ) );
 
-       function tearDown() {
-               parent::tearDown();
+               $this->popts = ParserOptions::newFromUserAndLang( $wgUser, $langObj );
+               $this->pcache = ParserCache::singleton();
        }
 
        /**
@@ -21,15 +25,13 @@ class ParserOptionsTest extends MediaWikiTestCase {
         * @group Database
         */
        function testGetParserCacheKeyWithDynamicDates() {
-               global $wgUseDynamicDates;
-               $wgUseDynamicDates = true;
-
                $title = Title::newFromText( "Some test article" );
-               $article = new Article( $title );
+               $page = WikiPage::factory( $title );
 
-               $pcacheKeyBefore = $this->pcache->getKey( $article, $this->popts );
+               $pcacheKeyBefore = $this->pcache->getKey( $page, $this->popts );
                $this->assertNotNull( $this->popts->getDateFormat() );
-               $pcacheKeyAfter = $this->pcache->getKey( $article, $this->popts );
+
+               $pcacheKeyAfter = $this->pcache->getKey( $page, $this->popts );
                $this->assertEquals( $pcacheKeyBefore, $pcacheKeyAfter );
        }
 }