API Client: Use new error handling mechanism

This commit is contained in:
Franz Liedke
2019-08-09 23:57:33 +02:00
committed by Daniël Klabbers
parent 6cf3c1088d
commit ddfb2c1ec1
10 changed files with 33 additions and 68 deletions

View File

@ -11,10 +11,8 @@ namespace Flarum\Tests\integration\api\Controller;
use Flarum\Api\Controller\CreateUserController;
use Flarum\Settings\SettingsRepositoryInterface;
use Flarum\User\Exception\PermissionDeniedException;
use Flarum\User\User;
use Illuminate\Support\Arr;
use Illuminate\Validation\ValidationException;
class CreateUserControllerTest extends ApiControllerTestCase
{
@ -51,10 +49,9 @@ class CreateUserControllerTest extends ApiControllerTestCase
*/
public function cannot_create_user_without_data()
{
$this->expectException(ValidationException::class);
$this->expectExceptionMessage('The given data was invalid.');
$response = $this->callWith();
$this->callWith();
$this->assertEquals(422, $response->getStatusCode());
}
/**
@ -104,12 +101,9 @@ class CreateUserControllerTest extends ApiControllerTestCase
$settings = app(SettingsRepositoryInterface::class);
$settings->set('allow_sign_up', false);
$this->expectException(PermissionDeniedException::class);
$response = $this->callWith($this->data);
$this->assertEquals(403, $response->getStatusCode());
try {
$this->callWith($this->data);
} finally {
$settings->set('allow_sign_up', true);
}
$settings->set('allow_sign_up', true);
}
}