Skip to content

Commit e098d33

Browse files
author
naillizard
committed
Added support for laravel 6.
1 parent 791f57e commit e098d33

File tree

7 files changed

+28
-22
lines changed

7 files changed

+28
-22
lines changed

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
}
1212
],
1313
"require": {
14-
"php": ">=5.6.0",
15-
"illuminate/support": "^5.3"
14+
"php": "^7.2",
15+
"illuminate/support": "^6.0"
1616
},
1717
"require-dev": {
18-
"orchestra/testbench": "~3.4",
19-
"phpunit/phpunit": "~5.7",
20-
"mockery/mockery": "0.9.*"
18+
"orchestra/testbench": "^4.0",
19+
"phpunit/phpunit": "^8.0",
20+
"mockery/mockery": "^1.0"
2121
},
2222
"autoload": {
2323
"psr-4": {

phpunit.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
convertWarningsToExceptions="true"
99
processIsolation="false"
1010
stopOnFailure="false"
11-
syntaxCheck="false"
1211
>
1312
<testsuites>
1413
<testsuite name="Package Test Suite">

src/ApiException.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Contracts\Support\Arrayable;
66
use Illuminate\Contracts\Support\Jsonable;
7+
use Illuminate\Support\Str;
78
use Lanin\Laravel\ApiExceptions\Contracts\ShowsPrevious;
89
use Lanin\Laravel\ApiExceptions\Contracts\ShowsTrace;
910
use Symfony\Component\Debug\Exception\FlattenException;
@@ -71,7 +72,7 @@ public function toArray()
7172
}
7273

7374
$return = [];
74-
$return['id'] = $e instanceof IdException ? $e->getId() : snake_case(class_basename($e));
75+
$return['id'] = $e instanceof IdException ? $e->getId() : Str::snake(class_basename($e));
7576
$return['message'] = $e->getMessage();
7677

7778
if ($e instanceof ApiException) {

src/Support/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ public function authorize()
3838
*/
3939
protected function failedValidation(Validator $validator)
4040
{
41-
throw new ValidationFailedApiException($this->formatErrors($validator));
41+
throw new ValidationFailedApiException($validator->getMessageBag()->toArray());
4242
}
4343
}

src/Support/Validator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Lanin\Laravel\ApiExceptions\Support;
44

5+
use Illuminate\Support\Str;
6+
57
class Validator extends \Illuminate\Validation\Validator
68
{
79
/**
@@ -18,7 +20,7 @@ protected function addError($attribute, $rule, $parameters)
1820
$message = $this->doReplacements($message, $attribute, $rule, $parameters);
1921

2022
$return = [
21-
'rule' => snake_case($rule),
23+
'rule' => Str::snake($rule),
2224
'message' => $message,
2325
];
2426

tests/ApiExceptionsServiceProviderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ class ApiExceptionsServiceProviderTest extends TestCase
99
/** @var ApiExceptionsServiceProvider */
1010
private $provider;
1111

12-
public function setUp()
12+
public function setUp(): void
1313
{
1414
parent::setUp();
1515
$this->provider = $this->app->getProvider(ApiExceptionsServiceProvider::class);
1616
}
1717

18-
public function tearDown()
18+
public function tearDown(): void
1919
{
2020
parent::tearDown();
2121
unset($this->provider);

tests/TestCase.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,28 @@
22

33
namespace Lanin\Laravel\ApiExceptions\Tests;
44

5-
use Illuminate\Support\Str;
5+
use Illuminate\Foundation\Application;
66
use Lanin\Laravel\ApiExceptions\ApiExceptionsServiceProvider;
77
use Orchestra\Testbench\TestCase as BaseTestCase;
8-
use PHPUnit_Framework_ExpectationFailedException as PHPUnitException;
98
use ReflectionClass;
9+
use ReflectionException;
10+
use ReflectionMethod;
11+
use ReflectionProperty;
1012

1113
abstract class TestCase extends BaseTestCase
1214
{
1315
/**
1416
* Setup the test environment.
1517
*/
16-
public function setUp()
18+
public function setUp(): void
1719
{
1820
parent::setUp();
1921
}
2022

2123
/**
2224
* Get package providers.
2325
*
24-
* @param \Illuminate\Foundation\Application $app
26+
* @param Application $app
2527
*
2628
* @return array
2729
*/
@@ -35,7 +37,7 @@ protected function getPackageProviders($app)
3537
/**
3638
* Define environment setup.
3739
*
38-
* @param \Illuminate\Foundation\Application $app
40+
* @param Application $app
3941
* @return void
4042
*/
4143
protected function getEnvironmentSetUp($app)
@@ -49,9 +51,10 @@ protected function getEnvironmentSetUp($app)
4951
/**
5052
* Make protected/private class property accessible.
5153
*
52-
* @param string|object $class
53-
* @param string $name
54-
* @return \ReflectionProperty
54+
* @param string|object $class
55+
* @param string $name
56+
* @return ReflectionProperty
57+
* @throws ReflectionException
5558
*/
5659
protected function getPublicProperty($class, $name)
5760
{
@@ -69,9 +72,10 @@ protected function getPublicProperty($class, $name)
6972
/**
7073
* Make protected/private class method accessible.
7174
*
72-
* @param string $name
73-
* @param string|object $class
74-
* @return \ReflectionMethod
75+
* @param string $name
76+
* @param string|object $class
77+
* @return ReflectionMethod
78+
* @throws ReflectionException
7579
*/
7680
protected function getPublicMethod($name, $class)
7781
{

0 commit comments

Comments
 (0)