Fixed most of the parser tests broken by filerepo merge
authorTim Starling <tstarling@users.mediawiki.org>
Sun, 3 Jun 2007 09:05:29 +0000 (09:05 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sun, 3 Jun 2007 09:05:29 +0000 (09:05 +0000)
includes/filerepo/RepoGroup.php
maintenance/parserTests.inc

index 021d3ba..1c35eaa 100644 (file)
@@ -14,7 +14,7 @@ class RepoGroup {
         * Get a RepoGroup instance. At present only one instance of RepoGroup is
         * needed in a MediaWiki invocation, this may change in the future.
         */
-       function singleton() {
+       static function singleton() {
                if ( self::$instance ) {
                        return self::$instance;
                }
@@ -23,6 +23,14 @@ class RepoGroup {
                return self::$instance;
        }
 
+       /**
+        * Destroy the singleton instance, so that a new one will be created next
+        * time singleton() is called.
+        */
+       static function destroySingleton() {
+               self::$instance = null;
+       }
+
        /**
         * Construct a group of file repositories. 
         * @param array $data Array of repository info arrays. 
index b2dffa7..75bc39d 100644 (file)
@@ -372,8 +372,14 @@ class ParserTest {
                        'wgScriptPath' => '/',
                        'wgArticlePath' => '/wiki/$1',
                        'wgActionPaths' => array(),
-                       'wgUploadPath' => 'http://example.com/images',
-                       'wgUploadDirectory' => $this->uploadDir,
+                       'wgLocalFileRepo' => array(
+                               'class' => 'LocalRepo',
+                               'name' => 'local',
+                               'directory' => $this->uploadDir,
+                               'url' => 'http://example.com/images',
+                               'hashLevels' => 2,
+                               'transformVia404' => false,
+                       ),
                        'wgStyleSheetPath' => '/skins',
                        'wgSitename' => 'MediaWiki',
                        'wgServerName' => 'Britney Spears',
@@ -541,20 +547,12 @@ class ParserTest {
         */
        private function setupUploadDir() {
                global $IP;
-
                $dir = wfTempDir() . "/mwParser-" . mt_rand() . "-images";
+               wfDebug( "Creating upload directory $dir\n" );
                mkdir( $dir );
                mkdir( $dir . '/3' );
                mkdir( $dir . '/3/3a' );
-
-               $img = "$IP/skins/monobook/headbg.jpg";
-               $h = fopen($img, 'r');
-               $c = fread($h, filesize($img));
-               fclose($h);
-
-               $f = fopen( $dir . '/3/3a/Foobar.jpg', 'wb' );
-               fwrite( $f, $c );
-               fclose( $f );
+               copy( "$IP/skins/monobook/headbg.jpg", "$dir/3/3a/Foobar.jpg" );
                return $dir;
        }
 
@@ -563,6 +561,7 @@ class ParserTest {
         * after each test runs.
         */
        private function teardownGlobals() {
+               RepoGroup::destroySingleton();
                foreach( $this->savedGlobals as $var => $val ) {
                        $GLOBALS[$var] = $val;
                }