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

@ -13,7 +13,6 @@ use Flarum\Api\Controller\CreateDiscussionController;
use Flarum\Discussion\Discussion;
use Flarum\User\User;
use Illuminate\Support\Arr;
use Illuminate\Validation\ValidationException;
class CreateDiscussionControllerTest extends ApiControllerTestCase
{
@ -70,11 +69,9 @@ class CreateDiscussionControllerTest extends ApiControllerTestCase
$this->actor = User::find(1);
$data = Arr::except($this->data, 'content');
$response = $this->callWith($data);
$this->expectException(ValidationException::class);
$this->expectExceptionMessage('The given data was invalid.');
$this->callWith($data);
$this->assertEquals(422, $response->getStatusCode());
}
/**
@ -85,10 +82,8 @@ class CreateDiscussionControllerTest extends ApiControllerTestCase
$this->actor = User::find(1);
$data = Arr::except($this->data, 'title');
$response = $this->callWith($data);
$this->expectException(ValidationException::class);
$this->expectExceptionMessage('The given data was invalid.');
$this->callWith($data);
$this->assertEquals(422, $response->getStatusCode());
}
}