Merge "Revert "Log the reason why revision->getContent() returns null""
[lhc/web/wiklou.git] / tests / phpunit / suites / UploadFromUrlTestSuite.php
index 80893da..6fb428b 100644 (file)
@@ -3,7 +3,7 @@
 require_once dirname( __DIR__ ) . '/includes/upload/UploadFromUrlTest.php';
 
 class UploadFromUrlTestSuite extends PHPUnit_Framework_TestSuite {
-       public $savedGlobals = array();
+       public $savedGlobals = [];
 
        public static function addTables( &$tables ) {
                $tables[] = 'user_properties';
@@ -22,30 +22,30 @@ class UploadFromUrlTestSuite extends PHPUnit_Framework_TestSuite {
                        $parserMemc;
 
                $tmpDir = $this->getNewTempDirectory();
-               $tmpGlobals = array();
+               $tmpGlobals = [];
 
                $tmpGlobals['wgScript'] = '/index.php';
                $tmpGlobals['wgScriptPath'] = '/';
                $tmpGlobals['wgArticlePath'] = '/wiki/$1';
                $tmpGlobals['wgStylePath'] = '/skins';
                $tmpGlobals['wgThumbnailScriptPath'] = false;
-               $tmpGlobals['wgLocalFileRepo'] = array(
-                       'class' => 'LocalRepo',
+               $tmpGlobals['wgLocalFileRepo'] = [
+                       'class' => LocalRepo::class,
                        'name' => 'local',
                        'url' => 'http://example.com/images',
                        'hashLevels' => 2,
                        'transformVia404' => false,
-                       'backend' => new FSFileBackend( array(
+                       'backend' => new FSFileBackend( [
                                'name' => 'local-backend',
-                               'wikiId' => wfWikiId(),
-                               'containerPaths' => array(
+                               'wikiId' => wfWikiID(),
+                               'containerPaths' => [
                                        'local-public' => "{$tmpDir}/test-repo/public",
                                        'local-thumb' => "{$tmpDir}/test-repo/thumb",
                                        'local-temp' => "{$tmpDir}/test-repo/temp",
                                        'local-deleted' => "{$tmpDir}/test-repo/delete",
-                               )
-                       ) ),
-               );
+                               ]
+                       ] ),
+               ];
                foreach ( $tmpGlobals as $var => $val ) {
                        if ( array_key_exists( $var, $GLOBALS ) ) {
                                $this->savedGlobals[$var] = $GLOBALS[$var];
@@ -61,13 +61,13 @@ class UploadFromUrlTestSuite extends PHPUnit_Framework_TestSuite {
                DeferredUpdates::clearPendingUpdates();
                $wgMemc = wfGetMainCache();
                $messageMemc = wfGetMessageCacheStorage();
-               $parserMemc = wfGetParserCacheStorage();
 
+               RequestContext::resetMain();
+               $context = RequestContext::getMain();
                $wgUser = new User;
-               $context = new RequestContext;
                $wgLang = $context->getLanguage();
                $wgOut = $context->getOutput();
-               $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) );
+               $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], [ $wgParserConf ] );
                $wgRequest = $context->getRequest();
 
                if ( $wgStyleDirectory === false ) {
@@ -86,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.
         *
@@ -170,15 +124,7 @@ 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 = $this->getNewTempDirectory();
-               }
+               $dir = $this->getNewTempDirectory();
 
                wfDebug( "Creating upload directory $dir\n" );