diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2007-09-14 13:18:58 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2007-09-14 13:18:58 +0200 |
commit | 8f416baead93a48e5799e44b8bd2e2c4859f4e04 (patch) | |
tree | cd47ac55eb80a39e3225e8b4f3161b88ea16c2cf /maintenance/parserTests.inc | |
parent | d7d08bd1a17618c7d77a6b9b2989e9f7293d6ed6 (diff) |
auf Version 1.11 aktualisiert; Login-Bug behoben
Diffstat (limited to 'maintenance/parserTests.inc')
-rw-r--r-- | maintenance/parserTests.inc | 68 |
1 files changed, 39 insertions, 29 deletions
diff --git a/maintenance/parserTests.inc b/maintenance/parserTests.inc index ddf8b89a..510a2db2 100644 --- a/maintenance/parserTests.inc +++ b/maintenance/parserTests.inc @@ -327,6 +327,22 @@ class ParserTest { } } + + /** + * Use a regex to find out the value of an option + * @param $regex A regex, the first group will be the value returned + * @param $opts Options line to look in + * @param $defaults Default value returned if the regex does not match + */ + private static function getOptionValue( $regex, $opts, $default ) { + $m = array(); + if( preg_match( $regex, $opts, $m ) ) { + return $m[1]; + } else { + return $default; + } + } + /** * Set up the global variables for a consistent environment for each test. * Ideally this should replace the global configuration entirely. @@ -342,19 +358,13 @@ class ParserTest { $this->uploadDir = $this->setupUploadDir(); } - $m = array(); - if( preg_match( '/language=([a-z]+(?:_[a-z]+)?)/', $opts, $m ) ) { - $lang = $m[1]; - } else { - $lang = 'en'; - } - - if( preg_match( '/variant=([a-z]+(?:-[a-z]+)?)/', $opts, $m ) ) { - $variant = $m[1]; - } else { - $variant = false; - } - + # Find out values for some special options. + $lang = + self::getOptionValue( '/language=([a-z]+(?:_[a-z]+)?)/', $opts, 'en' ); + $variant = + self::getOptionValue( '/variant=([a-z]+(?:-[a-z]+)?)/', $opts, false ); + $maxtoclevel = + self::getOptionValue( '/wgMaxTocLevel=(\d+)/', $opts, 999 ); $settings = array( 'wgServer' => 'http://localhost', @@ -362,8 +372,15 @@ 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, + ), + 'wgEnableUploads' => true, 'wgStyleSheetPath' => '/skins', 'wgSitename' => 'MediaWiki', 'wgServerName' => 'Britney Spears', @@ -374,7 +391,7 @@ class ParserTest { 'wgLang' => null, 'wgContLang' => null, 'wgNamespacesWithSubpages' => array( 0 => preg_match('/\\bsubpage\\b/i', $opts)), - 'wgMaxTocLevel' => 999, + 'wgMaxTocLevel' => $maxtoclevel, 'wgCapitalLinks' => true, 'wgNoFollowLinks' => true, 'wgThumbnailScriptPath' => false, @@ -416,7 +433,7 @@ class ParserTest { 'watchlist', 'math', 'searchindex', 'interwiki', 'querycache', 'objectcache', 'job', 'redirect', - 'querycachetwo' + 'querycachetwo', 'archive', 'user_groups' ); // Allow extensions to add to the list of tables to duplicate; @@ -531,20 +548,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; } @@ -553,6 +562,7 @@ class ParserTest { * after each test runs. */ private function teardownGlobals() { + RepoGroup::destroySingleton(); foreach( $this->savedGlobals as $var => $val ) { $GLOBALS[$var] = $val; } @@ -593,7 +603,7 @@ class ParserTest { } /** - * @desc delete the specified files, if they exist. + * Delete the specified files, if they exist. * @param array $files full paths to files to delete. */ private static function deleteFiles( $files ) { @@ -605,7 +615,7 @@ class ParserTest { } /** - * @desc delete the specified directories, if they exist. Must be empty. + * Delete the specified directories, if they exist. Must be empty. * @param array $dirs full paths to directories to delete. */ private static function deleteDirs( $dirs ) { |