follow-up r61355
authorMark A. Hershberger <mah@users.mediawiki.org>
Thu, 11 Feb 2010 05:35:21 +0000 (05:35 +0000)
committerMark A. Hershberger <mah@users.mediawiki.org>
Thu, 11 Feb 2010 05:35:21 +0000 (05:35 +0000)
Actually test UploadChunks code against Firefogg.  Uploads work, but
feedback on the Firefogg side seems not too.  Also, Firefogg makes a
complete upload, but then attempts more uploads.

includes/api/ApiUpload.php
maintenance/tests/ApiSetup.php
maintenance/tests/ApiTest.php
maintenance/tests/UploadFromChunksTest.php

index de50147..e99e5d9 100644 (file)
@@ -138,7 +138,15 @@ class ApiUpload extends ApiBase {
 
                // Cleanup any temporary mess
                $this->mUpload->cleanupTempFile();
-               $this->getResult()->addValue( null, $this->getModuleName(), $result );
+
+               if( $this->mParams['enablechunks'] ) {
+                       foreach ($result as $key => $value) {
+                               if($value === null) $value = "";
+                               $this->getResult()->addValue( null, $key, $value );
+                       }
+               } else {
+                       $this->getResult()->addValue( null, $this->getModuleName(), $result );
+               }
        }
 
        protected function performUpload() {
index d5fbac7..549d8ae 100644 (file)
@@ -10,10 +10,6 @@ abstract class ApiSetup extends PHPUnit_Framework_TestCase {
                global $wgServerName, $wgServer, $wgContLang, $wgAuth, $wgScriptPath,
                        $wgScriptExtension, $wgMemc, $wgRequest;
 
-               if($wgServerName == "localhost" || $wgServer == "http://localhost") {
-                       $this->markTestIncomplete('This test needs $wgServerName and $wgServer to '.
-                                                                         'be set in LocalSettings.php');
-               }
                self::$apiUrl = $wgServer.$wgScriptPath."/api".$wgScriptExtension;
 
                $wgMemc = new FakeMemCachedClient;
index 04f9c5b..b177ebf 100644 (file)
@@ -5,6 +5,10 @@ require_once( "ApiSetup.php" );
 class ApiTest extends ApiSetup {
 
        function setup() {
+               if($wgServerName == "localhost" || $wgServer == "http://localhost") {
+                       $this->markTestIncomplete('This test needs $wgServerName and $wgServer to '.
+                                                                         'be set in LocalSettings.php');
+               }
                parent::setup();
        }
 
index ebad774..b0decd6 100644 (file)
@@ -115,8 +115,7 @@ class UploadFromChunksTest extends ApiSetup {
                                  'token' => $token,
                        ));
 
-               $this->assertArrayHasKey("upload", $data);
-               $this->assertArrayHasKey("uploadUrl", $data['upload']);
+               $this->assertArrayHasKey("uploadUrl", $data);
 
                return array('data' => $data, 'session' => $_SESSION, 'token' => $token);
        }
@@ -131,7 +130,7 @@ class UploadFromChunksTest extends ApiSetup {
                $wgUser = User::newFromName(self::$userName);
                $token = $wgUser->editToken();
 
-               $url = $data['upload']['uploadUrl'];
+               $url = $data['uploadUrl'];
                $params = wfCgiToArray(substr($url, strpos($url, "?")));
 
                for($i=0;$i<10;$i++) {