* @param string|bool $error False if no error expected
*/
public function testAssert( $registered, $rights, $assert, $error ) {
- $user = new User();
if ( $registered ) {
- $user->setId( 1 );
+ $user = $this->getMutableTestUser()->getUser();
+ $user->load(); // load before setting mRights
+ } else {
+ $user = new User();
}
$user->mRights = $rights;
try {
], null, null, $user );
$this->assertFalse( $error ); // That no error was expected
} catch ( ApiUsageException $e ) {
- $this->assertTrue( self::apiExceptionHasCode( $e, $error ) );
+ $this->assertTrue( self::apiExceptionHasCode( $e, $error ),
+ "Error '{$e->getMessage()}' matched expected '$error'" );
}
}