20 'sysop' => static::getTestSysop(),
21 'uploader' => static::getTestUser(),
25 'wgAuth' =>
new MediaWiki\Auth\AuthManagerAuthPlugin,
27 'wgUser' => self::$users[
'sysop']->getUser(),
35 MediaWiki\Session\SessionManager::getGlobalSession()->clear();
49 $title = Title::newFromText( $pageName, $defaultNs );
72 $appendModule =
false,
User $user =
null
76 if ( is_null( $session ) ) {
89 MediaWiki\Auth\AuthManager::resetCache();
101 $module->getResult()->getResultData(
null, [
'Strip' =>
'all' ] ),
103 $context->getRequest()->getSessionArray()
106 if ( $appendModule ) {
107 $results[] = $module;
130 if ( $session ===
null ) {
134 if ( isset( $session[
'wsToken'] ) && $session[
'wsToken'] ) {
137 $session[
'wsTokenSecrets'][
'default'] = $session[
'wsToken'];
142 MediaWiki\Session\Token::SUFFIX;
146 throw new Exception(
"Session token not available" );
150 protected function doLogin( $testUser =
'sysop' ) {
151 if ( $testUser ===
null ) {
152 $testUser = static::getTestSysop();
153 } elseif ( is_string( $testUser ) && array_key_exists( $testUser, self::$users ) ) {
154 $testUser = self::$users[ $testUser ];
155 } elseif ( !$testUser instanceof
TestUser ) {
156 throw new MWException(
"Can not log in to undefined user $testUser" );
161 'lgname' => $testUser->getUser()->getName(),
162 'lgpassword' => $testUser->getPassword() ] );
164 $token = $data[0][
'login'][
'token'];
170 'lgname' => $testUser->getUser()->getName(),
171 'lgpassword' => $testUser->getPassword(),
176 if ( $data[0][
'login'][
'result'] ===
'Success' ) {
179 $wgUser = $testUser->getUser();
188 'action' =>
'tokens',
189 'type' =>
'edit|delete|protect|move|block|unblock|watch'
190 ], $session,
false,
$user->getUser() );
192 if ( !array_key_exists(
'tokens', $data[0] ) ) {
193 throw new MWException(
'Api failed to return a token list' );
196 return $data[0][
'tokens'];
200 $groups = PHPUnit_Util_Test::getGroups( get_class( $this ) );
201 $constraint = PHPUnit_Framework_Assert::logicalOr(
202 $this->contains(
'medium' ),
203 $this->contains(
'large' )
205 $this->assertThat( $groups, $constraint,
206 'ApiTestCase::setUp can be slow, tests must be "medium" or "large"'
$wgServer
URL of the server.
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
if(! $wgDBerrorLogTZ) $wgRequest
This is the main API class, used for both external and internal processing.
doApiRequestWithToken(array $params, array $session=null, User $user=null)
Add an edit token to the API request This is cheating a bit – we grab a token in the correct format a...
editPage( $pageName, $text, $summary='', $defaultNs=NS_MAIN)
Edits or creates a page/revision.
doLogin( $testUser='sysop')
getTokenList(TestUser $user, $session=null)
doApiRequest(array $params, array $session=null, $appendModule=false, User $user=null)
Does the API request and returns the result.
ApiTestContext $apiContext
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
WebRequest clone which takes values from a provided array.
static getMain()
Static methods.
Wraps the user object, so we can also retain full access to properties like password if we log in via...
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
when a variable name is used in a it is silently declared as a new local masking the global
the array() calling protocol came about after MediaWiki 1.4rc1.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
namespace and then decline to actually register it file or subcat img or subcat $title
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
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