Merge "Prepare for API error i18n"

This commit is contained in:
jenkins-bot 2016-11-28 17:36:13 +00:00 committed by Gerrit Code Review
commit 767a299afd
3 changed files with 25 additions and 3 deletions

View file

@ -117,7 +117,11 @@ class ApiFlowThankTest extends ApiTestCase {
}
public function testRequestWithoutToken() {
$this->setExpectedException( 'UsageException', 'The token parameter must be set' );
if ( class_exists( 'ApiUsageException' ) ) {
$this->setExpectedException( 'ApiUsageException', 'The "token" parameter must be set.' );
} else {
$this->setExpectedException( 'UsageException', 'The token parameter must be set' );
}
$this->doApiRequest( [
'action' => 'flowthank',
'postid' => UUID::create( '42' )->getAlphadecimal(),
@ -125,7 +129,11 @@ class ApiFlowThankTest extends ApiTestCase {
}
public function testInvalidRequest() {
$this->setExpectedException( 'UsageException', 'The postid parameter must be set' );
if ( class_exists( 'ApiUsageException' ) ) {
$this->setExpectedException( 'ApiUsageException', 'The "postid" parameter must be set.' );
} else {
$this->setExpectedException( 'UsageException', 'The postid parameter must be set' );
}
$this->doApiRequestWithToken( [ 'action' => 'flowthank' ] );
}

View file

@ -36,7 +36,11 @@ class ApiRevThankIntegrationTest extends ApiTestCase {
}
public function testRequestWithoutToken() {
$this->setExpectedException( 'UsageException', 'The token parameter must be set' );
if ( class_exists( 'ApiUsageException' ) ) {
$this->setExpectedException( 'ApiUsageException', 'The "token" parameter must be set.' );
} else {
$this->setExpectedException( 'UsageException', 'The token parameter must be set' );
}
$this->doApiRequest( [
'action' => 'thank',
'source' => 'someSource',

View file

@ -67,6 +67,16 @@ class ApiRevThankUnitTest extends MediaWikiTestCase {
$mockUser->expects( $this->once() )
->method( 'isBlocked' )
->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' ];