Go to the documentation of this file.
15 $this->tablesUsed = array_merge(
17 [
'ipblocks',
'change_tag',
'change_tag_def',
'logging' ]
37 if ( $blocker ===
null ) {
38 $blocker = self::$users[
'sysop']->getUser();
43 $this->assertNotNull( $this->mUser,
'Sanity check' );
45 $this->assertArrayHasKey(
'blocktoken',
$tokens,
'Sanity check' );
49 'user' => $this->mUser->getName(),
50 'reason' =>
'Some reason',
51 'token' =>
$tokens[
'blocktoken'],
53 if ( array_key_exists(
'userid', $extraParams ) ) {
62 $this->assertTrue( !is_null( $block ),
'Block is valid' );
64 $this->assertSame( $this->mUser->getName(), (
string)$block->getTarget() );
65 $this->assertSame(
'Some reason', $block->mReason );
81 $this->
doBlock( [
'userid' => $this->mUser->getId() ] );
89 'You cannot block or unblock other users because you are yourself blocked.' );
93 'address' => $blocked->getName(),
94 'by' => self::$users[
'sysop']->getUser()->getId(),
95 'reason' =>
'Capriciousness',
96 'timestamp' =>
'19370101000000',
97 'expiry' =>
'infinity',
101 $this->
doBlock( [], $blocked );
106 'There is no user by the name "Nonexistent". Check your spelling.' );
108 $this->
doBlock( [
'user' =>
'Nonexistent' ] );
114 "There is no user with ID $id." );
116 $this->assertFalse(
User::whoIs( $id ),
'Sanity check' );
118 $this->
doBlock( [
'userid' => $id ] );
125 $this->
doBlock( [
'tags' =>
'custom tag' ] );
128 $this->assertSame( 1, (
int)$dbw->selectField(
129 [
'change_tag',
'logging' ],
131 [
'log_type' =>
'block',
'ct_tag' =>
'custom tag' ],
134 [
'change_tag' => [
'INNER JOIN',
'ct_log_id = log_id' ] ]
142 $this->
doBlock( [
'tags' =>
'custom tag' ] );
145 $this->assertSame( 1, (
int)$dbw->selectField(
146 [
'change_tag',
'logging',
'change_tag_def' ],
148 [
'log_type' =>
'block',
'ctd_name' =>
'custom tag' ],
152 'change_tag' => [
'INNER JOIN',
'ct_log_id = log_id' ],
153 'change_tag_def' => [
'INNER JOIN',
'ctd_id = ct_tag_id' ],
160 'You do not have permission to apply change tags along with your changes.' );
165 [
'user' => [
'applychangetags' =>
true ] ] );
167 $this->
doBlock( [
'tags' =>
'custom tag' ] );
173 $newPermissions[
'hideuser'] =
true;
175 [
'sysop' => $newPermissions ] );
180 $this->assertSame(
'1', $dbw->selectField(
183 [
'ipb_id' =>
$res[0][
'block'][
'id'] ],
190 "You don't have permission to hide user names from the block log." );
192 $this->
doBlock( [
'hidename' =>
'' ] );
199 $this->assertSame(
'1', $dbw->selectField(
202 [
'ipb_id' =>
$res[0][
'block'][
'id'] ],
209 "You don't have permission to block users from sending email through the wiki." );
212 [
'sysop' => [
'blockemail' =>
true ] ] );
214 $this->
doBlock( [
'noemail' =>
'' ] );
221 $expiry = $dbw->selectField(
224 [
'ipb_id' =>
$res[0][
'block'][
'id'] ],
229 $this->assertLessThanOrEqual( 1,
230 abs(
wfTimestamp( TS_UNIX, $expiry ) - ( time() + 86400 ) ) );
236 $this->
doBlock( [
'expiry' =>
'' ] );
247 'user' => $this->mUser->getName(),
248 'reason' =>
'Some reason',
252 self::$users[
'sysop']->getUser()
testBlockOfNonexistentUser()
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
static newFromTarget( $specificTarget, $vagueTarget=null, $fromMaster=false)
Given a target and the target's type, get an existing Block object if possible.
const MIGRATION_WRITE_BOTH
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
testVeryLargeRangeBlock()
ApiUsageException Range blocks larger than /16 are not allowed.
testBlockById()
Block by user ID.
testBlockWithEmailBlock()
insert( $dbw=null)
Insert a block into the block table.
doBlock(array $extraParams=[], User $blocker=null)
testNormalBlock()
Block by username.
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
testBlockOfNonexistentUserId()
getTokenList(TestUser $user, $session=null)
doApiRequest(array $params, array $session=null, $appendModule=false, User $user=null, $tokenType=null)
Does the API request and returns the result.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
testBlockWithProhibitedEmailBlock()
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
static whoIs( $id)
Get the username corresponding to a given user ID.
testBlockWithProhibitedHide()
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
testBlockWithInvalidExpiry()
testBlockWithTagNewBackend()
testBlockByBlockedUser()
A blocked user can't block.
testBlockingActionWithNoToken()
ApiUsageException The "token" parameter must be set.
$wgGroupPermissions['sysop']['replacetext']
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
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
testBlockWithProhibitedTag()