MediaWiki  master
Go to the documentation of this file.
1 <?php
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';
15  return true;
16  }
18  protected function setUp() {
22  $tmpDir = $this->getNewTempDirectory();
23  $tmpGlobals = [];
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' => '',
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  }
54  $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
55  $wgNamespaceAliases['Image'] = NS_FILE;
56  $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
58  $wgParserCacheType = CACHE_NONE;
60  $wgMemc = wfGetMainCache();
61  $messageMemc = wfGetMessageCacheStorage();
65  $wgUser = new User;
66  $wgLang = $context->getLanguage();
67  $wgOut = $context->getOutput();
68  $wgRequest = $context->getRequest();
70  if ( $wgStyleDirectory === false ) {
71  $wgStyleDirectory = "$IP/skins";
72  }
76  }
78  protected function tearDown() {
79  foreach ( $this->savedGlobals as $var => $val ) {
80  $GLOBALS[$var] = $val;
81  }
82  // Restore backends
86  parent::tearDown();
87  }
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' );
95  return $suite;
96  }
97 }
static clearPendingUpdates()
Clear all pending updates without performing them.
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest to get request data $wgMemc
Definition: globals.txt:25
Definition: WebStart.php:41
static destroySingleton()
Destroy the singleton instance, so that a new one will be created next time singleton() is called...
Definition: RepoGroup.php:76
Namespace aliases.
static destroySingleton()
Destroy the singleton instance.
Get the cache object used by the message cache.
this hook is for auditing only RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist & $tables
Definition: hooks.txt:979
The cache type for storing article HTML.
Definition: Setup.php:876
static getMain()
Get the RequestContext object associated with the main request.
static resetMain()
Resets singleton returned by getMain().
Definition: Setup.php:770
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
const NS_FILE
Definition: Defines.php:70
Definition: Defines.php:71
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
Definition: Defines.php:72
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
Set the minimum permissions required to edit pages in each namespace.
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
Get the main cache object.
Filesystem stylesheets directory.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
Definition: hooks.txt:2633
if(! $wgDBerrorLogTZ) $wgRequest
Definition: Setup.php:728
Definition: Setup.php:881
Definition: Defines.php:102
Class for a file system (FS) based file backend.