* cleanSig() should do nothing if disabled
*/
function testCleanSigDisabled() {
- global $wgCleanSignatures;
- $wgCleanSignatures = false;
+ $this->setMwGlobals( 'wgCleanSignatures', false );
$title = Title::newFromText( __FUNCTION__ );
$outputText = $this->parser->cleanSig( "{{Foo}} ~~~~" );
/** @dataProvider provideExpandableUrls */
public function testWfExpandUrl( $fullUrl, $shortUrl, $defaultProto, $server, $canServer, $httpsMode, $message ) {
// Fake $wgServer and $wgCanonicalServer
- global $wgServer, $wgCanonicalServer;
- $oldServer = $wgServer;
- $oldCanServer = $wgCanonicalServer;
- $wgServer = $server;
- $wgCanonicalServer = $canServer;
+ $this->setMwGlobals( array(
+ 'wgServer' => $server,
+ 'wgCanonicalServer' => $canServer,
+ ) );
// Fake $_SERVER['HTTPS'] if needed
if ( $httpsMode ) {
}
$this->assertEquals( $fullUrl, wfExpandUrl( $shortUrl, $defaultProto ), $message );
-
- // Restore $wgServer and $wgCanonicalServer
- $wgServer = $oldServer;
- $wgCanonicalServer = $oldCanServer;
}
/**
}
public function testElementBasics() {
- global $wgWellFormedXml;
-
$this->assertEquals(
'<img>',
Html::element( 'img', null, '' ),
'Close tag for empty element (array, string)'
);
- $wgWellFormedXml = true;
+ $this->setMwGlobals( 'wgWellFormedXml', true );
$this->assertEquals(
'<img />',
}
public function testExpandAttributesForBooleans() {
- global $wgHtml5, $wgWellFormedXml;
-
$this->assertEquals(
'',
Html::expandAttributes( array( 'selected' => false ) ),
'Boolean attributes have no value when value is true (passed as numerical array)'
);
- $wgWellFormedXml = true;
+ $this->setMwGlobals( 'wgWellFormedXml', true );
$this->assertEquals(
' selected=""',
'Boolean attributes have empty string value when value is true (wgWellFormedXml)'
);
- $wgHtml5 = false;
+ $this->setMwGlobals( 'wgHtml5', false );
$this->assertEquals(
' selected="selected"',
* Please note it output a string prefixed with a space!
*/
public function testExpandAttributesVariousExpansions() {
- global $wgWellFormedXml;
-
### NOT EMPTY ####
$this->assertEquals(
' empty_string=""',
'Number 0 value needs no quotes'
);
- $wgWellFormedXml = true;
+ $this->setMwGlobals( 'wgWellFormedXml', true );
$this->assertEquals(
' empty_string=""',
* ^--- important, causes temporary tables to be used instead of the real database
*/
class RevisionTest_ContentHandlerUseDB extends RevisionStorageTest {
- var $saveContentHandlerNoDB = null;
function setUp() {
- global $wgContentHandlerUseDB;
-
- $this->saveContentHandlerNoDB = $wgContentHandlerUseDB;
-
- $wgContentHandlerUseDB = false;
+ $this->setMwGlobals( 'wgContentHandlerUseDB', false );
$dbw = wfGetDB( DB_MASTER );
parent::setUp();
}
- function tearDown() {
- global $wgContentHandlerUseDB;
-
- parent::tearDown();
-
- $wgContentHandlerUseDB = $this->saveContentHandlerNoDB;
- }
-
/**
* @covers Revision::selectFields
*/
function testCompressRevisionTextUtf8Gzip() {
$this->checkPHPExtension( 'zlib' );
-
- global $wgCompressRevisions;
- $wgCompressRevisions = true;
+ $this->setMwGlobals( 'wgCompressRevisions', true );
$row = new stdClass;
$row->old_text = "Wiki est l'\xc3\xa9cole superieur !";
$seleniumSettings = array();
$seleniumBrowsers = array();
$seleniumTestSuites = array();
- global $wgSeleniumConfigFile;
- $wgSeleniumConfigFile = '';
+ $this->setMwGlobals( 'wgSeleniumConfigFile', '' );
+
SeleniumConfig::getSeleniumSettings( $seleniumSettings,
$seleniumBrowsers,
$seleniumTestSuites );
$seleniumSettings = array();
$seleniumBrowsers = array();
$seleniumTestSuites = array();
- global $wgSeleniumConfigFile;
$this->writeToTempFile( $this->testConfig0 );
- $wgSeleniumConfigFile = $this->tempFileName;
+ $this->setMwGlobals( 'wgSeleniumConfigFile', $this->tempFileName );
+
SeleniumConfig::getSeleniumSettings( $seleniumSettings,
$seleniumBrowsers,
$seleniumTestSuites );
* @dataProvider provideGetIP
*/
function testGetIP( $expected, $input, $squid, $private, $description ) {
- global $wgSquidServersNoPurge, $wgUsePrivateIPs;
$_SERVER = $input;
- $wgSquidServersNoPurge = $squid;
- $wgUsePrivateIPs = $private;
+ $this->setMwGlobals( array(
+ 'wgSquidServersNoPurge' => $squid,
+ 'wgUsePrivateIPs' => $private,
+ ) );
+
$request = new WebRequest();
$result = $request->getIP();
$this->assertEquals( $expected, $result, $description );
* ^--- important, causes temporary tables to be used instead of the real database
*/
class WikiPageTest_ContentHandlerUseDB extends WikiPageTest {
- var $saveContentHandlerNoDB = null;
function setUp() {
- global $wgContentHandlerUseDB;
-
parent::setUp();
-
- $this->saveContentHandlerNoDB = $wgContentHandlerUseDB;
-
- $wgContentHandlerUseDB = false;
+ $this->setMwGlobals( 'wgContentHandlerUseDB', false );
$dbw = wfGetDB( DB_MASTER );
}
}
- function tearDown() {
- global $wgContentHandlerUseDB;
-
- $wgContentHandlerUseDB = $this->saveContentHandlerNoDB;
-
- parent::tearDown();
- }
-
public function testGetContentModel() {
$page = $this->createPage( "WikiPageTest_testGetContentModel", "some text", CONTENT_MODEL_JAVASCRIPT );
* @group Database
*/
public function testIsCountable( $text, $hasLinks, $mode, $expected ) {
- global $wgArticleCountMethod;
-
- $old = $wgArticleCountMethod;
- $wgArticleCountMethod = $mode;
+ $this->setMwGlobals( 'wgArticleCountMethod', $mode );
$content = $this->newContent( $text );
$v = $content->isCountable( $hasLinks, $this->context->getTitle() );
- $wgArticleCountMethod = $old;
$this->assertEquals( $expected, $v, 'isCountable() returned unexpected value ' . var_export( $v, true )
. ' instead of ' . var_export( $expected, true ) . " in mode `$mode` for text \"$text\"" );
class JobQueueTest extends MediaWikiTestCase {
protected $key;
protected $queueRand, $queueRandTTL, $queueFifo, $queueFifoTTL;
- protected $old = array();
function __construct( $name = null, array $data = array(), $dataName = '' ) {
parent::__construct( $name, $data, $dataName );
}
protected function setUp() {
- global $wgMemc, $wgJobTypeConf;
+ global $wgJobTypeConf;
parent::setUp();
- $this->old['wgMemc'] = $wgMemc;
- $wgMemc = new HashBagOStuff();
+
+ $this->setMwGlobals( 'wgMemc', new HashBagOStuff() );
+
if ( $this->getCliArg( 'use-jobqueue=' ) ) {
$name = $this->getCliArg( 'use-jobqueue=' );
if ( !isset( $wgJobTypeConf[$name] ) ) {
}
protected function tearDown() {
- global $wgMemc;
parent::tearDown();
foreach ( array(
'queueRand', 'queueRandTTL', 'queueTimestamp', 'queueTimestampTTL',
}
$this->$q = null;
}
- $wgMemc = $this->old['wgMemc'];
}
/**
* translation (to en) where XMP should win.
*/
public function testMultilingualCascade() {
- global $wgShowEXIF;
-
if ( !wfDl( 'exif' ) ) {
$this->markTestSkipped( "This test needs the exif extension." );
}
$this->markTestSkipped( "This test needs the xml extension." );
}
- $wgShowEXIF = true;
+ $this->setMwGlobals( 'wgShowEXIF', true );
$meta = BitmapMetadataHandler::Jpeg( $this->filePath .
'/Xmp-exif-multilingual_test.jpg' );
if ( !wfDl( 'exif' ) ) {
$this->markTestSkipped( "This test needs the exif extension." );
}
- global $wgShowEXIF;
- $this->show = $wgShowEXIF;
- $wgShowEXIF = true;
- global $wgEnableAutoRotation;
- $this->oldAuto = $wgEnableAutoRotation;
- $wgEnableAutoRotation = true;
- }
-
- protected function tearDown() {
- global $wgShowEXIF, $wgEnableAutoRotation;
- $wgShowEXIF = $this->show;
- $wgEnableAutoRotation = $this->oldAuto;
-
- parent::tearDown();
+ $this->setMwGlobals( array(
+ 'wgShowEXIF' => true,
+ 'wgEnableAutoRotation' => true,
+ ) );
}
/**
* @dataProvider provideFilesNoAutoRotate
*/
function testMetadataNoAutoRotate( $name, $type, $info ) {
- global $wgEnableAutoRotation;
- $wgEnableAutoRotation = false;
+ $this->setMwGlobals( 'wgEnableAutoRotation', false );
$file = $this->dataFile( $name, $type );
$this->assertEquals( $info['width'], $file->getWidth(), "$name: width check" );
$this->assertEquals( $info['height'], $file->getHeight(), "$name: height check" );
-
- $wgEnableAutoRotation = true;
}
/**
* @dataProvider provideFilesNoAutoRotate
*/
function testRotationRenderingNoAutoRotate( $name, $type, $info, $thumbs ) {
- global $wgEnableAutoRotation;
- $wgEnableAutoRotation = false;
+ $this->setMwGlobals( 'wgEnableAutoRotation', false );
foreach ( $thumbs as $size => $out ) {
if ( preg_match( '/^(\d+)px$/', $size, $matches ) ) {
$this->assertEquals( $out[1], $gis[1], "$name: thumb actual height check for $size" );
}
}
- $wgEnableAutoRotation = true;
}
public static function provideFilesNoAutoRotate() {
class UploadFromUrlTest extends ApiTestCase {
protected function setUp() {
- global $wgEnableUploads, $wgAllowCopyUploads, $wgAllowAsyncCopyUploads;
parent::setUp();
- $wgEnableUploads = true;
- $wgAllowCopyUploads = true;
- $wgAllowAsyncCopyUploads = true;
+ $this->setMwGlobals( array(
+ 'wgEnableUploads' => true,
+ 'wgAllowCopyUploads' => true,
+ 'wgAllowAsyncCopyUploads' => true,
+ ) );
wfSetupSession();
if ( wfLocalFile( 'UploadFromUrlTest.png' )->exists() ) {
}
public function testBug29408() {
- global $wgUser;
- $wgUser = self::$users['uploader']->user;
+ $this->setMwGlobals( 'wgUser', self::$users['uploader']->user );
$repo = RepoGroup::singleton()->getLocalRepo();
$stash = new UploadStash( $repo );
* Clears $wgUser, and reports errors from addDBData to PHPUnit
*/
protected function setUp() {
- global $wgUser;
-
parent::setUp();
// Check if any Exception is stored for rethrowing from addDBData
throw $this->exceptionFromAddDBData;
}
- $wgUser = new User();
+ $this->setMwGlobals( 'wgUser', new User() );
}
/**