clean some files when testing upload
authorAntoine Musso <hashar@users.mediawiki.org>
Thu, 8 Dec 2011 14:03:04 +0000 (14:03 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Thu, 8 Dec 2011 14:03:04 +0000 (14:03 +0000)
This catch temporary uploaded files which are six characters long.

Follow-up r102458

tests/phpunit/includes/api/ApiTestCaseUpload.php

index e51e721..3d57946 100644 (file)
@@ -19,6 +19,10 @@ abstract class ApiTestCaseUpload extends ApiTestCase {
                $this->clearFakeUploads();
        }
 
+       public function tearDown() {
+               $this->clearTempUpload();
+       }
+
        /**
         * Helper function -- remove files and associated articles by Title
         * @param $title Title: title to be removed
@@ -101,6 +105,15 @@ abstract class ApiTestCaseUpload extends ApiTestCase {
 
        }
 
+       function clearTempUpload() {
+               if( isset( $_FILES['file']['tmp_name'] ) ) {
+                       $tmp = $_FILES['file']['tmp_name'];
+                       if( file_exists( $tmp ) ) {
+                               unlink( $tmp );
+                       }
+               }
+       }
+
        /**
         * Remove traces of previous fake uploads
         */