3 require_once dirname( __FILE__
) . '/ApiSetup.php';
9 class ApiBlockTest
extends ApiTestSetup
{
16 function getTokens() {
17 return $this->getTokenList( $this->sysopUser
);
20 function addDBData() {
21 $user = User
::newFromName( 'UTBlockee' );
23 if ( $user->getId() == 0 ) {
24 $user->addToDatabase();
25 $user->setPassword( 'UTBlockeePassword' );
27 $user->saveSettings();
33 function testMakeNormalBlock() {
35 $data = $this->getTokens();
37 $user = User
::newFromName( 'UTBlockee' );
39 if ( !$user->getId() ) {
40 $this->markTestIncomplete( "The user UTBlockee does not exist" );
43 if( !isset( $data[0]['query']['pages'] ) ) {
44 $this->markTestIncomplete( "No block token found" );
47 $keys = array_keys( $data[0]['query']['pages'] );
48 $key = array_pop( $keys );
49 $pageinfo = $data[0]['query']['pages'][$key];
51 $data = $this->doApiRequest( array(
53 'user' => 'UTBlockee',
54 'reason' => 'Some reason',
55 'token' => $pageinfo['blocktoken'] ), $data );
57 $block = Block
::newFromDB('UTBlockee');
59 $this->assertTrue( !is_null( $block ), 'Block is valid' );
61 $this->assertEquals( 'UTBlockee', $block->mAddress
);
62 $this->assertEquals( 'Some reason', $block->mReason
);
63 $this->assertEquals( 'infinity', $block->mExpiry
);