mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Thanks
synced 2024-11-15 10:59:42 +00:00
Merge "Prepare for API error i18n"
This commit is contained in:
commit
767a299afd
|
@ -117,7 +117,11 @@ class ApiFlowThankTest extends ApiTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRequestWithoutToken() {
|
public function testRequestWithoutToken() {
|
||||||
|
if ( class_exists( 'ApiUsageException' ) ) {
|
||||||
|
$this->setExpectedException( 'ApiUsageException', 'The "token" parameter must be set.' );
|
||||||
|
} else {
|
||||||
$this->setExpectedException( 'UsageException', 'The token parameter must be set' );
|
$this->setExpectedException( 'UsageException', 'The token parameter must be set' );
|
||||||
|
}
|
||||||
$this->doApiRequest( [
|
$this->doApiRequest( [
|
||||||
'action' => 'flowthank',
|
'action' => 'flowthank',
|
||||||
'postid' => UUID::create( '42' )->getAlphadecimal(),
|
'postid' => UUID::create( '42' )->getAlphadecimal(),
|
||||||
|
@ -125,7 +129,11 @@ class ApiFlowThankTest extends ApiTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInvalidRequest() {
|
public function testInvalidRequest() {
|
||||||
|
if ( class_exists( 'ApiUsageException' ) ) {
|
||||||
|
$this->setExpectedException( 'ApiUsageException', 'The "postid" parameter must be set.' );
|
||||||
|
} else {
|
||||||
$this->setExpectedException( 'UsageException', 'The postid parameter must be set' );
|
$this->setExpectedException( 'UsageException', 'The postid parameter must be set' );
|
||||||
|
}
|
||||||
$this->doApiRequestWithToken( [ 'action' => 'flowthank' ] );
|
$this->doApiRequestWithToken( [ 'action' => 'flowthank' ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,11 @@ class ApiRevThankIntegrationTest extends ApiTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRequestWithoutToken() {
|
public function testRequestWithoutToken() {
|
||||||
|
if ( class_exists( 'ApiUsageException' ) ) {
|
||||||
|
$this->setExpectedException( 'ApiUsageException', 'The "token" parameter must be set.' );
|
||||||
|
} else {
|
||||||
$this->setExpectedException( 'UsageException', 'The token parameter must be set' );
|
$this->setExpectedException( 'UsageException', 'The token parameter must be set' );
|
||||||
|
}
|
||||||
$this->doApiRequest( [
|
$this->doApiRequest( [
|
||||||
'action' => 'thank',
|
'action' => 'thank',
|
||||||
'source' => 'someSource',
|
'source' => 'someSource',
|
||||||
|
|
|
@ -67,6 +67,16 @@ class ApiRevThankUnitTest extends MediaWikiTestCase {
|
||||||
$mockUser->expects( $this->once() )
|
$mockUser->expects( $this->once() )
|
||||||
->method( 'isBlocked' )
|
->method( 'isBlocked' )
|
||||||
->will( $this->returnValue( true ) );
|
->will( $this->returnValue( true ) );
|
||||||
|
$mockUser->expects( $this->any() )
|
||||||
|
->method( 'getBlock' )
|
||||||
|
->will( $this->returnValue( new Block( [
|
||||||
|
'address' => 'Test user',
|
||||||
|
'by' => 1,
|
||||||
|
'byText' => 'UTSysop',
|
||||||
|
'reason' => __METHOD__,
|
||||||
|
'timestamp' => wfTimestamp( TS_MW ),
|
||||||
|
'expiry' => 'infinity',
|
||||||
|
] ) ) );
|
||||||
|
|
||||||
$testCases[ 'blocked' ] = [ $mockUser, 'You have been blocked from editing' ];
|
$testCases[ 'blocked' ] = [ $mockUser, 'You have been blocked from editing' ];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue