22 'sysop' => static::getTestSysop(),
23 'uploader' => static::getTestUser(),
27 'wgAuth' =>
new MediaWiki\Auth\AuthManagerAuthPlugin,
29 'wgUser' => self::$users[
'sysop']->getUser(),
37 MediaWiki\Session\SessionManager::getGlobalSession()->clear();
50 protected function editPage( $pageName, $text, $summary =
'', $defaultNs =
NS_MAIN ) {
51 $title = Title::newFromText( $pageName, $defaultNs );
74 $appendModule =
false,
User $user =
null
78 if ( is_null( $session ) ) {
91 MediaWiki\Auth\AuthManager::resetCache();
103 $module->getResult()->getResultData(
null, [
'Strip' =>
'all' ] ),
105 $context->getRequest()->getSessionArray()
108 if ( $appendModule ) {
109 $results[] = $module;
132 if ( $session ===
null ) {
136 if ( isset( $session[
'wsToken'] ) && $session[
'wsToken'] ) {
139 $session[
'wsTokenSecrets'][
'default'] = $session[
'wsToken'];
142 $params[
'token'] = hash_hmac(
'md5', $timestamp, $session[
'wsToken'] ) .
143 dechex( $timestamp ) .
144 MediaWiki\Session\Token::SUFFIX;
146 return $this->
doApiRequest( $params, $session,
false, $user );
148 throw new Exception(
"Session token not available" );
152 protected function doLogin( $testUser =
'sysop' ) {
153 if ( $testUser ===
null ) {
154 $testUser = static::getTestSysop();
155 } elseif ( is_string( $testUser ) && array_key_exists( $testUser, self::$users ) ) {
156 $testUser = self::$users[ $testUser ];
157 } elseif ( !$testUser instanceof
TestUser ) {
158 throw new MWException(
"Can not log in to undefined user $testUser" );
163 'lgname' => $testUser->getUser()->getName(),
164 'lgpassword' => $testUser->getPassword() ] );
166 $token = $data[0][
'login'][
'token'];
172 'lgname' => $testUser->getUser()->getName(),
173 'lgpassword' => $testUser->getPassword(),
178 if ( $data[0][
'login'][
'result'] ===
'Success' ) {
181 $wgUser = $testUser->getUser();
190 'action' =>
'tokens',
191 'type' =>
'edit|delete|protect|move|block|unblock|watch'
192 ], $session,
false, $user->getUser() );
194 if ( !array_key_exists(
'tokens', $data[0] ) ) {
195 throw new MWException(
'Api failed to return a token list' );
198 return $data[0][
'tokens'];
202 if ( self::$errorFormatter ===
null ) {
205 Language::factory(
'en' ),
213 return (
bool)array_filter(
214 self::getErrorFormatter()->arrayFromStatus( $ex->getStatusValue() ),
216 return is_array(
$e ) &&
$e[
'code'] ===
$code;
222 $groups = PHPUnit_Util_Test::getGroups( static::class );
223 $constraint = PHPUnit_Framework_Assert::logicalOr(
227 $this->assertThat( $groups, $constraint,
228 'ApiTestCase::setUp can be slow, tests must be "medium" or "large"'
239 $msg,
$code =
null, array $data =
null, $httpCode = 0
242 $this->setExpectedException( ApiUsageException::class, $expected->getMessage() );
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it contains
$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.
This class represents the result of the API operations.
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.
setExpectedApiException( $msg, $code=null, array $data=null, $httpCode=0)
Expect an ApiUsageException to be thrown with the given parameters, which are the same as ApiUsageExc...
static apiExceptionHasCode(ApiUsageException $ex, $code)
static getErrorFormatter()
ApiTestContext $apiContext
Exception used to abort API execution with an error.
static newWithMessage(ApiBase $module=null, $msg, $code=null, $data=null, $httpCode=0)
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 function
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
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
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
returning false will NOT prevent logging $e