diff --git a/composer.json b/composer.json index ea1e45b..2716006 100644 --- a/composer.json +++ b/composer.json @@ -12,11 +12,12 @@ "homepage": "https://github.com/werk365/etagconditionals", "keywords": ["Laravel", "EtagConditionals"], "require": { - "illuminate/support": "~7|~8|~9|~10" + "php": "^8.2", + "illuminate/support": "^10.0|^11.0|^12.0" }, "require-dev": { - "phpunit/phpunit": "~8.0|~9.0", - "orchestra/testbench": "~5|~6|~7|~8" + "phpunit/phpunit": "^10.5|^11.0", + "orchestra/testbench": "^8.0|^9.0|^10.0" }, "autoload": { "psr-4": { diff --git a/tests/EtagConditionalsTest.php b/tests/EtagConditionalsTest.php index 92dc642..16a83d2 100644 --- a/tests/EtagConditionalsTest.php +++ b/tests/EtagConditionalsTest.php @@ -4,6 +4,7 @@ use Illuminate\Http\Request; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\Test; use Symfony\Component\HttpFoundation\Response; use Werk365\EtagConditionals\EtagConditionals; @@ -14,9 +15,10 @@ class EtagConditionalsTest extends TestCase public function tearDown(): void { EtagConditionals::etagGenerateUsing(null); + parent::tearDown(); } - /** @test */ + #[Test] public function get_default_etag() { $request = Request::create('/', 'GET'); @@ -25,7 +27,7 @@ public function get_default_etag() $this->assertEquals('"e0aa021e21dddbd6d8cecec71e9cf564"', EtagConditionals::getEtag($request, $response)); } - /** @test */ + #[Test] public function get_etag_with_callback_md5() { $request = Request::create('/', 'GET'); @@ -38,7 +40,7 @@ public function get_etag_with_callback_md5() $this->assertEquals('"e0aa021e21dddbd6d8cecec71e9cf564"', EtagConditionals::getEtag($request, $response)); } - /** @test */ + #[Test] public function get_etag_with_callback_sophisticated() { $request = Request::create('/', 'GET'); @@ -51,7 +53,7 @@ public function get_etag_with_callback_sophisticated() $this->assertEquals('"sophisticated"', EtagConditionals::getEtag($request, $response)); } - /** @test */ + #[Test] public function get_etag_with_callback_with_quotes() { $request = Request::create('/', 'GET'); diff --git a/tests/IfMatchTest.php b/tests/IfMatchTest.php index bceafa9..b069191 100644 --- a/tests/IfMatchTest.php +++ b/tests/IfMatchTest.php @@ -3,7 +3,9 @@ namespace Werk365\EtagConditionals\Tests; use Illuminate\Support\Facades\Config; +use Illuminate\Support\Facades\Route; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\Test; use Werk365\EtagConditionals\Middleware\IfMatch; class IfMatchTest extends TestCase @@ -14,12 +16,12 @@ public function setUp(): void { parent::setUp(); - \Route::middleware(IfMatch::class)->any('/_test/if-match', function () { + Route::middleware(IfMatch::class)->any('/_test/if-match', function () { return response($this->response, 200); }); } - /** @test */ + #[Test] public function patch_request_returns_200_if_matching_IfMatch() { $ifMatch = '"'.md5($this->response).'"'; @@ -31,7 +33,7 @@ public function patch_request_returns_200_if_matching_IfMatch() $response->assertStatus(200); } - /** @test */ + #[Test] public function patch_request_returns_200_if_matching_IfMatch_in_list_of_etags() { $ifMatch = '"'.md5('first').'", "'.md5($this->response).'","'.md5('last').'"'; @@ -43,7 +45,7 @@ public function patch_request_returns_200_if_matching_IfMatch_in_list_of_etags() $response->assertStatus(200); } - /** @test */ + #[Test] public function patch_request_returns_200_if_wildcard_is_used() { $ifMatch = '"'.md5('first').'", "*","'.md5('last').'"'; @@ -55,7 +57,7 @@ public function patch_request_returns_200_if_wildcard_is_used() $response->assertStatus(200); } - /** @test */ + #[Test] public function patch_request_returns_412_if_none_matching_IfMatch() { $ifMatch = '"'.md5($this->response.'ifMatch').'"'; @@ -67,7 +69,7 @@ public function patch_request_returns_412_if_none_matching_IfMatch() $response->assertStatus(412); } - /** @test */ + #[Test] public function patch_request_returns_412_if_none_matching_IfMatch_in_list_of_etags() { $ifMatch = '"'.md5('first').'", "'.md5($this->response.'ifMatch').'","'.md5('last').'"'; @@ -79,7 +81,7 @@ public function patch_request_returns_412_if_none_matching_IfMatch_in_list_of_et $response->assertStatus(412); } - /** @test */ + #[Test] public function patch_request_returns_200_if_matching_weaktag_when_weak_is_enabled_in_config() { Config::set('etagconditionals.if_match_weak', true); diff --git a/tests/IfNoneMatchTest.php b/tests/IfNoneMatchTest.php index ec3091e..faf5c0e 100644 --- a/tests/IfNoneMatchTest.php +++ b/tests/IfNoneMatchTest.php @@ -3,7 +3,9 @@ namespace Werk365\EtagConditionals\Tests; use Illuminate\Support\Facades\Config; +use Illuminate\Support\Facades\Route; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\Test; use Werk365\EtagConditionals\Middleware\IfNoneMatch; class IfNoneMatchTest extends TestCase @@ -14,12 +16,12 @@ public function setUp(): void { parent::setUp(); - \Route::middleware(IfNoneMatch::class)->any('/_test/if-none-match', function () { + Route::middleware(IfNoneMatch::class)->any('/_test/if-none-match', function () { return response($this->response, 200); }); } - /** @test */ + #[Test] public function get_request_status_200_with_none_matching_IfNoneMatch() { $noneMatch = '"'.md5($this->response.'NoneMatch').'"'; @@ -31,7 +33,7 @@ public function get_request_status_200_with_none_matching_IfNoneMatch() $response->assertStatus(200); } - /** @test */ + #[Test] public function get_request_status_304_with_matching_IfNoneMatch() { $noneMatch = '"'.md5($this->response).'"'; @@ -43,7 +45,7 @@ public function get_request_status_304_with_matching_IfNoneMatch() $response->assertStatus(304); } - /** @test */ + #[Test] public function get_request_status_200_with_matching_weaktag_if_weak_is_disabled_in_config() { Config::set('etagconditionals.if_none_match_weak', false); @@ -56,7 +58,7 @@ public function get_request_status_200_with_matching_weaktag_if_weak_is_disabled $response->assertStatus(200); } - /** @test */ + #[Test] public function get_request_status_304_with_matching_weaktag_if_weak_is_enabled_in_config() { Config::set('etagconditionals.if_none_match_weak', true); diff --git a/tests/SetEtagTest.php b/tests/SetEtagTest.php index 2dacba7..a18d4ee 100644 --- a/tests/SetEtagTest.php +++ b/tests/SetEtagTest.php @@ -2,7 +2,9 @@ namespace Werk365\EtagConditionals\Tests; +use Illuminate\Support\Facades\Route; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\Test; use Werk365\EtagConditionals\Middleware\SetEtag; class SetEtagTest extends TestCase @@ -13,19 +15,19 @@ public function setUp(): void { parent::setUp(); - \Route::middleware(SetEtag::class)->any('/_test/set-etag', function () { + Route::middleware(SetEtag::class)->any('/_test/set-etag', function () { return $this->response; }); } - /** @test */ + #[Test] public function middleware_sets_etag_header() { $response = $this->get('/_test/set-etag'); $response->assertHeader('ETag', $value = null); } - /** @test */ + #[Test] public function etag_header_has_correct_value() { $value = '"'.md5($this->response).'"';