Remove redundant test teardown in UploadFromUrlTestSuite
[lhc/web/wiklou.git] / tests / phpunit / suites / UploadFromUrlTestSuite.php
index d4a7bd3..5e70455 100644 (file)
@@ -18,9 +18,10 @@ class UploadFromUrlTestSuite extends PHPUnit_Framework_TestSuite {
        protected function setUp() {
                global $wgParser, $wgParserConf, $IP, $messageMemc, $wgMemc, $wgUser,
                        $wgLang, $wgOut, $wgRequest, $wgStyleDirectory,
-                       $wgEnableParserCache, $wgNamespaceAliases, $wgNamespaceProtection,
+                       $wgParserCacheType, $wgNamespaceAliases, $wgNamespaceProtection,
                        $parserMemc;
 
+               $tmpDir = $this->getNewTempDirectory();
                $tmpGlobals = array();
 
                $tmpGlobals['wgScript'] = '/index.php';
@@ -38,10 +39,10 @@ class UploadFromUrlTestSuite extends PHPUnit_Framework_TestSuite {
                                'name' => 'local-backend',
                                'wikiId' => wfWikiId(),
                                'containerPaths' => array(
-                                       'local-public' => wfTempDir() . '/test-repo/public',
-                                       'local-thumb' => wfTempDir() . '/test-repo/thumb',
-                                       'local-temp' => wfTempDir() . '/test-repo/temp',
-                                       'local-deleted' => wfTempDir() . '/test-repo/delete',
+                                       'local-public' => "{$tmpDir}/test-repo/public",
+                                       'local-thumb' => "{$tmpDir}/test-repo/thumb",
+                                       'local-temp' => "{$tmpDir}/test-repo/temp",
+                                       'local-deleted' => "{$tmpDir}/test-repo/delete",
                                )
                        ) ),
                );
@@ -56,7 +57,7 @@ class UploadFromUrlTestSuite extends PHPUnit_Framework_TestSuite {
                $wgNamespaceAliases['Image'] = NS_FILE;
                $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
 
-               $wgEnableParserCache = false;
+               $wgParserCacheType = CACHE_NONE;
                DeferredUpdates::clearPendingUpdates();
                $wgMemc = wfGetMainCache();
                $messageMemc = wfGetMessageCacheStorage();
@@ -85,55 +86,9 @@ class UploadFromUrlTestSuite extends PHPUnit_Framework_TestSuite {
                RepoGroup::destroySingleton();
                FileBackendGroup::destroySingleton();
 
-               $this->teardownUploadDir( $this->uploadDir );
-
                parent::tearDown();
        }
 
-       private $uploadDir;
-       private $keepUploads;
-
-       /**
-        * Remove the dummy uploads directory
-        * @param string $dir
-        */
-       private function teardownUploadDir( $dir ) {
-               if ( $this->keepUploads ) {
-                       return;
-               }
-
-               // delete the files first, then the dirs.
-               self::deleteFiles(
-                       array(
-                               "$dir/3/3a/Foobar.jpg",
-                               "$dir/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg",
-                               "$dir/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg",
-                               "$dir/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg",
-                               "$dir/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg",
-
-                               "$dir/0/09/Bad.jpg",
-                       )
-               );
-
-               self::deleteDirs(
-                       array(
-                               "$dir/3/3a",
-                               "$dir/3",
-                               "$dir/thumb/6/65",
-                               "$dir/thumb/6",
-                               "$dir/thumb/3/3a/Foobar.jpg",
-                               "$dir/thumb/3/3a",
-                               "$dir/thumb/3",
-
-                               "$dir/0/09/",
-                               "$dir/0/",
-
-                               "$dir/thumb",
-                               "$dir",
-                       )
-               );
-       }
-
        /**
         * Delete the specified files, if they exist.
         *
@@ -169,24 +124,10 @@ class UploadFromUrlTestSuite extends PHPUnit_Framework_TestSuite {
        private function setupUploadDir() {
                global $IP;
 
-               if ( $this->keepUploads ) {
-                       $dir = wfTempDir() . '/mwParser-images';
-
-                       if ( is_dir( $dir ) ) {
-                               return $dir;
-                       }
-               } else {
-                       $dir = wfTempDir() . "/mwParser-" . mt_rand() . "-images";
-               }
+               $dir = $this->getNewTempDirectory();
 
                wfDebug( "Creating upload directory $dir\n" );
 
-               if ( file_exists( $dir ) ) {
-                       wfDebug( "Already exists!\n" );
-
-                       return $dir;
-               }
-
                wfMkdirParents( $dir . '/3/3a', null, __METHOD__ );
                copy( "$IP/tests/phpunit/data/upload/headbg.jpg", "$dir/3/3a/Foobar.jpg" );