From 67aebdd165219e837ea779ddb7abf19f2d075a63 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Thu, 8 Dec 2011 14:03:04 +0000 Subject: [PATCH] clean some files when testing upload This catch temporary uploaded files which are six characters long. Follow-up r102458 --- tests/phpunit/includes/api/ApiTestCaseUpload.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/phpunit/includes/api/ApiTestCaseUpload.php b/tests/phpunit/includes/api/ApiTestCaseUpload.php index e51e72140a..3d57946072 100644 --- a/tests/phpunit/includes/api/ApiTestCaseUpload.php +++ b/tests/phpunit/includes/api/ApiTestCaseUpload.php @@ -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 */ -- 2.20.1