From 3172add7ec1cc1d79062ebc0fd7d28e2f822f98d Mon Sep 17 00:00:00 2001 From: Martin Zurowietz Date: Fri, 12 Jul 2024 16:35:02 +0200 Subject: [PATCH 1/3] Implement compatibility with Laravel 11 Resolves https://github.com/biigle/laravel-file-cache/issues/22 --- .github/workflows/tests.yml | 12 ++++++++---- .gitignore | 1 + composer.json | 12 ++++++------ phpunit.xml | 12 ++++++------ tests/FileCacheServiceProviderTest.php | 2 +- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index cca2d5f..0685172 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,8 +12,12 @@ jobs: timeout-minutes: 10 strategy: matrix: - php-versions: ['8.1', '8.2'] - laravel-versions: ['^9.0', '^10.0'] + php-version: ['8.1', '8.2'] + laravel-version: ['^9.0', '^10.0', '^11.0'] + exclude: + - php-version: '8.1' + laravel-version: '^11.0' + steps: - name: Checkout uses: actions/checkout@v3 @@ -21,10 +25,10 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php-versions }} + php-version: ${{ matrix.php-version }} - name: Setup Laravel - run: composer require -W --dev laravel/laravel:${{ matrix.laravel-versions }} + run: composer require -W --dev laravel/laravel:${{ matrix.laravel-version }} - name: Run tests run: ./vendor/bin/phpunit diff --git a/.gitignore b/.gitignore index 3ffdd8a..682fc88 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /vendor/ .phpunit.result.cache composer.lock +.phpunit.cache diff --git a/composer.json b/composer.json index 2f781c3..e385b64 100644 --- a/composer.json +++ b/composer.json @@ -4,16 +4,16 @@ "type": "library", "license": "MIT", "require": { - "illuminate/console": "^9.0 || ^10.0", - "illuminate/filesystem": "^9.0 || ^10.0", - "illuminate/support": "^9.0 || ^10.0", - "symfony/finder": "^6.0", + "illuminate/console": "^9.0 || ^10.0 || ^11.0", + "illuminate/filesystem": "^9.0 || ^10.0 || ^11.0", + "illuminate/support": "^9.0 || ^10.0 || ^11.0", + "symfony/finder": "^6.0 || ^7.0", "guzzlehttp/guzzle": "^7.0" }, "require-dev": { - "phpunit/phpunit": "^9.0", + "phpunit/phpunit": "^10.0", "mockery/mockery": "^1.2", - "laravel/laravel": "^9.0 || ^10.0" + "laravel/laravel": "^9.0 || ^10.0 || ^11.0" }, "authors": [ { diff --git a/phpunit.xml b/phpunit.xml index 9ddd9c4..1686ef8 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,13 +1,13 @@ - - - - src - - + tests + + + src + + diff --git a/tests/FileCacheServiceProviderTest.php b/tests/FileCacheServiceProviderTest.php index cb743e4..77db86e 100644 --- a/tests/FileCacheServiceProviderTest.php +++ b/tests/FileCacheServiceProviderTest.php @@ -12,7 +12,7 @@ public function testScheduledCommand() { config(['file-cache.prune_interval' => '*/5 * * * *']); $schedule = $this->app[Schedule::class]; - $event = $schedule->events()[0]; + $event = $schedule->events()[1]; $this->assertStringContainsString('prune-file-cache', $event->command); $this->assertEquals('*/5 * * * *', $event->expression); } From 7b5110b2a2913fafa0c56f35d117d602f0731694 Mon Sep 17 00:00:00 2001 From: Martin Zurowietz Date: Fri, 12 Jul 2024 16:37:28 +0200 Subject: [PATCH 2/3] Make test compatible with many Laravel versions --- tests/FileCacheServiceProviderTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/FileCacheServiceProviderTest.php b/tests/FileCacheServiceProviderTest.php index 77db86e..e65702c 100644 --- a/tests/FileCacheServiceProviderTest.php +++ b/tests/FileCacheServiceProviderTest.php @@ -11,8 +11,8 @@ class FileCacheServiceProviderTest extends TestCase public function testScheduledCommand() { config(['file-cache.prune_interval' => '*/5 * * * *']); - $schedule = $this->app[Schedule::class]; - $event = $schedule->events()[1]; + $events = $this->app[Schedule::class]->events(); + $event = end($events); $this->assertStringContainsString('prune-file-cache', $event->command); $this->assertEquals('*/5 * * * *', $event->expression); } From 3de0126f35f5cb82061d45e298228bf06cc05422 Mon Sep 17 00:00:00 2001 From: Martin Zurowietz Date: Fri, 12 Jul 2024 16:41:56 +0200 Subject: [PATCH 3/3] Make version compatible with Laravel 11 only --- .github/workflows/tests.yml | 7 ++----- composer.json | 10 +++++----- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0685172..8ce0d56 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,11 +12,8 @@ jobs: timeout-minutes: 10 strategy: matrix: - php-version: ['8.1', '8.2'] - laravel-version: ['^9.0', '^10.0', '^11.0'] - exclude: - - php-version: '8.1' - laravel-version: '^11.0' + php-version: ['8.2'] + laravel-version: ['^11.0'] steps: - name: Checkout diff --git a/composer.json b/composer.json index e385b64..0661b2b 100644 --- a/composer.json +++ b/composer.json @@ -4,16 +4,16 @@ "type": "library", "license": "MIT", "require": { - "illuminate/console": "^9.0 || ^10.0 || ^11.0", - "illuminate/filesystem": "^9.0 || ^10.0 || ^11.0", - "illuminate/support": "^9.0 || ^10.0 || ^11.0", - "symfony/finder": "^6.0 || ^7.0", + "illuminate/console": "^11.0", + "illuminate/filesystem": "^11.0", + "illuminate/support": "^11.0", + "symfony/finder": "^7.0", "guzzlehttp/guzzle": "^7.0" }, "require-dev": { "phpunit/phpunit": "^10.0", "mockery/mockery": "^1.2", - "laravel/laravel": "^9.0 || ^10.0 || ^11.0" + "laravel/laravel": "^11.0" }, "authors": [ {