3 use MediaWiki\MediaWikiServices
;
5 require_once dirname( __DIR__
) . '/includes/upload/UploadFromUrlTest.php';
7 class UploadFromUrlTestSuite
extends PHPUnit_Framework_TestSuite
{
8 public $savedGlobals = [];
10 public static function addTables( &$tables ) {
11 $tables[] = 'user_properties';
12 $tables[] = 'filearchive';
13 $tables[] = 'logging';
14 $tables[] = 'updatelog';
15 $tables[] = 'iwlinks';
20 protected function setUp() {
21 global $IP, $messageMemc, $wgMemc, $wgUser, $wgLang, $wgOut, $wgRequest, $wgStyleDirectory,
22 $wgParserCacheType, $wgNamespaceAliases, $wgNamespaceProtection;
24 $tmpDir = $this->getNewTempDirectory();
27 $tmpGlobals['wgScript'] = '/index.php';
28 $tmpGlobals['wgScriptPath'] = '/';
29 $tmpGlobals['wgArticlePath'] = '/wiki/$1';
30 $tmpGlobals['wgStylePath'] = '/skins';
31 $tmpGlobals['wgThumbnailScriptPath'] = false;
32 $tmpGlobals['wgLocalFileRepo'] = [
33 'class' => LocalRepo
::class,
35 'url' => 'http://example.com/images',
37 'transformVia404' => false,
38 'backend' => new FSFileBackend( [
39 'name' => 'local-backend',
40 'wikiId' => wfWikiID(),
42 'local-public' => "{$tmpDir}/test-repo/public",
43 'local-thumb' => "{$tmpDir}/test-repo/thumb",
44 'local-temp' => "{$tmpDir}/test-repo/temp",
45 'local-deleted' => "{$tmpDir}/test-repo/delete",
49 foreach ( $tmpGlobals as $var => $val ) {
50 if ( array_key_exists( $var, $GLOBALS ) ) {
51 $this->savedGlobals
[$var] = $GLOBALS[$var];
53 $GLOBALS[$var] = $val;
56 $wgNamespaceProtection[NS_MEDIAWIKI
] = 'editinterface';
57 $wgNamespaceAliases['Image'] = NS_FILE
;
58 $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK
;
60 $wgParserCacheType = CACHE_NONE
;
61 DeferredUpdates
::clearPendingUpdates();
62 $wgMemc = ObjectCache
::getLocalClusterInstance();
63 $messageMemc = wfGetMessageCacheStorage();
65 RequestContext
::resetMain();
66 $context = RequestContext
::getMain();
68 $wgLang = $context->getLanguage();
69 $wgOut = $context->getOutput();
70 $wgRequest = $context->getRequest();
72 if ( $wgStyleDirectory === false ) {
73 $wgStyleDirectory = "$IP/skins";
76 MediaWikiServices
::getInstance()->resetServiceForTesting( 'RepoGroup' );
77 FileBackendGroup
::destroySingleton();
80 protected function tearDown() {
81 foreach ( $this->savedGlobals
as $var => $val ) {
82 $GLOBALS[$var] = $val;
85 MediaWikiServices
::getInstance()->resetServiceForTesting( 'RepoGroup' );
86 FileBackendGroup
::destroySingleton();
91 public static function suite() {
92 // Hack to invoke the autoloader required to get phpunit to recognize
93 // the UploadFromUrlTest class
94 class_exists( 'UploadFromUrlTest' );
95 $suite = new UploadFromUrlTestSuite( 'UploadFromUrlTest' );