From 6f31208e4392a1abd26c4766a24df6d0ff451556 Mon Sep 17 00:00:00 2001 From: Mike Barlow Date: Wed, 4 Sep 2024 22:19:16 +0100 Subject: [PATCH 1/4] Added Laravel 11 support --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0aadabc..175901a 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ } ], "require": { - "illuminate/http": "~5.0|~6.0|~7.0|~8.0|~9.0|~10.0" + "illuminate/http": "~5.0|~6.0|~7.0|~8.0|~9.0|~10.0|~11.0" }, "require-dev": { "phpunit/phpunit": "^10.0", From 794cb27fa7667f0491753e7005e680c60639d3f4 Mon Sep 17 00:00:00 2001 From: Mike Barlow Date: Wed, 4 Sep 2024 22:20:43 +0100 Subject: [PATCH 2/4] changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 147b132..b8681ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to `mbarlow/laravel-response-helpers` will be documented in this file +## 2.3.0 - 2024-09-04 + +- Added support for Laravel 11. [#5](https://github.com/mikebarlow/laravel-response-helpers/pull/5) + ## 2.2.0 - 2023-05-22 - Added support for Laravel 10. [#4](https://github.com/mikebarlow/laravel-response-helpers/pull/4) From eca5081861ef566c33c992d968ff4e00dceb3728 Mon Sep 17 00:00:00 2001 From: Mike Barlow Date: Wed, 4 Sep 2024 22:46:54 +0100 Subject: [PATCH 3/4] Updated tests --- composer.json | 4 +- phpunit.xml | 8 ++- tests/ContentTest.php | 10 +--- tests/ResponsesTest.php | 130 ++++++++-------------------------------- 4 files changed, 37 insertions(+), 115 deletions(-) diff --git a/composer.json b/composer.json index 175901a..85ddfc4 100644 --- a/composer.json +++ b/composer.json @@ -13,9 +13,9 @@ "illuminate/http": "~5.0|~6.0|~7.0|~8.0|~9.0|~10.0|~11.0" }, "require-dev": { - "phpunit/phpunit": "^10.0", + "phpunit/phpunit": "^10.5 || ^11.0.1", "squizlabs/php_codesniffer": "^3.5", - "orchestra/testbench": "^8.0" + "orchestra/testbench": "^8.0 || ^9.0" }, "autoload": { "files": [ diff --git a/phpunit.xml b/phpunit.xml index 9080a51..c3ec91e 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,5 +1,11 @@ - + diff --git a/tests/ContentTest.php b/tests/ContentTest.php index 12e35d4..702038b 100644 --- a/tests/ContentTest.php +++ b/tests/ContentTest.php @@ -6,10 +6,7 @@ class ContentTest extends TestCase { - /** - * @test - */ - public function strings_and_arrays_pass_through() + public function testStringsAndArraysPassThrough(): void { $string = 'This is the output'; $array = [ @@ -28,10 +25,7 @@ public function strings_and_arrays_pass_through() ); } - /** - * @test - */ - public function can_transform_json_resource() + public function testItCanTransformJsonResource(): void { $resource = new MyResource([ 'test1' => 'This is a test', diff --git a/tests/ResponsesTest.php b/tests/ResponsesTest.php index 13e1693..dcd64d0 100644 --- a/tests/ResponsesTest.php +++ b/tests/ResponsesTest.php @@ -7,10 +7,7 @@ class ResponsesTest extends TestCase { - /** - * @test - */ - public function can_return_200_ok() + public function testItCanReturn200Ok(): void { $response = ok(['message' => 'ok'], ['x-custom-header' => 'test']); @@ -20,10 +17,7 @@ public function can_return_200_ok() $this->assertSame('test', $response->headers->get('x-custom-header')); } - /** - * @test - */ - public function can_return_201_created() + public function testItCanReturn201Created(): void { $response = created(['message' => 'created'], ['x-custom-header' => 'test']); @@ -33,10 +27,7 @@ public function can_return_201_created() $this->assertSame('test', $response->headers->get('x-custom-header')); } - /** - * @test - */ - public function can_return_202_accepted() + public function testItCanReturn202Accepted(): void { $response = accepted(['message' => 'accepted'], ['x-custom-header' => 'test']); @@ -46,10 +37,7 @@ public function can_return_202_accepted() $this->assertSame('test', $response->headers->get('x-custom-header')); } - /** - * @test - */ - public function can_return_204_no_content() + public function testItCanReturn204NoContent(): void { $response = noContent(['x-custom-header' => 'test']); @@ -58,10 +46,7 @@ public function can_return_204_no_content() $this->assertSame('test', $response->headers->get('x-custom-header')); } - /** - * @test - */ - public function can_return_301_moved_permanently() + public function testItCanReturn301MovedPermanently(): void { $response = movedPermanently('https://example.com/new-url', ['x-custom-header' => 'test']); @@ -71,10 +56,7 @@ public function can_return_301_moved_permanently() $this->assertSame('https://example.com/new-url', $response->headers->get('Location')); } - /** - * @test - */ - public function can_return_302_found() + public function testItCanReturn302Found(): void { $response = found('https://example.com/url', ['x-custom-header' => 'test']); @@ -84,10 +66,7 @@ public function can_return_302_found() $this->assertSame('https://example.com/url', $response->headers->get('Location')); } - /** - * @test - */ - public function can_return_303_see_other() + public function testItCanReturn303SeeOther(): void { $response = seeOther('https://example.com/new-url', ['x-custom-header' => 'test']); @@ -97,10 +76,7 @@ public function can_return_303_see_other() $this->assertSame('https://example.com/new-url', $response->headers->get('Location')); } - /** - * @test - */ - public function can_return_307_temporary_redirect() + public function testItCanReturn307TemporaryRedirect(): void { $response = temporaryRedirect('https://example.com/new-url', ['x-custom-header' => 'test']); @@ -110,10 +86,7 @@ public function can_return_307_temporary_redirect() $this->assertSame('https://example.com/new-url', $response->headers->get('Location')); } - /** - * @test - */ - public function can_return_400_bad_request() + public function testItCanReturn400BadRequest(): void { $response = badRequest(['message' => 'bad request'], ['x-custom-header' => 'test']); @@ -123,10 +96,7 @@ public function can_return_400_bad_request() $this->assertSame('test', $response->headers->get('x-custom-header')); } - /** - * @test - */ - public function can_return_401_unauthorized() + public function testItCanReturn401Unauthorized(): void { $response = unauthorized(['message' => 'unauthorized'], ['x-custom-header' => 'test']); @@ -136,10 +106,7 @@ public function can_return_401_unauthorized() $this->assertSame('test', $response->headers->get('x-custom-header')); } - /** - * @test - */ - public function can_return_402_payment_required() + public function testItCanReturn402PaymentRequired(): void { $response = paymentRequired(['message' => 'payment required'], ['x-custom-header' => 'test']); @@ -149,10 +116,7 @@ public function can_return_402_payment_required() $this->assertSame('test', $response->headers->get('x-custom-header')); } - /** - * @test - */ - public function can_return_403_forbidden() + public function testItCanReturn403Forbidden(): void { $response = forbidden(['message' => 'forbidden'], ['x-custom-header' => 'test']); @@ -162,10 +126,7 @@ public function can_return_403_forbidden() $this->assertSame('test', $response->headers->get('x-custom-header')); } - /** - * @test - */ - public function can_return_404_not_found() + public function testItCanReturn404NotFound(): void { $response = notFound(['message' => 'not found'], ['x-custom-header' => 'test']); @@ -175,10 +136,7 @@ public function can_return_404_not_found() $this->assertSame('test', $response->headers->get('x-custom-header')); } - /** - * @test - */ - public function can_return_405_method_not_allowed() + public function testItCanReturn405MethodNotAllowed(): void { $response = methodNotAllowed(['message' => 'method not allowed'], ['x-custom-header' => 'test']); @@ -188,10 +146,7 @@ public function can_return_405_method_not_allowed() $this->assertSame('test', $response->headers->get('x-custom-header')); } - /** - * @test - */ - public function can_return_406_not_acceptable() + public function testItCanReturn406NotAcceptable(): void { $response = notAcceptable(['message' => 'not acceptable'], ['x-custom-header' => 'test']); @@ -201,10 +156,7 @@ public function can_return_406_not_acceptable() $this->assertSame('test', $response->headers->get('x-custom-header')); } - /** - * @test - */ - public function can_return_410_gone() + public function testItCanReturn410Gone(): void { $response = gone(['message' => 'gone'], ['x-custom-header' => 'test']); @@ -214,10 +166,7 @@ public function can_return_410_gone() $this->assertSame('test', $response->headers->get('x-custom-header')); } - /** - * @test - */ - public function can_return_413_payload_too_large() + public function testItCanReturn413PayloadTooLarge(): void { $response = payloadTooLarge(['message' => 'payload too large'], ['x-custom-header' => 'test']); @@ -227,10 +176,7 @@ public function can_return_413_payload_too_large() $this->assertSame('test', $response->headers->get('x-custom-header')); } - /** - * @test - */ - public function can_return_422_unprocessable_entity() + public function testItCanReturn422UnprocessableEntity(): void { $response = unprocessableEntity(['message' => 'unprocessable entity'], ['x-custom-header' => 'test']); @@ -240,10 +186,7 @@ public function can_return_422_unprocessable_entity() $this->assertSame('test', $response->headers->get('x-custom-header')); } - /** - * @test - */ - public function can_return_426_upgrade_required() + public function testItCanReturn426UpgradeRequired(): void { $response = upgradeRequired(['message' => 'upgrade required'], ['x-custom-header' => 'test']); @@ -253,10 +196,7 @@ public function can_return_426_upgrade_required() $this->assertSame('test', $response->headers->get('x-custom-header')); } - /** - * @test - */ - public function can_return_429_too_many_requests() + public function testItCanReturn429TooManyRequests(): void { $response = tooManyRequests(['message' => 'too many requests'], ['x-custom-header' => 'test']); @@ -266,10 +206,7 @@ public function can_return_429_too_many_requests() $this->assertSame('test', $response->headers->get('x-custom-header')); } - /** - * @test - */ - public function can_return_500_internal_server_error() + public function testItCanReturn500InternalServerError(): void { $response = internalServerError(['message' => 'internal server error'], ['x-custom-header' => 'test']); @@ -279,10 +216,7 @@ public function can_return_500_internal_server_error() $this->assertSame('test', $response->headers->get('x-custom-header')); } - /** - * @test - */ - public function can_return_501_not_implemented() + public function testItCanReturn501NotImplemented(): void { $response = notImplemented(['message' => 'not implemented'], ['x-custom-header' => 'test']); @@ -292,10 +226,7 @@ public function can_return_501_not_implemented() $this->assertSame('test', $response->headers->get('x-custom-header')); } - /** - * @test - */ - public function can_return_502_bad_gateway() + public function testItCanReturn502BadGateway(): void { $response = badGateway(['message' => 'bad gateway'], ['x-custom-header' => 'test']); @@ -305,10 +236,7 @@ public function can_return_502_bad_gateway() $this->assertSame('test', $response->headers->get('x-custom-header')); } - /** - * @test - */ - public function can_return_503_service_unavailable() + public function testItCanReturn503ServiceUnavailable(): void { $response = serviceUnavailable(['message' => 'service unavailable'], ['x-custom-header' => 'test']); @@ -318,10 +246,7 @@ public function can_return_503_service_unavailable() $this->assertSame('test', $response->headers->get('x-custom-header')); } - /** - * @test - */ - public function can_return_504_gateway_timeout() + public function testItCanReturn504GatewayTimeout(): void { $response = gatewayTimeout(['message' => 'gateway timeout'], ['x-custom-header' => 'test']); @@ -331,10 +256,7 @@ public function can_return_504_gateway_timeout() $this->assertSame('test', $response->headers->get('x-custom-header')); } - /** - * @test - */ - public function can_return_507_insufficient_storage() + public function testItCanReturn507InsufficientStorage(): void { $response = insufficientStorage(['message' => 'insufficient storage'], ['x-custom-header' => 'test']); From 8d6d3f06aac110ad034ca426f5a3c5dcdfc22703 Mon Sep 17 00:00:00 2001 From: Mike Barlow Date: Wed, 4 Sep 2024 22:48:32 +0100 Subject: [PATCH 4/4] changelog update --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8681ad..27363e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes to `mbarlow/laravel-response-helpers` will be documented in ## 2.3.0 - 2024-09-04 - Added support for Laravel 11. [#5](https://github.com/mikebarlow/laravel-response-helpers/pull/5) +- Updated Tests and test dependencies ## 2.2.0 - 2023-05-22