diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 4b34db1..7a0aa8e 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,7 +1,7 @@ build: environment: php: - version: 8.1 + version: 8.3.28 nodes: analysis: project_setup: diff --git a/composer.json b/composer.json index 9fcbf13..0622705 100644 --- a/composer.json +++ b/composer.json @@ -10,13 +10,16 @@ } ], "homepage": "https://github.com/werk365/etagconditionals", - "keywords": ["Laravel", "EtagConditionals"], + "keywords": [ + "Laravel", + "EtagConditionals" + ], "require": { - "illuminate/support": "~7|~8|~9|~10|~11|~12" + "illuminate/support": "~7|~8|~9|~10|~11|~12|^13.0" }, "require-dev": { - "phpunit/phpunit": "~8.0|~9.0", - "orchestra/testbench": "~5|~6|~7|~8" + "phpunit/phpunit": "^12.0", + "orchestra/testbench": "~5|~6|~7|~8|^11.0" }, "autoload": { "psr-4": { diff --git a/tests/EtagConditionalsTest.php b/tests/EtagConditionalsTest.php index 92dc642..8e38369 100644 --- a/tests/EtagConditionalsTest.php +++ b/tests/EtagConditionalsTest.php @@ -4,20 +4,21 @@ use Illuminate\Http\Request; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\Test; use Symfony\Component\HttpFoundation\Response; use Werk365\EtagConditionals\EtagConditionals; -class EtagConditionalsTest extends TestCase +final class EtagConditionalsTest extends TestCase { private string $response = 'OK'; - public function tearDown(): void + protected function tearDown(): void { EtagConditionals::etagGenerateUsing(null); } - /** @test */ - public function get_default_etag() + #[Test] + public function get_default_etag(): void { $request = Request::create('/', 'GET'); $response = response($this->response, 200); @@ -25,8 +26,8 @@ public function get_default_etag() $this->assertEquals('"e0aa021e21dddbd6d8cecec71e9cf564"', EtagConditionals::getEtag($request, $response)); } - /** @test */ - public function get_etag_with_callback_md5() + #[Test] + public function get_etag_with_callback_md5(): void { $request = Request::create('/', 'GET'); $response = response($this->response, 200); @@ -38,8 +39,8 @@ public function get_etag_with_callback_md5() $this->assertEquals('"e0aa021e21dddbd6d8cecec71e9cf564"', EtagConditionals::getEtag($request, $response)); } - /** @test */ - public function get_etag_with_callback_sophisticated() + #[Test] + public function get_etag_with_callback_sophisticated(): void { $request = Request::create('/', 'GET'); $response = response($this->response, 200); @@ -51,8 +52,8 @@ public function get_etag_with_callback_sophisticated() $this->assertEquals('"sophisticated"', EtagConditionals::getEtag($request, $response)); } - /** @test */ - public function get_etag_with_callback_with_quotes() + #[Test] + public function get_etag_with_callback_with_quotes(): void { $request = Request::create('/', 'GET'); $response = response($this->response, 200); diff --git a/tests/IfMatchTest.php b/tests/IfMatchTest.php index bceafa9..57625c3 100644 --- a/tests/IfMatchTest.php +++ b/tests/IfMatchTest.php @@ -4,13 +4,14 @@ use Illuminate\Support\Facades\Config; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\Test; use Werk365\EtagConditionals\Middleware\IfMatch; -class IfMatchTest extends TestCase +final class IfMatchTest extends TestCase { private string $response = 'OK'; - public function setUp(): void + protected function setUp(): void { parent::setUp(); @@ -19,8 +20,8 @@ public function setUp(): void }); } - /** @test */ - public function patch_request_returns_200_if_matching_IfMatch() + #[Test] + public function patch_request_returns_200_if_matching_IfMatch(): void { $ifMatch = '"'.md5($this->response).'"'; $response = $this->withHeaders([ @@ -31,8 +32,8 @@ public function patch_request_returns_200_if_matching_IfMatch() $response->assertStatus(200); } - /** @test */ - public function patch_request_returns_200_if_matching_IfMatch_in_list_of_etags() + #[Test] + public function patch_request_returns_200_if_matching_IfMatch_in_list_of_etags(): void { $ifMatch = '"'.md5('first').'", "'.md5($this->response).'","'.md5('last').'"'; $response = $this->withHeaders([ @@ -43,8 +44,8 @@ public function patch_request_returns_200_if_matching_IfMatch_in_list_of_etags() $response->assertStatus(200); } - /** @test */ - public function patch_request_returns_200_if_wildcard_is_used() + #[Test] + public function patch_request_returns_200_if_wildcard_is_used(): void { $ifMatch = '"'.md5('first').'", "*","'.md5('last').'"'; $response = $this->withHeaders([ @@ -55,8 +56,8 @@ public function patch_request_returns_200_if_wildcard_is_used() $response->assertStatus(200); } - /** @test */ - public function patch_request_returns_412_if_none_matching_IfMatch() + #[Test] + public function patch_request_returns_412_if_none_matching_IfMatch(): void { $ifMatch = '"'.md5($this->response.'ifMatch').'"'; $response = $this->withHeaders([ @@ -67,8 +68,8 @@ public function patch_request_returns_412_if_none_matching_IfMatch() $response->assertStatus(412); } - /** @test */ - public function patch_request_returns_412_if_none_matching_IfMatch_in_list_of_etags() + #[Test] + public function patch_request_returns_412_if_none_matching_IfMatch_in_list_of_etags(): void { $ifMatch = '"'.md5('first').'", "'.md5($this->response.'ifMatch').'","'.md5('last').'"'; $response = $this->withHeaders([ @@ -79,8 +80,8 @@ public function patch_request_returns_412_if_none_matching_IfMatch_in_list_of_et $response->assertStatus(412); } - /** @test */ - public function patch_request_returns_200_if_matching_weaktag_when_weak_is_enabled_in_config() + #[Test] + public function patch_request_returns_200_if_matching_weaktag_when_weak_is_enabled_in_config(): void { Config::set('etagconditionals.if_match_weak', true); $ifMatch = 'W/"'.md5($this->response).'"'; @@ -92,8 +93,8 @@ public function patch_request_returns_200_if_matching_weaktag_when_weak_is_enabl $response->assertStatus(200); } - /** @test */ - public function patch_request_returns_412_if_matching_weaktag_when_weak_is_disabled_in_config() + #[Test] + public function patch_request_returns_412_if_matching_weaktag_when_weak_is_disabled_in_config(): void { Config::set('etagconditionals.if_match_weak', false); $ifMatch = 'W/"'.md5($this->response).'"'; diff --git a/tests/IfNoneMatchTest.php b/tests/IfNoneMatchTest.php index ec3091e..f15ea18 100644 --- a/tests/IfNoneMatchTest.php +++ b/tests/IfNoneMatchTest.php @@ -4,13 +4,14 @@ use Illuminate\Support\Facades\Config; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\Test; use Werk365\EtagConditionals\Middleware\IfNoneMatch; -class IfNoneMatchTest extends TestCase +final class IfNoneMatchTest extends TestCase { private string $response = 'OK'; - public function setUp(): void + protected function setUp(): void { parent::setUp(); @@ -19,8 +20,8 @@ public function setUp(): void }); } - /** @test */ - public function get_request_status_200_with_none_matching_IfNoneMatch() + #[Test] + public function get_request_status_200_with_none_matching_IfNoneMatch(): void { $noneMatch = '"'.md5($this->response.'NoneMatch').'"'; $response = $this->withHeaders([ @@ -31,8 +32,8 @@ public function get_request_status_200_with_none_matching_IfNoneMatch() $response->assertStatus(200); } - /** @test */ - public function get_request_status_304_with_matching_IfNoneMatch() + #[Test] + public function get_request_status_304_with_matching_IfNoneMatch(): void { $noneMatch = '"'.md5($this->response).'"'; $response = $this->withHeaders([ @@ -43,8 +44,8 @@ public function get_request_status_304_with_matching_IfNoneMatch() $response->assertStatus(304); } - /** @test */ - public function get_request_status_200_with_matching_weaktag_if_weak_is_disabled_in_config() + #[Test] + public function get_request_status_200_with_matching_weaktag_if_weak_is_disabled_in_config(): void { Config::set('etagconditionals.if_none_match_weak', false); $noneMatch = 'W/"'.md5($this->response).'"'; @@ -56,8 +57,8 @@ public function get_request_status_200_with_matching_weaktag_if_weak_is_disabled $response->assertStatus(200); } - /** @test */ - public function get_request_status_304_with_matching_weaktag_if_weak_is_enabled_in_config() + #[Test] + public function get_request_status_304_with_matching_weaktag_if_weak_is_enabled_in_config(): void { Config::set('etagconditionals.if_none_match_weak', true); $noneMatch = 'W/"'.md5($this->response).'"'; diff --git a/tests/SetEtagTest.php b/tests/SetEtagTest.php index 2dacba7..0736deb 100644 --- a/tests/SetEtagTest.php +++ b/tests/SetEtagTest.php @@ -3,13 +3,14 @@ namespace Werk365\EtagConditionals\Tests; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\Test; use Werk365\EtagConditionals\Middleware\SetEtag; -class SetEtagTest extends TestCase +final class SetEtagTest extends TestCase { private string $response = 'OK'; - public function setUp(): void + protected function setUp(): void { parent::setUp(); @@ -18,15 +19,15 @@ public function setUp(): void }); } - /** @test */ - public function middleware_sets_etag_header() + #[Test] + public function middleware_sets_etag_header(): void { $response = $this->get('/_test/set-etag'); $response->assertHeader('ETag', $value = null); } - /** @test */ - public function etag_header_has_correct_value() + #[Test] + public function etag_header_has_correct_value(): void { $value = '"'.md5($this->response).'"'; $response = $this->get('/_test/set-etag');