From: Tim Starling Date: Sun, 3 Jun 2007 09:05:29 +0000 (+0000) Subject: Fixed most of the parser tests broken by filerepo merge X-Git-Tag: 1.31.0-rc.0~52715 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/password.php?a=commitdiff_plain;h=ed732bda059d54aa04586763e86ef8465df390ef;p=lhc%2Fweb%2Fwiklou.git Fixed most of the parser tests broken by filerepo merge --- diff --git a/includes/filerepo/RepoGroup.php b/includes/filerepo/RepoGroup.php index 021d3ba737..1c35eaa5a0 100644 --- a/includes/filerepo/RepoGroup.php +++ b/includes/filerepo/RepoGroup.php @@ -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. diff --git a/maintenance/parserTests.inc b/maintenance/parserTests.inc index b2dffa7d80..75bc39d882 100644 --- a/maintenance/parserTests.inc +++ b/maintenance/parserTests.inc @@ -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; }