* 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;
}
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.
'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',
*/
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;
}
* after each test runs.
*/
private function teardownGlobals() {
+ RepoGroup::destroySingleton();
foreach( $this->savedGlobals as $var => $val ) {
$GLOBALS[$var] = $val;
}