Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Laravel 11 support #5

Merged
merged 4 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

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)
- Updated Tests and test dependencies

## 2.2.0 - 2023-05-22

- Added support for Laravel 10. [#4](https://github.com/mikebarlow/laravel-response-helpers/pull/4)
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
}
],
"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",
"phpunit/phpunit": "^10.5 || ^11.0.1",
"squizlabs/php_codesniffer": "^3.5",
"orchestra/testbench": "^8.0"
"orchestra/testbench": "^8.0 || ^9.0"
},
"autoload": {
"files": [
Expand Down
8 changes: 7 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" cacheDirectory=".phpunit.cache">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="vendor/autoload.php" cacheDirectory=".phpunit.cache"
displayDetailsOnIncompleteTests="true"
displayDetailsOnSkippedTests="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true" >
<coverage/>
<testsuites>
<testsuite name="mbarlow/laravel-response-helpers tests">
Expand Down
10 changes: 2 additions & 8 deletions tests/ContentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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',
Expand Down
130 changes: 26 additions & 104 deletions tests/ResponsesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);

Expand All @@ -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']);

Expand All @@ -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']);

Expand All @@ -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']);

Expand All @@ -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']);

Expand All @@ -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']);

Expand All @@ -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']);

Expand All @@ -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']);

Expand All @@ -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']);

Expand All @@ -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']);

Expand All @@ -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']);

Expand All @@ -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']);

Expand All @@ -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']);

Expand All @@ -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']);

Expand All @@ -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']);

Expand All @@ -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']);

Expand All @@ -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']);

Expand All @@ -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']);

Expand All @@ -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']);

Expand All @@ -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']);

Expand All @@ -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']);

Expand All @@ -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']);

Expand All @@ -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']);

Expand All @@ -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']);

Expand All @@ -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']);

Expand All @@ -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']);

Expand Down