Force $wgContLang to English at the entry point.
This avoids early Titles being localized. Remove setupGlobals() from addArticle() Make the upload dir global. Make the fake uploads a bit saner.
This commit is contained in:
parent
b35aab334c
commit
3a12d1f822
2 changed files with 36 additions and 55 deletions
|
|
@ -41,7 +41,7 @@ class ParserTest {
|
|||
/**
|
||||
* boolean $useTemporaryTables Use temporary tables for the temporary database
|
||||
*/
|
||||
private $useTemporaryTables = true;
|
||||
private $useTemporaryTables = false;
|
||||
|
||||
/**
|
||||
* boolean $databaseSetupDone True if the database has been set up
|
||||
|
|
@ -145,6 +145,7 @@ class ParserTest {
|
|||
* Draw input from a set of test files
|
||||
*/
|
||||
function fuzzTest( $filenames ) {
|
||||
$GLOBALS['wgContLang'] = Language::factory( 'en' );
|
||||
$dict = $this->getFuzzInput( $filenames );
|
||||
$dictSize = strlen( $dict );
|
||||
$logMaxLength = log( $this->maxFuzzTestLength );
|
||||
|
|
@ -265,6 +266,7 @@ class ParserTest {
|
|||
* @return Boolean: true if passed all tests, false if any tests failed.
|
||||
*/
|
||||
public function runTestsFromFiles( $filenames ) {
|
||||
$GLOBALS['wgContLang'] = Language::factory( 'en' );
|
||||
$this->recorder->start();
|
||||
$this->setupDatabase();
|
||||
$ok = true;
|
||||
|
|
@ -486,9 +488,6 @@ class ParserTest {
|
|||
*/
|
||||
private function setupGlobals( $opts = '', $config = '' ) {
|
||||
global $wgDBtype;
|
||||
if ( !isset( $this->uploadDir ) ) {
|
||||
$this->uploadDir = $this->setupUploadDir();
|
||||
}
|
||||
|
||||
# Find out values for some special options.
|
||||
$lang =
|
||||
|
|
@ -711,53 +710,14 @@ class ParserTest {
|
|||
|
||||
|
||||
if ( $wgDBtype == 'oracle' ) {
|
||||
# Insert 0 and 1 user_ids to prevent FK violations
|
||||
# Insert 0 user to prevent FK violations
|
||||
|
||||
# Anonymous user
|
||||
$db->insert( 'user', array(
|
||||
'user_id' => 0,
|
||||
'user_name' => 'Anonymous' ) );
|
||||
|
||||
# Hack-on-Hack: Insert a test user to be able to insert an image
|
||||
$db->insert( 'user', array(
|
||||
'user_id' => 1,
|
||||
'user_name' => 'Tester' ) );
|
||||
}
|
||||
|
||||
# Hack: Insert an image to work with
|
||||
$db->insert( 'image', array(
|
||||
'img_name' => 'Foobar.jpg',
|
||||
'img_size' => 12345,
|
||||
'img_description' => 'Some lame file',
|
||||
'img_user' => 1,
|
||||
'img_user_text' => 'WikiSysop',
|
||||
'img_timestamp' => $db->timestamp( '20010115123500' ),
|
||||
'img_width' => 1941,
|
||||
'img_height' => 220,
|
||||
'img_bits' => 24,
|
||||
'img_media_type' => MEDIATYPE_BITMAP,
|
||||
'img_major_mime' => "image",
|
||||
'img_minor_mime' => "jpeg",
|
||||
'img_metadata' => serialize( array() ),
|
||||
) );
|
||||
|
||||
# This image will be blacklisted in [[MediaWiki:Bad image list]]
|
||||
$db->insert( 'image', array(
|
||||
'img_name' => 'Bad.jpg',
|
||||
'img_size' => 12345,
|
||||
'img_description' => 'zomgnotcensored',
|
||||
'img_user' => 1,
|
||||
'img_user_text' => 'WikiSysop',
|
||||
'img_timestamp' => $db->timestamp( '20010115123500' ),
|
||||
'img_width' => 320,
|
||||
'img_height' => 240,
|
||||
'img_bits' => 24,
|
||||
'img_media_type' => MEDIATYPE_BITMAP,
|
||||
'img_major_mime' => "image",
|
||||
'img_minor_mime' => "jpeg",
|
||||
'img_metadata' => serialize( array() ),
|
||||
) );
|
||||
|
||||
# Update certain things in site_stats
|
||||
$db->insert( 'site_stats', array( 'ss_row_id' => 1, 'ss_images' => 2, 'ss_good_articles' => 1 ) );
|
||||
|
||||
|
|
@ -767,6 +727,31 @@ class ParserTest {
|
|||
# Make a new message cache
|
||||
global $wgMessageCache, $wgMemc;
|
||||
$wgMessageCache = new MessageCache( $wgMemc, true, 3600 );
|
||||
|
||||
$this->uploadDir = $this->setupUploadDir();
|
||||
$user = User::createNew( 'WikiSysop' );
|
||||
$image = wfLocalFile( Title::makeTitle( NS_FILE, 'Foobar.jpg' ) );
|
||||
$image->recordUpload2( '', 'Upload of some lame file', 'Some lame file', array(
|
||||
'width' => 1941,
|
||||
'height' => 220,
|
||||
'bits' => 24,
|
||||
'media_type' => MEDIATYPE_BITMAP,
|
||||
'mime' => 'image/jpeg',
|
||||
'metadata' => serialize( array() ),
|
||||
'fileExists' => true
|
||||
), $db->timestamp( '20010115123500' ), $user );
|
||||
|
||||
# This image will be blacklisted in [[MediaWiki:Bad image list]]
|
||||
$image = wfLocalFile( Title::makeTitle( NS_FILE, 'Bad.jpg' ) );
|
||||
$image->recordUpload2( '', 'zomgnotcensored', 'Borderline image', array(
|
||||
'width' => 320,
|
||||
'height' => 240,
|
||||
'bits' => 24,
|
||||
'media_type' => MEDIATYPE_BITMAP,
|
||||
'mime' => 'image/jpeg',
|
||||
'metadata' => serialize( array() ),
|
||||
'fileExists' => true
|
||||
), $db->timestamp( '20010115123500' ), $user );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -791,6 +776,8 @@ class ParserTest {
|
|||
if ( !$this->databaseSetupDone ) {
|
||||
return;
|
||||
}
|
||||
$this->teardownUploadDir( $this->uploadDir );
|
||||
|
||||
$this->changePrefix( $this->oldTablePrefix );
|
||||
$this->databaseSetupDone = false;
|
||||
if ( $this->useTemporaryTables ) {
|
||||
|
|
@ -825,14 +812,13 @@ class ParserTest {
|
|||
$dir = wfTempDir() . "/mwParser-" . mt_rand() . "-images";
|
||||
}
|
||||
|
||||
wfDebug( "Creating upload directory $dir\n" );
|
||||
//wfDebug( "Creating upload directory $dir\n" );
|
||||
if ( file_exists( $dir ) ) {
|
||||
wfDebug( "Already exists!\n" );
|
||||
return $dir;
|
||||
}
|
||||
wfMkdirParents( $dir . '/3/3a' );
|
||||
copy( "$IP/skins/monobook/headbg.jpg", "$dir/3/3a/Foobar.jpg" );
|
||||
|
||||
wfMkdirParents( $dir . '/0/09' );
|
||||
copy( "$IP/skins/monobook/headbg.jpg", "$dir/0/09/Bad.jpg" );
|
||||
return $dir;
|
||||
|
|
@ -848,10 +834,6 @@ class ParserTest {
|
|||
foreach ( $this->savedGlobals as $var => $val ) {
|
||||
$GLOBALS[$var] = $val;
|
||||
}
|
||||
if ( isset( $this->uploadDir ) ) {
|
||||
$this->teardownUploadDir( $this->uploadDir );
|
||||
unset( $this->uploadDir );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1045,7 +1027,6 @@ class ParserTest {
|
|||
* @param $line Integer: the input line number, for reporting errors
|
||||
*/
|
||||
public function addArticle( $name, $text, $line ) {
|
||||
$this->setupGlobals();
|
||||
$title = Title::newFromText( $name );
|
||||
if ( is_null( $title ) ) {
|
||||
wfDie( "invalid title at line $line\n" );
|
||||
|
|
@ -1058,8 +1039,6 @@ class ParserTest {
|
|||
|
||||
$art = new Article( $title );
|
||||
$art->insertNewArticle( $text, '', false, false );
|
||||
|
||||
$this->teardownGlobals();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1728,8 +1707,9 @@ class TestFileIterator implements Iterator {
|
|||
$section = null;
|
||||
continue;
|
||||
}
|
||||
global $wgUseTeX;
|
||||
if ( $this->parser &&
|
||||
preg_match( '/\\bmath\\b/i', $data['options'] ) && !$this->parser->savedGlobals['wgUseTeX'] ) {
|
||||
preg_match( '/\\bmath\\b/i', $data['options'] ) && !$wgUseTeX ) {
|
||||
# don't run math tests if $wgUseTeX is set to false in LocalSettings
|
||||
$data = array();
|
||||
$section = null;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ class MediaWikiParserTestSuite extends PHPUnit_Framework_TestSuite {
|
|||
public function run( PHPUnit_Framework_TestResult $result = null, $filter = false,
|
||||
array $groups = array(), array $excludeGroups = array(), $processIsolation = false
|
||||
) {
|
||||
global $IP;
|
||||
global $IP, $wgContLang;
|
||||
$wgContLang = Language::factory( 'en' );
|
||||
$this->backend->setupDatabase();
|
||||
|
||||
$iter = new TestFileIterator( "$IP/maintenance/parserTests.txt" );
|
||||
|
|
|
|||
Loading…
Reference in a new issue