Revert r108358. It's a good fellow and we like to keep it.
[lhc/web/wiklou.git] / tests / phpunit / includes / parser / NewParserTest.php
index 37a0486..e999796 100644 (file)
@@ -32,10 +32,6 @@ class NewParserTest extends MediaWikiTestCase {
 
        protected $file = false;
 
-       /*function __construct($a = null,$b = array(),$c = null ) {
-               parent::__construct($a,$b,$c);
-       }*/
-
        function setUp() {
                global $wgContLang, $wgNamespaceProtection, $wgNamespaceAliases;
                global $wgHooks, $IP;
@@ -60,15 +56,14 @@ class NewParserTest extends MediaWikiTestCase {
                $tmpGlobals['wgStylePath'] = '/skins';
                $tmpGlobals['wgThumbnailScriptPath'] = false;
                $tmpGlobals['wgLocalFileRepo'] = array(
-                       'class' => 'LocalRepo',
-                       'name' => 'local',
-                       'directory' => wfTempDir() . '/test-repo',
-                       'url' => 'http://example.com/images',
-                       'deletedDir' => wfTempDir() . '/test-repo/delete',
-                       'hashLevels' => 2,
+                       'class'           => 'LocalRepo',
+                       'name'            => 'local',
+                       'url'             => 'http://example.com/images',
+                       'hashLevels'      => 2,
                        'transformVia404' => false,
+                       'backend'         => 'local-backend'
                );
-
+               $tmpGlobals['wgForeignFileRepos'] = array();
                $tmpGlobals['wgEnableParserCache'] = false;
                $tmpGlobals['wgHooks'] = $wgHooks;
                $tmpGlobals['wgDeferredUpdateList'] = array();
@@ -104,11 +99,9 @@ class NewParserTest extends MediaWikiTestCase {
                $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
                $wgNamespaceAliases['Image'] = NS_FILE;
                $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
-
        }
 
        public function tearDown() {
-
                foreach ( $this->savedInitialGlobals as $var => $val ) {
                        $GLOBALS[$var] = $val;
                }
@@ -118,9 +111,14 @@ class NewParserTest extends MediaWikiTestCase {
                $wgNamespaceProtection[NS_MEDIAWIKI] = $this->savedWeirdGlobals['mw_namespace_protection'];
                $wgNamespaceAliases['Image'] = $this->savedWeirdGlobals['image_alias'];
                $wgNamespaceAliases['Image_talk'] = $this->savedWeirdGlobals['image_talk_alias'];
+
+               // Restore backends
+               RepoGroup::destroySingleton();
+               FileBackendGroup::destroySingleton();
        }
 
        function addDBData() {
+               $this->tablesUsed[] = 'image';
                # Hack: insert a few Wikipedia in-project interwiki prefixes,
                # for testing inter-language links
                $this->db->insert( 'interwiki', array(
@@ -234,12 +232,19 @@ class NewParserTest extends MediaWikiTestCase {
                        'wgExtensionAssetsPath' => '/extensions',
                        'wgActionPaths' => array(),
                        'wgLocalFileRepo' => array(
-                               'class' => 'LocalRepo',
-                               'name' => 'local',
-                               'directory' => $this->uploadDir,
-                               'url' => 'http://example.com/images',
-                               'hashLevels' => 2,
+                               'class'           => 'LocalRepo',
+                               'name'            => 'local',
+                               'url'             => 'http://example.com/images',
+                               'hashLevels'      => 2,
                                'transformVia404' => false,
+                               'backend'         => new FSFileBackend( array(
+                                       'name'        => 'local-backend',
+                                       'lockManager' => 'nullLockManager',
+                                       'containerPaths' => array(
+                                               'local-public' => "$this->uploadDir",
+                                               'local-thumb'  => "$this->uploadDir/thumb",
+                                       )
+                               ) )
                        ),
                        'wgEnableUploads' => self::getOptionValue( 'wgEnableUploads', $opts, true ),
                        'wgStylePath' => '/skins',
@@ -321,12 +326,15 @@ class NewParserTest extends MediaWikiTestCase {
                $wgHooks['ParserGetVariableValueTs'][] = 'ParserTest::getFakeTimestamp';
 
                MagicWord::clearCache();
+               RepoGroup::destroySingleton();
+               FileBackendGroup::destroySingleton();
 
                # Publish the articles after we have the final language set
                $this->publishTestArticles();
 
                # The entries saved into RepoGroup cache with previous globals will be wrong.
                RepoGroup::destroySingleton();
+               FileBackendGroup::destroySingleton();
                MessageCache::singleton()->destroyInstance();
 
                return $context;
@@ -370,13 +378,13 @@ class NewParserTest extends MediaWikiTestCase {
         * after each test runs.
         */
        protected function teardownGlobals() {
-               RepoGroup::destroySingleton();
-               LinkCache::singleton()->clear();
-
                foreach ( $this->savedGlobals as $var => $val ) {
                        $GLOBALS[$var] = $val;
                }
 
+               RepoGroup::destroySingleton();
+               LinkCache::singleton()->clear();
+
                $this->teardownUploadDir( $this->uploadDir );
        }
 
@@ -690,7 +698,7 @@ class NewParserTest extends MediaWikiTestCase {
        //Various action functions
 
        public function addArticle( $name, $text, $line ) {
-               self::$articles[$name] = $text;
+               self::$articles[$name] = array( $text, $line );
        }
 
        public function publishTestArticles() {
@@ -698,12 +706,9 @@ class NewParserTest extends MediaWikiTestCase {
                        return;
                }
 
-               foreach ( self::$articles as $name => $text ) {
-                       $title = Title::newFromText( $name );
-
-                       if ( $title->getArticleID( Title::GAID_FOR_UPDATE ) == 0 ) {
-                               ParserTest::addArticle( $name, $text );
-                       }
+               foreach ( self::$articles as $name => $info ) {
+                       list( $text, $line ) = $info;
+                       ParserTest::addArticle( $name, $text, $line, 'ignoreduplicate' );
                }
        }
 
@@ -757,10 +762,6 @@ class NewParserTest extends MediaWikiTestCase {
                }
        }
 
-       public function showRunFile( $file ) {
-               /* NOP */
-       }
-
        //Test options parser functions
 
        protected function parseOptions( $instring ) {