From e44313f91d55063bed55c24134eefd7f4dce39a4 Mon Sep 17 00:00:00 2001 From: Coen Zimmerman Date: Sat, 15 Apr 2017 22:43:45 +0200 Subject: [PATCH 1/9] Updated changed namespace for http response exception --- src/Encoder/Transformers/ExceptionTransformer.php | 4 ++-- src/Http/Requests/JsonApiRequest.php | 2 +- tests/Encoder/Transformers/ExceptionTransformerTest.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Encoder/Transformers/ExceptionTransformer.php b/src/Encoder/Transformers/ExceptionTransformer.php index d9a979b..3c82b5d 100644 --- a/src/Encoder/Transformers/ExceptionTransformer.php +++ b/src/Encoder/Transformers/ExceptionTransformer.php @@ -50,8 +50,8 @@ protected function convertExceptionToErrorData(Exception $exception) protected function getStatusCode(Exception $exception) { // special case: fully formed response exception (laravel 5.2 validation) - if (is_a($exception, \Illuminate\Http\Exception\HttpResponseException::class)) { - /** @var \Illuminate\Http\Exception\HttpResponseException $exception */ + if (is_a($exception, \Illuminate\Http\Exceptions\HttpResponseException::class)) { + /** @var \Illuminate\Http\Exceptions\HttpResponseException $exception */ return $exception->getResponse()->getStatusCode(); } diff --git a/src/Http/Requests/JsonApiRequest.php b/src/Http/Requests/JsonApiRequest.php index 3a56e93..08b776c 100644 --- a/src/Http/Requests/JsonApiRequest.php +++ b/src/Http/Requests/JsonApiRequest.php @@ -5,7 +5,7 @@ use Czim\JsonApi\Data\Root; use Czim\JsonApi\Support\Request\RequestQueryParser; use Illuminate\Foundation\Http\FormRequest; -use Illuminate\Http\Exception\HttpResponseException; +use Illuminate\Http\Exceptions\HttpResponseException; class JsonApiRequest extends FormRequest { diff --git a/tests/Encoder/Transformers/ExceptionTransformerTest.php b/tests/Encoder/Transformers/ExceptionTransformerTest.php index dec4908..9f815c8 100644 --- a/tests/Encoder/Transformers/ExceptionTransformerTest.php +++ b/tests/Encoder/Transformers/ExceptionTransformerTest.php @@ -5,7 +5,7 @@ use Czim\JsonApi\Encoder\Transformers\ExceptionTransformer; use Czim\JsonApi\Test\Helpers\Exceptions\TestStatusException; use Czim\JsonApi\Test\TestCase; -use Illuminate\Http\Exception\HttpResponseException; +use Illuminate\Http\Exceptions\HttpResponseException; use Mockery; /** From 99618ca8d42427a89fe6705e986c419ad6d315a9 Mon Sep 17 00:00:00 2001 From: Coen Zimmerman Date: Sat, 15 Apr 2017 22:44:39 +0200 Subject: [PATCH 2/9] Updated tests for new call/response handling --- .../Request/JsonApiRequestTest.php | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/Integration/Request/JsonApiRequestTest.php b/tests/Integration/Request/JsonApiRequestTest.php index 9dcf30c..8e91a80 100644 --- a/tests/Integration/Request/JsonApiRequestTest.php +++ b/tests/Integration/Request/JsonApiRequestTest.php @@ -24,14 +24,14 @@ public function getEnvironmentSetUp($app) */ function it_does_not_validate_get_request_parameters_against_json_schema() { - $this->call( + $response = $this->call( 'GET', 'request?page[number]=44' ); - $this->assertResponseStatus(200); + $response->assertStatus(200); - $data = json_decode($this->response->content(), true); + $data = json_decode($response->content(), true); static::assertEquals(44, $data['query-page-number']); } @@ -41,15 +41,15 @@ function it_does_not_validate_get_request_parameters_against_json_schema() */ function it_parses_query_string_data() { - $this->call( + $response = $this->call( 'POST', 'request?page[number]=44', $this->getValidRequestData() ); - $this->assertResponseStatus(200); + $response->assertStatus(200); - $data = json_decode($this->response->content(), true); + $data = json_decode($response->content(), true); static::assertEquals(44, $data['query-page-number']); } @@ -59,9 +59,9 @@ function it_parses_query_string_data() */ function it_returns_a_422_response_for_invalid_request_data() { - $this->call('POST', 'request', ['test']); + $response = $this->call('POST', 'request', ['test']); - $this->assertResponseStatus(422); + $response->assertStatus(422); } /** @@ -69,15 +69,15 @@ function it_returns_a_422_response_for_invalid_request_data() */ function it_parses_valid_request_data() { - $this->call( + $response = $this->call( 'POST', 'request', $this->getValidRequestData() ); - $this->assertResponseStatus(200); + $response->assertStatus(200); - $data = json_decode($this->response->content(), true); + $data = json_decode($response->content(), true); static::assertInternalType('array', $data, 'Invalid JSON returned'); static::assertEquals(RootType::RESOURCE, $data['data-root-type']); @@ -88,15 +88,15 @@ function it_parses_valid_request_data() */ function it_parses_valid_create_data() { - $this->call( + $response = $this->call( 'POST', 'create', $this->getValidCreateData() ); - $this->assertResponseStatus(200); + $response->assertStatus(200); - $data = json_decode($this->response->content(), true); + $data = json_decode($response->content(), true); static::assertInternalType('array', $data, 'Invalid JSON returned'); static::assertEquals(RootType::RESOURCE, $data['data-root-type']); From de3121b35fd5bf7e10fe3106ca635fc3c9f28649 Mon Sep 17 00:00:00 2001 From: Coen Zimmerman Date: Sat, 15 Apr 2017 22:44:52 +0200 Subject: [PATCH 3/9] Updated dependencies for 5.4 --- composer.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index a68b943..1247593 100644 --- a/composer.json +++ b/composer.json @@ -17,17 +17,18 @@ } ], "require": { - "php": ">=5.6.0", + "php": ">=5.6.4", "czim/laravel-dataobject": "^1.0", "myclabs/php-enum": "^1.5", "doctrine/dbal": "^2.5", "justinrainbow/json-schema": "^5.2" }, "require-dev": { - "phpunit/phpunit": "5.*", + "phpunit/phpunit": "~5.7", "mockery/mockery": "0.9.*", "scrutinizer/ocular": "~1.1", - "orchestra/testbench": "3.3.*", + "orchestra/testbench": "~3.4", + "orchestra/database": "~3.4", "satooshi/php-coveralls": "^1.0" }, "autoload": { From d15e811aae2bfff1976df40b9b8bf632b3765efa Mon Sep 17 00:00:00 2001 From: Coen Zimmerman Date: Sat, 15 Apr 2017 22:43:45 +0200 Subject: [PATCH 4/9] Updated changed namespace for http response exception --- src/Encoder/Transformers/ExceptionTransformer.php | 4 ++-- src/Http/Requests/JsonApiRequest.php | 2 +- tests/Encoder/Transformers/ExceptionTransformerTest.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Encoder/Transformers/ExceptionTransformer.php b/src/Encoder/Transformers/ExceptionTransformer.php index d9a979b..3c82b5d 100644 --- a/src/Encoder/Transformers/ExceptionTransformer.php +++ b/src/Encoder/Transformers/ExceptionTransformer.php @@ -50,8 +50,8 @@ protected function convertExceptionToErrorData(Exception $exception) protected function getStatusCode(Exception $exception) { // special case: fully formed response exception (laravel 5.2 validation) - if (is_a($exception, \Illuminate\Http\Exception\HttpResponseException::class)) { - /** @var \Illuminate\Http\Exception\HttpResponseException $exception */ + if (is_a($exception, \Illuminate\Http\Exceptions\HttpResponseException::class)) { + /** @var \Illuminate\Http\Exceptions\HttpResponseException $exception */ return $exception->getResponse()->getStatusCode(); } diff --git a/src/Http/Requests/JsonApiRequest.php b/src/Http/Requests/JsonApiRequest.php index 3a56e93..08b776c 100644 --- a/src/Http/Requests/JsonApiRequest.php +++ b/src/Http/Requests/JsonApiRequest.php @@ -5,7 +5,7 @@ use Czim\JsonApi\Data\Root; use Czim\JsonApi\Support\Request\RequestQueryParser; use Illuminate\Foundation\Http\FormRequest; -use Illuminate\Http\Exception\HttpResponseException; +use Illuminate\Http\Exceptions\HttpResponseException; class JsonApiRequest extends FormRequest { diff --git a/tests/Encoder/Transformers/ExceptionTransformerTest.php b/tests/Encoder/Transformers/ExceptionTransformerTest.php index dec4908..9f815c8 100644 --- a/tests/Encoder/Transformers/ExceptionTransformerTest.php +++ b/tests/Encoder/Transformers/ExceptionTransformerTest.php @@ -5,7 +5,7 @@ use Czim\JsonApi\Encoder\Transformers\ExceptionTransformer; use Czim\JsonApi\Test\Helpers\Exceptions\TestStatusException; use Czim\JsonApi\Test\TestCase; -use Illuminate\Http\Exception\HttpResponseException; +use Illuminate\Http\Exceptions\HttpResponseException; use Mockery; /** From b0c9c4c2e8e8c18a00fccb0a6e3262dc7c9d9c59 Mon Sep 17 00:00:00 2001 From: Coen Zimmerman Date: Sat, 15 Apr 2017 22:44:39 +0200 Subject: [PATCH 5/9] Updated tests for new call/response handling --- .../Request/JsonApiRequestTest.php | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/Integration/Request/JsonApiRequestTest.php b/tests/Integration/Request/JsonApiRequestTest.php index 9dcf30c..8e91a80 100644 --- a/tests/Integration/Request/JsonApiRequestTest.php +++ b/tests/Integration/Request/JsonApiRequestTest.php @@ -24,14 +24,14 @@ public function getEnvironmentSetUp($app) */ function it_does_not_validate_get_request_parameters_against_json_schema() { - $this->call( + $response = $this->call( 'GET', 'request?page[number]=44' ); - $this->assertResponseStatus(200); + $response->assertStatus(200); - $data = json_decode($this->response->content(), true); + $data = json_decode($response->content(), true); static::assertEquals(44, $data['query-page-number']); } @@ -41,15 +41,15 @@ function it_does_not_validate_get_request_parameters_against_json_schema() */ function it_parses_query_string_data() { - $this->call( + $response = $this->call( 'POST', 'request?page[number]=44', $this->getValidRequestData() ); - $this->assertResponseStatus(200); + $response->assertStatus(200); - $data = json_decode($this->response->content(), true); + $data = json_decode($response->content(), true); static::assertEquals(44, $data['query-page-number']); } @@ -59,9 +59,9 @@ function it_parses_query_string_data() */ function it_returns_a_422_response_for_invalid_request_data() { - $this->call('POST', 'request', ['test']); + $response = $this->call('POST', 'request', ['test']); - $this->assertResponseStatus(422); + $response->assertStatus(422); } /** @@ -69,15 +69,15 @@ function it_returns_a_422_response_for_invalid_request_data() */ function it_parses_valid_request_data() { - $this->call( + $response = $this->call( 'POST', 'request', $this->getValidRequestData() ); - $this->assertResponseStatus(200); + $response->assertStatus(200); - $data = json_decode($this->response->content(), true); + $data = json_decode($response->content(), true); static::assertInternalType('array', $data, 'Invalid JSON returned'); static::assertEquals(RootType::RESOURCE, $data['data-root-type']); @@ -88,15 +88,15 @@ function it_parses_valid_request_data() */ function it_parses_valid_create_data() { - $this->call( + $response = $this->call( 'POST', 'create', $this->getValidCreateData() ); - $this->assertResponseStatus(200); + $response->assertStatus(200); - $data = json_decode($this->response->content(), true); + $data = json_decode($response->content(), true); static::assertInternalType('array', $data, 'Invalid JSON returned'); static::assertEquals(RootType::RESOURCE, $data['data-root-type']); From 380ba7279a89c331ff50a79cf8c1da989b7a045a Mon Sep 17 00:00:00 2001 From: Coen Zimmerman Date: Sat, 15 Apr 2017 22:44:52 +0200 Subject: [PATCH 6/9] Updated dependencies for 5.4 --- composer.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index a68b943..1247593 100644 --- a/composer.json +++ b/composer.json @@ -17,17 +17,18 @@ } ], "require": { - "php": ">=5.6.0", + "php": ">=5.6.4", "czim/laravel-dataobject": "^1.0", "myclabs/php-enum": "^1.5", "doctrine/dbal": "^2.5", "justinrainbow/json-schema": "^5.2" }, "require-dev": { - "phpunit/phpunit": "5.*", + "phpunit/phpunit": "~5.7", "mockery/mockery": "0.9.*", "scrutinizer/ocular": "~1.1", - "orchestra/testbench": "3.3.*", + "orchestra/testbench": "~3.4", + "orchestra/database": "~3.4", "satooshi/php-coveralls": "^1.0" }, "autoload": { From 8d719ea16319738eabb727e7166e5cd162eb7e2d Mon Sep 17 00:00:00 2001 From: Coen Zimmerman Date: Sat, 15 Apr 2017 22:43:45 +0200 Subject: [PATCH 7/9] Updated changed namespace for http response exception --- src/Encoder/Transformers/ExceptionTransformer.php | 4 ++-- src/Http/Requests/JsonApiRequest.php | 2 +- tests/Encoder/Transformers/ExceptionTransformerTest.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Encoder/Transformers/ExceptionTransformer.php b/src/Encoder/Transformers/ExceptionTransformer.php index d9a979b..3c82b5d 100644 --- a/src/Encoder/Transformers/ExceptionTransformer.php +++ b/src/Encoder/Transformers/ExceptionTransformer.php @@ -50,8 +50,8 @@ protected function convertExceptionToErrorData(Exception $exception) protected function getStatusCode(Exception $exception) { // special case: fully formed response exception (laravel 5.2 validation) - if (is_a($exception, \Illuminate\Http\Exception\HttpResponseException::class)) { - /** @var \Illuminate\Http\Exception\HttpResponseException $exception */ + if (is_a($exception, \Illuminate\Http\Exceptions\HttpResponseException::class)) { + /** @var \Illuminate\Http\Exceptions\HttpResponseException $exception */ return $exception->getResponse()->getStatusCode(); } diff --git a/src/Http/Requests/JsonApiRequest.php b/src/Http/Requests/JsonApiRequest.php index 3a56e93..08b776c 100644 --- a/src/Http/Requests/JsonApiRequest.php +++ b/src/Http/Requests/JsonApiRequest.php @@ -5,7 +5,7 @@ use Czim\JsonApi\Data\Root; use Czim\JsonApi\Support\Request\RequestQueryParser; use Illuminate\Foundation\Http\FormRequest; -use Illuminate\Http\Exception\HttpResponseException; +use Illuminate\Http\Exceptions\HttpResponseException; class JsonApiRequest extends FormRequest { diff --git a/tests/Encoder/Transformers/ExceptionTransformerTest.php b/tests/Encoder/Transformers/ExceptionTransformerTest.php index dec4908..9f815c8 100644 --- a/tests/Encoder/Transformers/ExceptionTransformerTest.php +++ b/tests/Encoder/Transformers/ExceptionTransformerTest.php @@ -5,7 +5,7 @@ use Czim\JsonApi\Encoder\Transformers\ExceptionTransformer; use Czim\JsonApi\Test\Helpers\Exceptions\TestStatusException; use Czim\JsonApi\Test\TestCase; -use Illuminate\Http\Exception\HttpResponseException; +use Illuminate\Http\Exceptions\HttpResponseException; use Mockery; /** From 9404533d0e2d0129245ce3d26bf8607ed54fb730 Mon Sep 17 00:00:00 2001 From: Coen Zimmerman Date: Sat, 15 Apr 2017 22:44:39 +0200 Subject: [PATCH 8/9] Updated tests for new call/response handling --- .../Request/JsonApiRequestTest.php | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/Integration/Request/JsonApiRequestTest.php b/tests/Integration/Request/JsonApiRequestTest.php index 9dcf30c..8e91a80 100644 --- a/tests/Integration/Request/JsonApiRequestTest.php +++ b/tests/Integration/Request/JsonApiRequestTest.php @@ -24,14 +24,14 @@ public function getEnvironmentSetUp($app) */ function it_does_not_validate_get_request_parameters_against_json_schema() { - $this->call( + $response = $this->call( 'GET', 'request?page[number]=44' ); - $this->assertResponseStatus(200); + $response->assertStatus(200); - $data = json_decode($this->response->content(), true); + $data = json_decode($response->content(), true); static::assertEquals(44, $data['query-page-number']); } @@ -41,15 +41,15 @@ function it_does_not_validate_get_request_parameters_against_json_schema() */ function it_parses_query_string_data() { - $this->call( + $response = $this->call( 'POST', 'request?page[number]=44', $this->getValidRequestData() ); - $this->assertResponseStatus(200); + $response->assertStatus(200); - $data = json_decode($this->response->content(), true); + $data = json_decode($response->content(), true); static::assertEquals(44, $data['query-page-number']); } @@ -59,9 +59,9 @@ function it_parses_query_string_data() */ function it_returns_a_422_response_for_invalid_request_data() { - $this->call('POST', 'request', ['test']); + $response = $this->call('POST', 'request', ['test']); - $this->assertResponseStatus(422); + $response->assertStatus(422); } /** @@ -69,15 +69,15 @@ function it_returns_a_422_response_for_invalid_request_data() */ function it_parses_valid_request_data() { - $this->call( + $response = $this->call( 'POST', 'request', $this->getValidRequestData() ); - $this->assertResponseStatus(200); + $response->assertStatus(200); - $data = json_decode($this->response->content(), true); + $data = json_decode($response->content(), true); static::assertInternalType('array', $data, 'Invalid JSON returned'); static::assertEquals(RootType::RESOURCE, $data['data-root-type']); @@ -88,15 +88,15 @@ function it_parses_valid_request_data() */ function it_parses_valid_create_data() { - $this->call( + $response = $this->call( 'POST', 'create', $this->getValidCreateData() ); - $this->assertResponseStatus(200); + $response->assertStatus(200); - $data = json_decode($this->response->content(), true); + $data = json_decode($response->content(), true); static::assertInternalType('array', $data, 'Invalid JSON returned'); static::assertEquals(RootType::RESOURCE, $data['data-root-type']); From db0235fc61fb3e76eb0d84083e81d6a22f7db93e Mon Sep 17 00:00:00 2001 From: Coen Zimmerman Date: Sat, 15 Apr 2017 22:44:52 +0200 Subject: [PATCH 9/9] Updated dependencies for 5.4 --- composer.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index a68b943..1247593 100644 --- a/composer.json +++ b/composer.json @@ -17,17 +17,18 @@ } ], "require": { - "php": ">=5.6.0", + "php": ">=5.6.4", "czim/laravel-dataobject": "^1.0", "myclabs/php-enum": "^1.5", "doctrine/dbal": "^2.5", "justinrainbow/json-schema": "^5.2" }, "require-dev": { - "phpunit/phpunit": "5.*", + "phpunit/phpunit": "~5.7", "mockery/mockery": "0.9.*", "scrutinizer/ocular": "~1.1", - "orchestra/testbench": "3.3.*", + "orchestra/testbench": "~3.4", + "orchestra/database": "~3.4", "satooshi/php-coveralls": "^1.0" }, "autoload": {