Index: trunk/phase3/tests/phpunit/includes/api/ApiBlockTest.php |
— | — | @@ -0,0 +1,67 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +require_once dirname( __FILE__ ) . '/ApiSetup.php'; |
| 5 | + |
| 6 | +/** |
| 7 | + * @group Database |
| 8 | + * @group Destructive |
| 9 | + */ |
| 10 | +class ApiBlockTest extends ApiTestSetup { |
| 11 | + |
| 12 | + function setUp() { |
| 13 | + parent::setUp(); |
| 14 | + $this->doLogin(); |
| 15 | + } |
| 16 | + |
| 17 | + function getTokens() { |
| 18 | + return $this->getTokenList( $this->sysopUser ); |
| 19 | + } |
| 20 | + |
| 21 | + function addDBData() { |
| 22 | + $user = User::newFromName( 'UTBlockee' ); |
| 23 | + |
| 24 | + if ( $user->getId() == 0 ) { |
| 25 | + $user->addToDatabase(); |
| 26 | + $user->setPassword( 'UTBlockeePassword' ); |
| 27 | + |
| 28 | + $user->saveSettings(); |
| 29 | + } |
| 30 | + } |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | + function testMakeNormalBlock() { |
| 35 | + |
| 36 | + $data = $this->getTokens(); |
| 37 | + |
| 38 | + $user = User::newFromName( 'UTBlockee' ); |
| 39 | + |
| 40 | + if ( !$user->getId() ) { |
| 41 | + $this->markTestIncomplete( "The user UTBlockee does not exist" ); |
| 42 | + } |
| 43 | + |
| 44 | + if( !isset( $data[0]['query']['pages'] ) ) { |
| 45 | + $this->markTestIncomplete( "No block token found" ); |
| 46 | + } |
| 47 | + |
| 48 | + $keys = array_keys( $data[0]['query']['pages'] ); |
| 49 | + $key = array_pop( $keys ); |
| 50 | + $pageinfo = $data[0]['query']['pages'][$key]; |
| 51 | + |
| 52 | + $data = $this->doApiRequest( array( |
| 53 | + 'action' => 'block', |
| 54 | + 'user' => 'UTBlockee', |
| 55 | + 'reason' => 'Some reason', |
| 56 | + 'token' => $pageinfo['blocktoken'] ), $data ); |
| 57 | + |
| 58 | + $block = Block::newFromDB('UTBlockee'); |
| 59 | + |
| 60 | + $this->assertTrue( !is_null( $block ), 'Block is valid' ); |
| 61 | + |
| 62 | + $this->assertEquals( 'UTBlockee', $block->mAddress ); |
| 63 | + $this->assertEquals( 'Some reason', $block->mReason ); |
| 64 | + $this->assertEquals( 'infinity', $block->mExpiry ); |
| 65 | + |
| 66 | + } |
| 67 | + |
| 68 | +} |
Property changes on: trunk/phase3/tests/phpunit/includes/api/ApiBlockTest.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 69 | + native |
Index: trunk/phase3/includes/api/ApiBlock.php |
— | — | @@ -90,6 +90,7 @@ |
91 | 91 | $form->BlockHideName = $params['hidename']; |
92 | 92 | $form->BlockAllowUsertalk = $params['allowusertalk'] && $wgBlockAllowsUTEdit; |
93 | 93 | $form->BlockReblock = $params['reblock']; |
| 94 | + $form->BlockWatchUser = $params['watchuser']; |
94 | 95 | |
95 | 96 | $userID = $expiry = null; |
96 | 97 | $retval = $form->doBlock( $userID, $expiry ); |
— | — | @@ -120,6 +121,9 @@ |
121 | 122 | if ( $params['allowusertalk'] ) { |
122 | 123 | $res['allowusertalk'] = ''; |
123 | 124 | } |
| 125 | + if ( $params['watchuser'] ) { |
| 126 | + $res['watchuser'] = ''; |
| 127 | + } |
124 | 128 | |
125 | 129 | $this->getResult()->addValue( null, $this->getModuleName(), $res ); |
126 | 130 | } |
— | — | @@ -149,6 +153,7 @@ |
150 | 154 | 'hidename' => false, |
151 | 155 | 'allowusertalk' => false, |
152 | 156 | 'reblock' => false, |
| 157 | + 'watchuser' => false, |
153 | 158 | ); |
154 | 159 | } |
155 | 160 | |
— | — | @@ -166,6 +171,7 @@ |
167 | 172 | 'hidename' => 'Hide the username from the block log. (Requires the "hideuser" right.)', |
168 | 173 | 'allowusertalk' => 'Allow the user to edit their own talk page (depends on $wgBlockAllowsUTEdit)', |
169 | 174 | 'reblock' => 'If the user is already blocked, overwrite the existing block', |
| 175 | + 'watchuser' => 'Watch the user/IP\'s user and talk pages', |
170 | 176 | ); |
171 | 177 | } |
172 | 178 | |