3 require_once dirname( __DIR__
) . '/includes/upload/UploadFromUrlTest.php';
5 class UploadFromUrlTestSuite
extends PHPUnit_Framework_TestSuite
{
6 public $savedGlobals = [];
8 public static function addTables( &$tables ) {
9 $tables[] = 'user_properties';
10 $tables[] = 'filearchive';
11 $tables[] = 'logging';
12 $tables[] = 'updatelog';
13 $tables[] = 'iwlinks';
18 protected function setUp() {
19 global $wgParser, $wgParserConf, $IP, $messageMemc, $wgMemc, $wgUser,
20 $wgLang, $wgOut, $wgRequest, $wgStyleDirectory,
21 $wgParserCacheType, $wgNamespaceAliases, $wgNamespaceProtection;
23 $tmpDir = $this->getNewTempDirectory();
26 $tmpGlobals['wgScript'] = '/index.php';
27 $tmpGlobals['wgScriptPath'] = '/';
28 $tmpGlobals['wgArticlePath'] = '/wiki/$1';
29 $tmpGlobals['wgStylePath'] = '/skins';
30 $tmpGlobals['wgThumbnailScriptPath'] = false;
31 $tmpGlobals['wgLocalFileRepo'] = [
32 'class' => LocalRepo
::class,
34 'url' => 'http://example.com/images',
36 'transformVia404' => false,
37 'backend' => new FSFileBackend( [
38 'name' => 'local-backend',
39 'wikiId' => wfWikiID(),
41 'local-public' => "{$tmpDir}/test-repo/public",
42 'local-thumb' => "{$tmpDir}/test-repo/thumb",
43 'local-temp' => "{$tmpDir}/test-repo/temp",
44 'local-deleted' => "{$tmpDir}/test-repo/delete",
48 foreach ( $tmpGlobals as $var => $val ) {
49 if ( array_key_exists( $var, $GLOBALS ) ) {
50 $this->savedGlobals
[$var] = $GLOBALS[$var];
52 $GLOBALS[$var] = $val;
55 $wgNamespaceProtection[NS_MEDIAWIKI
] = 'editinterface';
56 $wgNamespaceAliases['Image'] = NS_FILE
;
57 $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK
;
59 $wgParserCacheType = CACHE_NONE
;
60 DeferredUpdates
::clearPendingUpdates();
61 $wgMemc = wfGetMainCache();
62 $messageMemc = wfGetMessageCacheStorage();
64 RequestContext
::resetMain();
65 $context = RequestContext
::getMain();
67 $wgLang = $context->getLanguage();
68 $wgOut = $context->getOutput();
69 $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], [ $wgParserConf ] );
70 $wgRequest = $context->getRequest();
72 if ( $wgStyleDirectory === false ) {
73 $wgStyleDirectory = "$IP/skins";
76 RepoGroup
::destroySingleton();
77 FileBackendGroup
::destroySingleton();
80 protected function tearDown() {
81 foreach ( $this->savedGlobals
as $var => $val ) {
82 $GLOBALS[$var] = $val;
85 RepoGroup
::destroySingleton();
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' );