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