From 1c01145a14e48f1e68113b83f204ffbb55c9dd35 Mon Sep 17 00:00:00 2001 From: Daniel Klabbers Date: Thu, 5 Oct 2017 13:57:31 +0200 Subject: [PATCH] fixed those exception handling tests --- .travis.yml | 5 ++++- .../IlluminateValidationExceptionHandler.php | 5 +++-- .../Handler/IlluminateValidationExceptionHandlerTest.php | 8 +++++--- tests/Test/TestCase.php | 4 ++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2226ea1a2..4a684b9be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,14 @@ language: php php: - - 5.6 - 7.0 - 7.1 + - 7.2 - hhvm +services: + - mysql + matrix: allow_failures: - php: hhvm diff --git a/src/Api/ExceptionHandler/IlluminateValidationExceptionHandler.php b/src/Api/ExceptionHandler/IlluminateValidationExceptionHandler.php index ab5bfadcf..31bf030ca 100644 --- a/src/Api/ExceptionHandler/IlluminateValidationExceptionHandler.php +++ b/src/Api/ExceptionHandler/IlluminateValidationExceptionHandler.php @@ -12,7 +12,7 @@ namespace Flarum\Api\ExceptionHandler; use Exception; -use Illuminate\Contracts\Validation\ValidationException; +use Illuminate\Validation\ValidationException; use Tobscure\JsonApi\Exception\Handler\ExceptionHandlerInterface; use Tobscure\JsonApi\Exception\Handler\ResponseBag; @@ -32,7 +32,8 @@ class IlluminateValidationExceptionHandler implements ExceptionHandlerInterface public function handle(Exception $e) { $status = 422; - $errors = $this->formatErrors($e->errors()->toArray()); + + $errors = $this->formatErrors($e->errors()); return new ResponseBag($status, $errors); } diff --git a/tests/Flarum/Api/Handler/IlluminateValidationExceptionHandlerTest.php b/tests/Flarum/Api/Handler/IlluminateValidationExceptionHandlerTest.php index 4960aba36..298cee7b2 100644 --- a/tests/Flarum/Api/Handler/IlluminateValidationExceptionHandlerTest.php +++ b/tests/Flarum/Api/Handler/IlluminateValidationExceptionHandlerTest.php @@ -13,9 +13,11 @@ namespace Tests\Flarum\Api\Handler; use Exception; use Flarum\Api\ExceptionHandler\IlluminateValidationExceptionHandler; -use Illuminate\Contracts\Validation\ValidationException; +use Illuminate\Translation\{ + Translator, ArrayLoader +}; +use Illuminate\Validation\ValidationException; use Illuminate\Validation\Factory; -use Symfony\Component\Translation\Translator; use Tests\Test\TestCase; class IlluminateValidationExceptionHandlerTest extends TestCase @@ -54,7 +56,7 @@ class IlluminateValidationExceptionHandlerTest extends TestCase private function makeValidator($data = [], $rules = []) { - $translator = new Translator('en'); + $translator = new Translator(new ArrayLoader(), 'en'); $factory = new Factory($translator); return $factory->make($data, $rules); diff --git a/tests/Test/TestCase.php b/tests/Test/TestCase.php index 5a25ceb8b..864eb3b5d 100644 --- a/tests/Test/TestCase.php +++ b/tests/Test/TestCase.php @@ -12,9 +12,9 @@ namespace Tests\Test; 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() {