mirror of
https://github.com/flarum/core.git
synced 2025-07-30 21:20:24 +02:00
Distinguish between attributes/relationships in ValidationException
This exception could be a candidate for inclusion in tobscure/json-api...
This commit is contained in:
@@ -32,15 +32,24 @@ class ValidationExceptionHandlerTest extends TestCase
|
||||
|
||||
public function test_managing_exceptions()
|
||||
{
|
||||
$response = $this->handler->handle(new ValidationException(['There was an error']));
|
||||
$response = $this->handler->handle(new ValidationException(
|
||||
['foo' => 'Attribute error'],
|
||||
['bar' => 'Relationship error']
|
||||
));
|
||||
|
||||
$this->assertEquals(422, $response->getStatus());
|
||||
$this->assertEquals([
|
||||
[
|
||||
'status' => '422',
|
||||
'code' => 'validation_error',
|
||||
'detail' => 'There was an error',
|
||||
'source' => ['pointer' => '/data/attributes/0']
|
||||
'detail' => 'Attribute error',
|
||||
'source' => ['pointer' => '/data/attributes/foo']
|
||||
],
|
||||
[
|
||||
'status' => '422',
|
||||
'code' => 'validation_error',
|
||||
'detail' => 'Relationship error',
|
||||
'source' => ['pointer' => '/data/relationships/bar']
|
||||
]
|
||||
], $response->getErrors());
|
||||
}
|
||||
|
Reference in New Issue
Block a user