mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Thanks
synced 2024-11-24 06:53:46 +00:00
tests: setExpectedException() is deprecated
Change-Id: Ie9500ff2dabb9315f6fe8344acdfbb1f3f1aac33
This commit is contained in:
parent
951d171e6b
commit
be060b3d07
|
@ -57,7 +57,8 @@ class ApiCoreThankIntegrationTest extends ApiTestCase {
|
|||
}
|
||||
|
||||
public function testRequestWithoutToken() {
|
||||
$this->setExpectedException( 'ApiUsageException', 'The "token" parameter must be set.' );
|
||||
$this->expectException( ApiUsageException::class );
|
||||
$this->expectExceptionMessage( 'The "token" parameter must be set.' );
|
||||
$this->doApiRequest( [
|
||||
'action' => 'thank',
|
||||
'source' => 'someSource',
|
||||
|
@ -84,10 +85,9 @@ class ApiCoreThankIntegrationTest extends ApiTestCase {
|
|||
public function testLogRequestWithDisallowedLogType() {
|
||||
// Empty the log-type whitelist.
|
||||
$this->setMwGlobals( [ 'wgThanksLogTypeWhitelist' => [] ] );
|
||||
$this->setExpectedException(
|
||||
ApiUsageException::class,
|
||||
"Log type 'delete' is not in the whitelist of permitted log types."
|
||||
);
|
||||
$this->expectException( ApiUsageException::class );
|
||||
$this->expectExceptionMessage(
|
||||
"Log type 'delete' is not in the whitelist of permitted log types." );
|
||||
$this->doApiRequestWithToken( [
|
||||
'action' => 'thank',
|
||||
'log' => $this->logId,
|
||||
|
@ -111,10 +111,9 @@ class ApiCoreThankIntegrationTest extends ApiTestCase {
|
|||
$this->doLogin( 'sysop' );
|
||||
|
||||
// Then try to thank for it, and we should get an exception.
|
||||
$this->setExpectedException(
|
||||
ApiUsageException::class,
|
||||
"The requested log entry has been deleted and thanks cannot be given for it."
|
||||
);
|
||||
$this->expectException( ApiUsageException::class );
|
||||
$this->expectExceptionMessage(
|
||||
"The requested log entry has been deleted and thanks cannot be given for it." );
|
||||
$this->doApiRequestWithToken( [
|
||||
'action' => 'thank',
|
||||
'log' => $this->logId,
|
||||
|
@ -140,7 +139,7 @@ class ApiCoreThankIntegrationTest extends ApiTestCase {
|
|||
}
|
||||
|
||||
public function testInvalidRequest() {
|
||||
$this->setExpectedException( 'ApiUsageException' );
|
||||
$this->expectException( ApiUsageException::class );
|
||||
$this->doApiRequestWithToken( [ 'action' => 'thank' ] );
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,8 @@ class ApiCoreThankUnitTest extends MediaWikiTestCase {
|
|||
$method->setAccessible( true );
|
||||
|
||||
if ( $expectedError ) {
|
||||
$this->setExpectedException( 'ApiUsageException', $expectedError );
|
||||
$this->expectException( ApiUsageException::class );
|
||||
$this->expectExceptionMessage( $expectedError );
|
||||
}
|
||||
|
||||
$method->invoke( $module, $user );
|
||||
|
|
|
@ -124,7 +124,8 @@ class ApiFlowThankIntegrationTest extends ApiTestCase {
|
|||
}
|
||||
|
||||
public function testRequestWithoutToken() {
|
||||
$this->setExpectedException( 'ApiUsageException', 'The "token" parameter must be set.' );
|
||||
$this->expectException( ApiUsageException::class );
|
||||
$this->expectExceptionMessage( 'The "token" parameter must be set.' );
|
||||
$this->doApiRequest( [
|
||||
'action' => 'flowthank',
|
||||
'postid' => UUID::create( '42' )->getAlphadecimal(),
|
||||
|
@ -132,7 +133,8 @@ class ApiFlowThankIntegrationTest extends ApiTestCase {
|
|||
}
|
||||
|
||||
public function testInvalidRequest() {
|
||||
$this->setExpectedException( 'ApiUsageException', 'The "postid" parameter must be set.' );
|
||||
$this->expectException( ApiUsageException::class );
|
||||
$this->expectExceptionMessage( 'The "postid" parameter must be set.' );
|
||||
$this->doApiRequestWithToken( [ 'action' => 'flowthank' ] );
|
||||
}
|
||||
|
||||
|
@ -145,7 +147,8 @@ class ApiFlowThankIntegrationTest extends ApiTestCase {
|
|||
}
|
||||
|
||||
public function testRequestWithInvalidId() {
|
||||
$this->setExpectedException( 'ApiUsageException', 'Post ID is not valid' );
|
||||
$this->expectException( ApiUsageException::class );
|
||||
$this->expectExceptionMessage( 'Post ID is not valid' );
|
||||
list( $result,, ) = $this->doApiRequestWithToken( [
|
||||
'action' => 'flowthank',
|
||||
'postid' => UUID::create( '42' )->getAlphadecimal(),
|
||||
|
@ -153,7 +156,8 @@ class ApiFlowThankIntegrationTest extends ApiTestCase {
|
|||
}
|
||||
|
||||
public function testRequestWithOwnId() {
|
||||
$this->setExpectedException( 'ApiUsageException', 'You cannot thank yourself' );
|
||||
$this->expectException( ApiUsageException::class );
|
||||
$this->expectExceptionMessage( 'You cannot thank yourself' );
|
||||
list( $result,, ) = $this->doApiRequestWithToken( [
|
||||
'action' => 'flowthank',
|
||||
'postid' => $this->postByMe->getPostId()->getAlphadecimal(),
|
||||
|
|
Loading…
Reference in a new issue