Use expectException() in ActionTest
This way the intent is clearer, and it also properly covers the case where the exception isn't thrown. Change-Id: I7831382956d5bc204b695fecc47f7111519d53af
This commit is contained in:
parent
9b05a56a5d
commit
55b1c430ed
1 changed files with 4 additions and 11 deletions
|
|
@ -269,11 +269,8 @@ class ActionTest extends MediaWikiIntegrationTestCase {
|
|||
$user = $this->getTestUser()->getUser();
|
||||
$this->overrideUserPermissions( $user, [] );
|
||||
$action = $this->getAction( 'access' );
|
||||
try {
|
||||
$action->canExecute( $user );
|
||||
} catch ( Exception $e ) {
|
||||
$this->assertInstanceOf( PermissionsError::class, $e );
|
||||
}
|
||||
$this->expectException( PermissionsError::class );
|
||||
$action->canExecute( $user );
|
||||
}
|
||||
|
||||
public function testCanExecuteRequiresUnblock() {
|
||||
|
|
@ -297,12 +294,8 @@ class ActionTest extends MediaWikiIntegrationTestCase {
|
|||
->method( 'getBlock' )
|
||||
->willReturn( $block );
|
||||
|
||||
try {
|
||||
$action->canExecute( $user );
|
||||
$this->assertFalse( true );
|
||||
} catch ( Exception $e ) {
|
||||
$this->assertInstanceOf( UserBlockedError::class, $e );
|
||||
}
|
||||
$this->expectException( UserBlockedError::class );
|
||||
$action->canExecute( $user );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue