X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fsuites%2FUploadFromUrlTestSuite.php;h=556c75412a4b8c56e45c5b411758a2d3b1d6cd4e;hb=767042c3e68adb29513;hp=5e704554f328fc6996fdc08a8670d4a52590cba6;hpb=1d4be85a7f74b276765ce03344be00fc054eaca6;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/suites/UploadFromUrlTestSuite.php b/tests/phpunit/suites/UploadFromUrlTestSuite.php index 5e704554f3..556c75412a 100644 --- a/tests/phpunit/suites/UploadFromUrlTestSuite.php +++ b/tests/phpunit/suites/UploadFromUrlTestSuite.php @@ -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'; @@ -18,34 +18,33 @@ class UploadFromUrlTestSuite extends PHPUnit_Framework_TestSuite { protected function setUp() { global $wgParser, $wgParserConf, $IP, $messageMemc, $wgMemc, $wgUser, $wgLang, $wgOut, $wgRequest, $wgStyleDirectory, - $wgParserCacheType, $wgNamespaceAliases, $wgNamespaceProtection, - $parserMemc; + $wgParserCacheType, $wgNamespaceAliases, $wgNamespaceProtection; $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 +60,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 ) { @@ -89,54 +88,6 @@ class UploadFromUrlTestSuite extends PHPUnit_Framework_TestSuite { parent::tearDown(); } - /** - * Delete the specified files, if they exist. - * - * @param array $files Full paths to files to delete. - */ - private static function deleteFiles( $files ) { - foreach ( $files as $file ) { - if ( file_exists( $file ) ) { - unlink( $file ); - } - } - } - - /** - * Delete the specified directories, if they exist. Must be empty. - * - * @param array $dirs Full paths to directories to delete. - */ - private static function deleteDirs( $dirs ) { - foreach ( $dirs as $dir ) { - if ( is_dir( $dir ) ) { - rmdir( $dir ); - } - } - } - - /** - * Create a dummy uploads directory which will contain a couple - * of files in order to pass existence tests. - * - * @return string The directory - */ - private function setupUploadDir() { - global $IP; - - $dir = $this->getNewTempDirectory(); - - wfDebug( "Creating upload directory $dir\n" ); - - wfMkdirParents( $dir . '/3/3a', null, __METHOD__ ); - copy( "$IP/tests/phpunit/data/upload/headbg.jpg", "$dir/3/3a/Foobar.jpg" ); - - wfMkdirParents( $dir . '/0/09', null, __METHOD__ ); - copy( "$IP/tests/phpunit/data/upload/headbg.jpg", "$dir/0/09/Bad.jpg" ); - - return $dir; - } - public static function suite() { // Hack to invoke the autoloader required to get phpunit to recognize // the UploadFromUrlTest class