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 $IP, $messageMemc, $wgMemc, $wgUser, $wgLang, $wgOut, $wgRequest, $wgStyleDirectory,
20 $wgParserCacheType, $wgNamespaceAliases, $wgNamespaceProtection;
22 $tmpDir = $this->getNewTempDirectory();
25 $tmpGlobals['wgScript'] = '/index.php';
26 $tmpGlobals['wgScriptPath'] = '/';
27 $tmpGlobals['wgArticlePath'] = '/wiki/$1';
28 $tmpGlobals['wgStylePath'] = '/skins';
29 $tmpGlobals['wgThumbnailScriptPath'] = false;
30 $tmpGlobals['wgLocalFileRepo'] = [
31 'class' => LocalRepo
::class,
33 'url' => 'http://example.com/images',
35 'transformVia404' => false,
36 'backend' => new FSFileBackend( [
37 'name' => 'local-backend',
38 'wikiId' => wfWikiID(),
40 'local-public' => "{$tmpDir}/test-repo/public",
41 'local-thumb' => "{$tmpDir}/test-repo/thumb",
42 'local-temp' => "{$tmpDir}/test-repo/temp",
43 'local-deleted' => "{$tmpDir}/test-repo/delete",
47 foreach ( $tmpGlobals as $var => $val ) {
48 if ( array_key_exists( $var, $GLOBALS ) ) {
49 $this->savedGlobals
[$var] = $GLOBALS[$var];
51 $GLOBALS[$var] = $val;
54 $wgNamespaceProtection[NS_MEDIAWIKI
] = 'editinterface';
55 $wgNamespaceAliases['Image'] = NS_FILE
;
56 $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK
;
58 $wgParserCacheType = CACHE_NONE
;
59 DeferredUpdates
::clearPendingUpdates();
60 $wgMemc = ObjectCache
::getLocalClusterInstance();
61 $messageMemc = wfGetMessageCacheStorage();
63 RequestContext
::resetMain();
64 $context = RequestContext
::getMain();
66 $wgLang = $context->getLanguage();
67 $wgOut = $context->getOutput();
68 $wgRequest = $context->getRequest();
70 if ( $wgStyleDirectory === false ) {
71 $wgStyleDirectory = "$IP/skins";
74 RepoGroup
::destroySingleton();
75 FileBackendGroup
::destroySingleton();
78 protected function tearDown() {
79 foreach ( $this->savedGlobals
as $var => $val ) {
80 $GLOBALS[$var] = $val;
83 RepoGroup
::destroySingleton();
84 FileBackendGroup
::destroySingleton();
89 public static function suite() {
90 // Hack to invoke the autoloader required to get phpunit to recognize
91 // the UploadFromUrlTest class
92 class_exists( 'UploadFromUrlTest' );
93 $suite = new UploadFromUrlTestSuite( 'UploadFromUrlTest' );