+ $this->makeChunk( "123" );
+
+ $gotException = false;
+ try {
+ $data = $this->doApiRequest( $params, $data );
+ } catch ( UsageException $e ) {
+ $this->assertEquals( "This type of file is banned",
+ $e->getMessage() );
+ $gotException = true;
+ }
+ $this->cleanChunk();
+ $this->assertTrue( $gotException );
+ }
+
+ /**
+ * @depends testLogin
+ */
+ function testUploadChunkDoneDuplicate( $data ) {
+ global $wgUser, $wgVerifyMimeType;
+
+ $wgVerifyMimeType = false;
+ $wgUser = User::newFromName( self::$userName );
+ $data[2]['wsEditToken'] = $data[2]['wsToken'];
+ $token = md5( $data[2]['wsToken'] ) . EDIT_TOKEN_SUFFIX;
+ $data = $this->doApiRequest( array(
+ 'filename' => 'tmp.png',
+ 'action' => 'upload',
+ 'enablechunks' => true,
+ 'token' => $token ), $data );
+
+ $url = $data[0]['uploadUrl'];
+ $params = wfCgiToArray( substr( $url, strpos( $url, "?" ) ) );
+ $size = 0;
+ for ( $i = 0; $i < 4; $i++ ) {
+ $this->makeChunk( "123" );
+ $size += $_FILES['chunk']['size'];
+
+ $data = $this->doApiRequest( $params, $data );
+ $this->assertArrayHasKey( "result", $data[0] );
+ $this->assertTrue( (bool)$data[0]["result"] );
+
+ $this->assertArrayHasKey( "filesize", $data[0] );
+ $this->assertEquals( $size, $data[0]['filesize'] );