From: Timo Tijhof Date: Tue, 7 Nov 2017 06:45:34 +0000 (-0800) Subject: upload: Simplify UploadStashTest by using getNewTempFile() X-Git-Tag: 1.31.0-rc.0~1581^2 X-Git-Url: https://git.cyclocoop.org/%27.%24link.%27?a=commitdiff_plain;h=a4eb5c9a8a3913b13ae2735d44aec5adb9d5731b;p=lhc%2Fweb%2Fwiklou.git upload: Simplify UploadStashTest by using getNewTempFile() The parent class has a built-in list that tracks these files and deletes them in a teardown. I was unable to reproduce a case where $path + '.' is created by MediaWiki. As far as I can tell, no current code exists in core that would do this. If it does exist, we can keep the tearDown() override with just that second case, but I'm removing it for now, given it doesn't appear to be used. Change-Id: I5847b7b266f1393d983aeb4b115bc0ae000e3547 --- diff --git a/tests/phpunit/includes/upload/UploadStashTest.php b/tests/phpunit/includes/upload/UploadStashTest.php index d754ba5a22..f46ad20646 100644 --- a/tests/phpunit/includes/upload/UploadStashTest.php +++ b/tests/phpunit/includes/upload/UploadStashTest.php @@ -19,7 +19,7 @@ class UploadStashTest extends MediaWikiTestCase { protected function setUp() { parent::setUp(); - $this->tmpFile = wfTempDir() . '/' . uniqid(); + $this->tmpFile = $this->getNewTempFile(); file_put_contents( $this->tmpFile, "\x00" ); self::$users = [ @@ -38,18 +38,6 @@ class UploadStashTest extends MediaWikiTestCase { ]; } - protected function tearDown() { - if ( file_exists( $this->tmpFile . "." ) ) { - unlink( $this->tmpFile . "." ); - } - - if ( file_exists( $this->tmpFile ) ) { - unlink( $this->tmpFile ); - } - - parent::tearDown(); - } - /** * @todo give this test a real name explaining what is being tested here */