Merged FileBackend branch. Manually avoiding merging the many prop-only changes SVN...
[lhc/web/wiklou.git] / tests / phpunit / includes / api / ApiTestCaseUpload.php
index 4824d7e..a155a8c 100644 (file)
@@ -19,14 +19,10 @@ abstract class ApiTestCaseUpload extends ApiTestCase {
                $this->clearFakeUploads();
        }
 
-       /**
-        * Fixture -- run after every test
-        * Clean up temporary files etc.
-        */
-       function tearDown() {
+       public function tearDown() {
+               $this->clearTempUpload();
        }
 
-
        /**
         * Helper function -- remove files and associated articles by Title
         * @param $title Title: title to be removed
@@ -64,7 +60,7 @@ abstract class ApiTestCaseUpload extends ApiTestCase {
         * @param $filePath String: path to file on the filesystem
         */
        public function deleteFileByContent( $filePath ) {
-               $hash = File::sha1Base36( $filePath );
+               $hash = FSFile::getSha1Base36FromPath( $filePath );
                $dupes = RepoGroup::singleton()->findBySha1( $hash );
                $success = true;
                foreach ( $dupes as $dupe ) {
@@ -109,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
         */