summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/upload
diff options
context:
space:
mode:
Diffstat (limited to 'tests/phpunit/includes/upload')
-rw-r--r--tests/phpunit/includes/upload/UploadBaseTest.php41
-rw-r--r--tests/phpunit/includes/upload/UploadFromUrlTest.php5
2 files changed, 22 insertions, 24 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
+ );
}
diff --git a/tests/phpunit/includes/upload/UploadFromUrlTest.php b/tests/phpunit/includes/upload/UploadFromUrlTest.php
index ec56b63e..b7496629 100644
--- a/tests/phpunit/includes/upload/UploadFromUrlTest.php
+++ b/tests/phpunit/includes/upload/UploadFromUrlTest.php
@@ -35,7 +35,10 @@ class UploadFromUrlTest extends ApiTestCase {
wfSetupSession( $sessionId );
- return array( $module->getResultData(), $req );
+ return array(
+ $module->getResult()->getResultData( null, array( 'Strip' => 'all' ) ),
+ $req
+ );
}
/**