summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/upload/UploadBaseTest.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-06-04 07:31:04 +0200
committerPierre Schmitz <pierre@archlinux.de>2015-06-04 07:58:39 +0200
commitf6d65e533c62f6deb21342d4901ece24497b433e (patch)
treef28adf0362d14bcd448f7b65a7aaf38650f923aa /tests/phpunit/includes/upload/UploadBaseTest.php
parentc27b2e832fe25651ef2410fae85b41072aae7519 (diff)
Update to MediaWiki 1.25.1
Diffstat (limited to 'tests/phpunit/includes/upload/UploadBaseTest.php')
-rw-r--r--tests/phpunit/includes/upload/UploadBaseTest.php41
1 files changed, 18 insertions, 23 deletions
diff --git a/tests/phpunit/includes/upload/UploadBaseTest.php b/tests/phpunit/includes/upload/UploadBaseTest.php
index 3d3b0068..9441b77f 100644
--- a/tests/phpunit/includes/upload/UploadBaseTest.php
+++ b/tests/phpunit/includes/upload/UploadBaseTest.php
@@ -9,21 +9,17 @@ class UploadBaseTest extends MediaWikiTestCase {
protected $upload;
protected function setUp() {
- global $wgHooks;
parent::setUp();
$this->upload = new UploadTestHandler;
- $this->hooks = $wgHooks;
- $wgHooks['InterwikiLoadPrefix'][] = function ( $prefix, &$data ) {
- return false;
- };
- }
-
- protected function tearDown() {
- global $wgHooks;
- $wgHooks = $this->hooks;
- parent::tearDown();
+ $this->setMwGlobals( 'wgHooks', array(
+ 'InterwikiLoadPrefix' => array(
+ function ( $prefix, &$data ) {
+ return false;
+ }
+ ),
+ ) );
}
/**
@@ -97,7 +93,7 @@ class UploadBaseTest extends MediaWikiTestCase {
// Helper used to create an empty file of size $size.
private function createFileOfSize( $size ) {
- $filename = tempnam( wfTempDir(), "mwuploadtest" );
+ $filename = $this->getNewTempFile();
$fh = fopen( $filename, 'w' );
ftruncate( $fh, $size );
@@ -112,22 +108,21 @@ class UploadBaseTest extends MediaWikiTestCase {
* This method should be abstracted so we can test different settings.
*/
public function testMaxUploadSize() {
- global $wgMaxUploadSize;
- $savedGlobal = $wgMaxUploadSize; // save global
- global $wgFileExtensions;
- $wgFileExtensions[] = 'txt';
-
- $wgMaxUploadSize = 100;
+ $this->setMwGlobals( array(
+ 'wgMaxUploadSize' => 100,
+ 'wgFileExtensions' => array(
+ 'txt',
+ ),
+ ) );
- $filename = $this->createFileOfSize( $wgMaxUploadSize );
+ $filename = $this->createFileOfSize( 100 );
$this->upload->initializePathInfo( basename( $filename ) . '.txt', $filename, 100 );
$result = $this->upload->verifyUpload();
- unlink( $filename );
$this->assertEquals(
- array( 'status' => UploadBase::OK ), $result );
-
- $wgMaxUploadSize = $savedGlobal; // restore global
+ array( 'status' => UploadBase::OK ),
+ $result
+ );
}