X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fupload%2FUploadFromUrlTest.php;h=a69a137b72b4f43e2f6b4bfdd9b76f6333b6295c;hb=c1c0d243522d477799bb5ca325a100fa6a86a7fd;hp=fb14c657b8743a10efab85b24f638fc67c984ad4;hpb=f132746d2882a8383cb6288325aae048b2b996e3;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/upload/UploadFromUrlTest.php b/tests/phpunit/includes/upload/UploadFromUrlTest.php index fb14c657b8..a69a137b72 100644 --- a/tests/phpunit/includes/upload/UploadFromUrlTest.php +++ b/tests/phpunit/includes/upload/UploadFromUrlTest.php @@ -11,10 +11,10 @@ class UploadFromUrlTest extends ApiTestCase { protected function setUp() { parent::setUp(); - $this->setMwGlobals( array( + $this->setMwGlobals( [ 'wgEnableUploads' => true, 'wgAllowCopyUploads' => true, - ) ); + ] ); if ( wfLocalFile( 'UploadFromUrlTest.png' )->exists() ) { $this->deleteFile( 'UploadFromUrlTest.png' ); @@ -22,7 +22,7 @@ class UploadFromUrlTest extends ApiTestCase { } protected function doApiRequest( array $params, array $unused = null, - $appendModule = false, User $user = null + $appendModule = false, User $user = null, $tokenType = null ) { global $wgRequest; @@ -30,10 +30,10 @@ class UploadFromUrlTest extends ApiTestCase { $module = new ApiMain( $req, true ); $module->execute(); - return array( - $module->getResult()->getResultData( null, array( 'Strip' => 'all' ) ), + return [ + $module->getResult()->getResultData( null, [ 'Strip' => 'all' ] ), $req - ); + ]; } /** @@ -55,10 +55,10 @@ class UploadFromUrlTest extends ApiTestCase { $exception = false; try { - $this->doApiRequest( array( + $this->doApiRequest( [ 'action' => 'upload', - ) ); - } catch ( UsageException $e ) { + ] ); + } catch ( ApiUsageException $e ) { $exception = true; $this->assertEquals( "The token parameter must be set", $e->getMessage() ); } @@ -66,11 +66,11 @@ class UploadFromUrlTest extends ApiTestCase { $exception = false; try { - $this->doApiRequest( array( + $this->doApiRequest( [ 'action' => 'upload', 'token' => $token, - ), $data ); - } catch ( UsageException $e ) { + ], $data ); + } catch ( ApiUsageException $e ) { $exception = true; $this->assertEquals( "One of the parameters sessionkey, file, url is required", $e->getMessage() ); @@ -79,12 +79,12 @@ class UploadFromUrlTest extends ApiTestCase { $exception = false; try { - $this->doApiRequest( array( + $this->doApiRequest( [ 'action' => 'upload', 'url' => 'http://www.example.com/test.png', 'token' => $token, - ), $data ); - } catch ( UsageException $e ) { + ], $data ); + } catch ( ApiUsageException $e ) { $exception = true; $this->assertEquals( "The filename parameter must be set", $e->getMessage() ); } @@ -93,13 +93,13 @@ class UploadFromUrlTest extends ApiTestCase { $this->user->removeGroup( 'sysop' ); $exception = false; try { - $this->doApiRequest( array( + $this->doApiRequest( [ 'action' => 'upload', 'url' => 'http://www.example.com/test.png', 'filename' => 'UploadFromUrlTest.png', 'token' => $token, - ), $data ); - } catch ( UsageException $e ) { + ], $data ); + } catch ( ApiUsageException $e ) { $exception = true; $this->assertEquals( "Permission denied", $e->getMessage() ); } @@ -116,13 +116,13 @@ class UploadFromUrlTest extends ApiTestCase { $this->assertFalse( $job, 'Starting with an empty jobqueue' ); $this->user->addGroup( 'users' ); - $data = $this->doApiRequest( array( + $data = $this->doApiRequest( [ 'action' => 'upload', 'filename' => 'UploadFromUrlTest.png', 'url' => 'http://upload.wikimedia.org/wikipedia/mediawiki/b/bc/Wiki.png', 'ignorewarnings' => true, 'token' => $token, - ), $data ); + ], $data ); $job = JobQueueGroup::singleton()->pop(); $this->assertFalse( $job ); @@ -138,7 +138,7 @@ class UploadFromUrlTest extends ApiTestCase { $this->assertTrue( $t->exists(), "File '$name' exists" ); if ( $t->exists() ) { - $file = wfFindFile( $name, array( 'ignoreRedirect' => true ) ); + $file = wfFindFile( $name, [ 'ignoreRedirect' => true ] ); $empty = ""; FileDeleteForm::doDelete( $t, $file, $empty, "none", true ); $page = WikiPage::factory( $t );