upload: Simplify UploadStashTest by using getNewTempFile()
authorTimo Tijhof <krinklemail@gmail.com>
Tue, 7 Nov 2017 06:45:34 +0000 (22:45 -0800)
committerTimo Tijhof <krinklemail@gmail.com>
Tue, 7 Nov 2017 06:45:34 +0000 (22:45 -0800)
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

tests/phpunit/includes/upload/UploadStashTest.php

index d754ba5..f46ad20 100644 (file)
@@ -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
         */