mirror of
https://github.com/flarum/core.git
synced 2025-07-16 06:16:23 +02:00
fixed those exception handling tests
This commit is contained in:
@ -1,11 +1,14 @@
|
|||||||
language: php
|
language: php
|
||||||
|
|
||||||
php:
|
php:
|
||||||
- 5.6
|
|
||||||
- 7.0
|
- 7.0
|
||||||
- 7.1
|
- 7.1
|
||||||
|
- 7.2
|
||||||
- hhvm
|
- hhvm
|
||||||
|
|
||||||
|
services:
|
||||||
|
- mysql
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
allow_failures:
|
allow_failures:
|
||||||
- php: hhvm
|
- php: hhvm
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
namespace Flarum\Api\ExceptionHandler;
|
namespace Flarum\Api\ExceptionHandler;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Contracts\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
use Tobscure\JsonApi\Exception\Handler\ExceptionHandlerInterface;
|
use Tobscure\JsonApi\Exception\Handler\ExceptionHandlerInterface;
|
||||||
use Tobscure\JsonApi\Exception\Handler\ResponseBag;
|
use Tobscure\JsonApi\Exception\Handler\ResponseBag;
|
||||||
|
|
||||||
@ -32,7 +32,8 @@ class IlluminateValidationExceptionHandler implements ExceptionHandlerInterface
|
|||||||
public function handle(Exception $e)
|
public function handle(Exception $e)
|
||||||
{
|
{
|
||||||
$status = 422;
|
$status = 422;
|
||||||
$errors = $this->formatErrors($e->errors()->toArray());
|
|
||||||
|
$errors = $this->formatErrors($e->errors());
|
||||||
|
|
||||||
return new ResponseBag($status, $errors);
|
return new ResponseBag($status, $errors);
|
||||||
}
|
}
|
||||||
|
@ -13,9 +13,11 @@ namespace Tests\Flarum\Api\Handler;
|
|||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Flarum\Api\ExceptionHandler\IlluminateValidationExceptionHandler;
|
use Flarum\Api\ExceptionHandler\IlluminateValidationExceptionHandler;
|
||||||
use Illuminate\Contracts\Validation\ValidationException;
|
use Illuminate\Translation\{
|
||||||
|
Translator, ArrayLoader
|
||||||
|
};
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
use Illuminate\Validation\Factory;
|
use Illuminate\Validation\Factory;
|
||||||
use Symfony\Component\Translation\Translator;
|
|
||||||
use Tests\Test\TestCase;
|
use Tests\Test\TestCase;
|
||||||
|
|
||||||
class IlluminateValidationExceptionHandlerTest extends TestCase
|
class IlluminateValidationExceptionHandlerTest extends TestCase
|
||||||
@ -54,7 +56,7 @@ class IlluminateValidationExceptionHandlerTest extends TestCase
|
|||||||
|
|
||||||
private function makeValidator($data = [], $rules = [])
|
private function makeValidator($data = [], $rules = [])
|
||||||
{
|
{
|
||||||
$translator = new Translator('en');
|
$translator = new Translator(new ArrayLoader(), 'en');
|
||||||
$factory = new Factory($translator);
|
$factory = new Factory($translator);
|
||||||
|
|
||||||
return $factory->make($data, $rules);
|
return $factory->make($data, $rules);
|
||||||
|
@ -12,9 +12,9 @@
|
|||||||
namespace Tests\Test;
|
namespace Tests\Test;
|
||||||
|
|
||||||
use Mockery;
|
use Mockery;
|
||||||
use PHPUnit_Framework_TestCase;
|
use PHPUnit\Framework\TestCase as Test;
|
||||||
|
|
||||||
abstract class TestCase extends PHPUnit_Framework_TestCase
|
abstract class TestCase extends Test
|
||||||
{
|
{
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user