diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 22fe8e3..8e8ac1e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,31 +8,44 @@ on: branches: - master +permissions: + contents: read + jobs: test: name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} runs-on: ${{ matrix.os }} - + strategy: fail-fast: true matrix: - # Disable testing on windows for now... - # os: [ubuntu-latest, windows-latest] os: [ubuntu-latest] - php: [7.4, 8.0, 8.1] - laravel: [8.*, 9.*] - #stability: [prefer-lowest, prefer-stable] + php: ["8.1", "8.2", "8.3", "8.4"] + laravel: [10.*, 11.*, 12.*, 13.*] stability: [prefer-stable] include: - - laravel: 8.* - testbench: ^6.6 - - laravel: 9.* - testbench: 7.* - # Laravel 7 has no support for PHP 8.1 + - laravel: 10.* + testbench: 8.* + - laravel: 11.* + testbench: 9.* + - laravel: 12.* + testbench: 10.* + - laravel: 13.* + testbench: 11.* exclude: - # Laravel 9 doesn't support < PHP 8 - - laravel: 9.* - php: 7.4 + # Laravel 10 supports PHP 8.1 - 8.3 + - laravel: 10.* + php: "8.4" + # Laravel 11 & 12 require PHP >= 8.2 + - laravel: 11.* + php: "8.1" + - laravel: 12.* + php: "8.1" + # Laravel 13 requires PHP >= 8.3 + - laravel: 13.* + php: "8.1" + - laravel: 13.* + php: "8.2" services: redis: @@ -43,13 +56,13 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo, redis coverage: none - name: Setup problem matchers @@ -58,7 +71,12 @@ jobs: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - name: Install dependencies run: | - composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update + # We intentionally test older, still-constraint-compatible Laravel releases + # (e.g. L10 is EOL) that may carry open Packagist advisories. Composer 2.9+ + # blocks advisory-flagged versions during resolution by default, so allow them + # here. This only affects the CI runner, not the published composer.json. + composer config audit.block-insecure false + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --dev --no-interaction --no-update composer update --${{ matrix.stability }} --prefer-dist --no-interaction - name: Execute tests - run: vendor/bin/phpunit \ No newline at end of file + run: vendor/bin/phpunit diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f50957..852f540 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,4 +11,10 @@ All notable changes to `swiftmade/playback` will be documented in this file - Fix lock key - Add a test case for the handling of race condition - Minor refactor and documentation improvements -- Remove predis dependency \ No newline at end of file +- Remove predis dependency + +## Unreleased + +- Add support for Laravel 10, 11, 12 and 13 +- Drop support for Laravel 8 and 9 (and PHP < 8.1) +- Upgrade test suite to PHPUnit 10/11/12 \ No newline at end of file diff --git a/README.md b/README.md index 4bc609a..6432d0f 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Playback gives you idempotent endpoints in Laravel, using Redis locks. [What's e ## Installation -> 💡 Supports Laravel 8.x, Laravel 9.x on PHP 7.4, 8.0 or 8.1 +> 💡 Supports Laravel 10.x, 11.x, 12.x and 13.x on PHP 8.1 – 8.4 1. You can install the package via composer: @@ -53,7 +53,7 @@ Open `config/cache.php` and add a new store. Just apply the `Swiftmade\Playback\Playback` middleware to your endpoints. There are many ways of doing it, so here's a link to the docs: -- https://laravel.com/docs/9.x/middleware +- https://laravel.com/docs/middleware ## Use diff --git a/composer.json b/composer.json index 8bb5c06..e7eeaff 100644 --- a/composer.json +++ b/composer.json @@ -16,14 +16,14 @@ } ], "require": { - "php": "^7.3|^8.0", - "illuminate/support": "^8.0|^9.0" + "php": "^8.1", + "illuminate/support": "^10.0|^11.0|^12.0|^13.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.9", - "orchestra/testbench": "^6.0|^7.0", - "phpunit/phpunit": "^9.0", - "spatie/async": "^1.5" + "friendsofphp/php-cs-fixer": "^3.64", + "orchestra/testbench": "^8.0|^9.0|^10.0|^11.0", + "phpunit/phpunit": "^10.5|^11.0|^12.0", + "spatie/async": "^1.6" }, "autoload": { "psr-4": { @@ -49,4 +49,4 @@ ] } } -} +} \ No newline at end of file diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 2dd1d48..e5ad4b5 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,12 +1,10 @@ - @@ -14,4 +12,9 @@ tests + + + src + + diff --git a/tests/PlaybackTest.php b/tests/PlaybackTest.php index de596e5..fa5cb48 100644 --- a/tests/PlaybackTest.php +++ b/tests/PlaybackTest.php @@ -5,6 +5,7 @@ use Spatie\Async\Pool; use Swiftmade\Playback\Recorder; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\Test; use Swiftmade\Playback\PlaybackServiceProvider; use Swiftmade\Playback\Tests\Support\TestServiceProvider; @@ -24,9 +25,7 @@ protected function tearDown(): void parent::tearDown(); } - /** - * @test - */ + #[Test] public function it_plays_back_post_requests() { $headers = [ @@ -55,9 +54,7 @@ public function it_plays_back_post_requests() ); } - /** - * @test - */ + #[Test] public function it_plays_back_internal_server_errors() { $headers = [ @@ -85,9 +82,7 @@ public function it_plays_back_internal_server_errors() ); } - /** - * @test - */ + #[Test] public function different_key_returns_different_response() { $headers = [ @@ -116,9 +111,7 @@ public function different_key_returns_different_response() ); } - /** - * @test - */ + #[Test] public function it_returns_400_if_headers_change() { $headers = [ @@ -137,9 +130,7 @@ public function it_returns_400_if_headers_change() $response2->assertStatus(400); } - /** - * @test - */ + #[Test] public function it_returns_400_if_body_changes() { $headers = [ @@ -158,9 +149,7 @@ public function it_returns_400_if_body_changes() $response2->assertStatus(400); } - /** - * @test - */ + #[Test] public function it_returns_400_if_query_parameters_change() { $headers = [ @@ -176,9 +165,7 @@ public function it_returns_400_if_query_parameters_change() $response2->assertStatus(400); } - /** - * @test - */ + #[Test] public function it_returns_400_if_path_changes() { $headers = [ @@ -194,9 +181,7 @@ public function it_returns_400_if_path_changes() $response2->assertStatus(400); } - /** - * @test - */ + #[Test] public function it_does_not_play_back_if_validation_fails() { $headers = [ @@ -228,9 +213,7 @@ public function it_does_not_play_back_if_validation_fails() $response4->assertHeader(config('playback.playback_header_name'), 'validation_test'); } - /** - * @test - */ + #[Test] public function it_does_not_record_get_request() { $headers = [ @@ -253,9 +236,7 @@ public function it_does_not_record_get_request() ); } - /** - * @test - */ + #[Test] public function the_first_request_wins() { $headers = [ @@ -267,7 +248,7 @@ public function the_first_request_wins() ->timeout(6); $pool[] = async(function () use ($headers) { - $app = new self(); + $app = new self('the_first_request_wins'); $app->setUpBeforeClass(); $app->setUp(); $response = $app->post('slow', [], $headers); @@ -285,7 +266,7 @@ public function the_first_request_wins() $pool[] = async(function () use ($headers) { usleep(150 * 1000); - $app = new self(); + $app = new self('the_first_request_wins'); $app->setUpBeforeClass(); $app->setUp(); $response = $app->post('slow', [], $headers); @@ -302,7 +283,7 @@ public function the_first_request_wins() $pool[] = async(function () use ($headers) { usleep(3000 * 1000); - $app = new self(); + $app = new self('the_first_request_wins'); $app->setUpBeforeClass(); $app->setUp(); $response = $app->post('slow', [], $headers);