Merge "Remove parameter 'options' from hook 'SkinEditSectionLinks'"
[lhc/web/wiklou.git] / tests / phpunit / suites / UploadFromUrlTestSuite.php
1 <?php
2
3 use MediaWiki\MediaWikiServices;
4
5 require_once dirname( __DIR__ ) . '/includes/upload/UploadFromUrlTest.php';
6
7 class UploadFromUrlTestSuite extends PHPUnit_Framework_TestSuite {
8 public $savedGlobals = [];
9
10 public static function addTables( &$tables ) {
11 $tables[] = 'user_properties';
12 $tables[] = 'filearchive';
13 $tables[] = 'logging';
14 $tables[] = 'updatelog';
15 $tables[] = 'iwlinks';
16
17 return true;
18 }
19
20 protected function setUp() {
21 global $IP, $messageMemc, $wgMemc, $wgUser, $wgLang, $wgOut, $wgRequest, $wgStyleDirectory,
22 $wgParserCacheType, $wgNamespaceAliases, $wgNamespaceProtection;
23
24 $tmpDir = $this->getNewTempDirectory();
25 $tmpGlobals = [];
26
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,
34 'name' => 'local',
35 'url' => 'http://example.com/images',
36 'hashLevels' => 2,
37 'transformVia404' => false,
38 'backend' => new FSFileBackend( [
39 'name' => 'local-backend',
40 'wikiId' => wfWikiID(),
41 'containerPaths' => [
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",
46 ]
47 ] ),
48 ];
49 foreach ( $tmpGlobals as $var => $val ) {
50 if ( array_key_exists( $var, $GLOBALS ) ) {
51 $this->savedGlobals[$var] = $GLOBALS[$var];
52 }
53 $GLOBALS[$var] = $val;
54 }
55
56 $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
57 $wgNamespaceAliases['Image'] = NS_FILE;
58 $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
59
60 $wgParserCacheType = CACHE_NONE;
61 DeferredUpdates::clearPendingUpdates();
62 $wgMemc = ObjectCache::getLocalClusterInstance();
63 $messageMemc = wfGetMessageCacheStorage();
64
65 RequestContext::resetMain();
66 $context = RequestContext::getMain();
67 $wgUser = new User;
68 $wgLang = $context->getLanguage();
69 $wgOut = $context->getOutput();
70 $wgRequest = $context->getRequest();
71
72 if ( $wgStyleDirectory === false ) {
73 $wgStyleDirectory = "$IP/skins";
74 }
75
76 MediaWikiServices::getInstance()->resetServiceForTesting( 'RepoGroup' );
77 FileBackendGroup::destroySingleton();
78 }
79
80 protected function tearDown() {
81 foreach ( $this->savedGlobals as $var => $val ) {
82 $GLOBALS[$var] = $val;
83 }
84 // Restore backends
85 MediaWikiServices::getInstance()->resetServiceForTesting( 'RepoGroup' );
86 FileBackendGroup::destroySingleton();
87
88 parent::tearDown();
89 }
90
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' );
96
97 return $suite;
98 }
99 }