MediaWiki  1.23.2
ApiBlockTest.php
Go to the documentation of this file.
1 <?php
2 
10 class ApiBlockTest extends ApiTestCase {
11  protected function setUp() {
12  parent::setUp();
13  $this->doLogin();
14  }
15 
16  protected function getTokens() {
17  return $this->getTokenList( self::$users['sysop'] );
18  }
19 
20  function addDBData() {
21  $user = User::newFromName( 'UTApiBlockee' );
22 
23  if ( $user->getId() == 0 ) {
24  $user->addToDatabase();
25  $user->setPassword( 'UTApiBlockeePassword' );
26 
27  $user->saveSettings();
28  }
29  }
30 
39  public function testMakeNormalBlock() {
40  $tokens = $this->getTokens();
41 
42  $user = User::newFromName( 'UTApiBlockee' );
43 
44  if ( !$user->getId() ) {
45  $this->markTestIncomplete( "The user UTApiBlockee does not exist" );
46  }
47 
48  if ( !array_key_exists( 'blocktoken', $tokens ) ) {
49  $this->markTestIncomplete( "No block token found" );
50  }
51 
52  $this->doApiRequest( array(
53  'action' => 'block',
54  'user' => 'UTApiBlockee',
55  'reason' => 'Some reason',
56  'token' => $tokens['blocktoken'] ), null, false, self::$users['sysop']->user );
57 
58  $block = Block::newFromTarget( 'UTApiBlockee' );
59 
60  $this->assertTrue( !is_null( $block ), 'Block is valid' );
61 
62  $this->assertEquals( 'UTApiBlockee', (string)$block->getTarget() );
63  $this->assertEquals( 'Some reason', $block->mReason );
64  $this->assertEquals( 'infinity', $block->mExpiry );
65  }
66 
71  public function testBlockingActionWithNoToken( ) {
72  $this->doApiRequest(
73  array(
74  'action' => 'block',
75  'user' => 'UTApiBlockee',
76  'reason' => 'Some reason',
77  ),
78  null,
79  false,
80  self::$users['sysop']->user
81  );
82  }
83 }
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
ApiBlockTest\testMakeNormalBlock
testMakeNormalBlock()
This test has probably always been broken and use an invalid token Bug tracking brokenness is https:/...
Definition: ApiBlockTest.php:39
ApiTestCase\getTokenList
getTokenList( $user, $session=null)
Definition: ApiTestCase.php:166
ApiBlockTest\setUp
setUp()
Definition: ApiBlockTest.php:11
Block\newFromTarget
static newFromTarget( $specificTarget, $vagueTarget=null, $fromMaster=false)
Given a target and the target's type, get an existing Block object if possible.
Definition: Block.php:970
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:388
ApiBlockTest
@group API @group Database @group medium
Definition: ApiBlockTest.php:10
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
user
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 and we might be restricted by PHP settings such as safe mode or open_basedir We cannot assume that the software even has read access anywhere useful Many shared hosts run all users web applications under the same user
Definition: distributors.txt:9
ApiTestCase
Definition: ApiTestCase.php:3
ApiBlockTest\getTokens
getTokens()
Definition: ApiBlockTest.php:16
$user
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 account $user
Definition: hooks.txt:237
ApiTestCase\doLogin
doLogin( $user='sysop')
Definition: ApiTestCase.php:141
ApiTestCase\doApiRequest
doApiRequest(array $params, array $session=null, $appendModule=false, User $user=null)
Does the API request and returns the result.
Definition: ApiTestCase.php:74
ApiBlockTest\testBlockingActionWithNoToken
testBlockingActionWithNoToken()
@expectedException UsageException @expectedExceptionMessage The token parameter must be set
Definition: ApiBlockTest.php:71
ApiBlockTest\addDBData
addDBData()
Stub.
Definition: ApiBlockTest.php:20