From 277603d3a428f3a12b8c49bf84b4fbbe7b826240 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 24 Apr 2024 16:42:10 +0800 Subject: [PATCH 01/11] Support PHPUnit 11 Signed-off-by: Mior Muhammad Zaki --- .github/workflows/coveralls.yaml | 2 +- .github/workflows/strict-tests.yaml | 1 + .github/workflows/tests.yaml | 1 + composer.json | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/coveralls.yaml b/.github/workflows/coveralls.yaml index d14ae6dea..383a21f64 100644 --- a/.github/workflows/coveralls.yaml +++ b/.github/workflows/coveralls.yaml @@ -15,7 +15,7 @@ jobs: php: - 8.2 phpunit: - - "10.5.x" + - "^11.0.0" dependencies: - "highest" experimental: diff --git a/.github/workflows/strict-tests.yaml b/.github/workflows/strict-tests.yaml index afdde7864..c271a0949 100644 --- a/.github/workflows/strict-tests.yaml +++ b/.github/workflows/strict-tests.yaml @@ -22,6 +22,7 @@ jobs: - "~10.5.0" - "10.5.4" - "~11.0.0" + - "~11.1.0" dependencies: - "highest" experimental: diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 098f50912..bfa358c00 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -23,6 +23,7 @@ jobs: - "~10.5.0" - "10.5.4" - "~11.0.0" + - "~11.1.0" dependencies: - "highest" - "lowest" diff --git a/composer.json b/composer.json index 60f8bccae..a5147d47f 100644 --- a/composer.json +++ b/composer.json @@ -55,7 +55,7 @@ "brianium/paratest": "<7.3.0 || >=8.0.0", "laravel/framework": "<11.1.0 || >=12.0.0", "nunomaduro/collision": "<8.0.0 || >=9.0.0", - "phpunit/phpunit": "<10.5.0 || 11.0.0 || >=11.1.0" + "phpunit/phpunit": "<10.5.0 || 11.0.0 || >=11.2.0" }, "suggest": { "ext-pcntl": "Required to use all features of the console signal trapping.", From f466d22a10ed276dad84f8ca8f561027fbfa1a65 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 24 Apr 2024 17:28:48 +0800 Subject: [PATCH 02/11] wip Signed-off-by: Mior Muhammad Zaki --- src/Console/Commander.php | 2 +- src/Foundation/Application.php | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Console/Commander.php b/src/Console/Commander.php index f178d0e1d..d0e17aac4 100644 --- a/src/Console/Commander.php +++ b/src/Console/Commander.php @@ -119,7 +119,7 @@ public function handle(): void } finally { $this->handleTerminatingConsole(); Workbench::flush(); - static::$testbench::flushState(); + static::$testbench::flushState(false); $this->untrap(); } diff --git a/src/Foundation/Application.php b/src/Foundation/Application.php index 5105d418d..a66394566 100644 --- a/src/Foundation/Application.php +++ b/src/Foundation/Application.php @@ -173,9 +173,10 @@ public static function createFromConfig(ConfigContract $config, ?callable $resol /** * Flush the application states. * + * @param bool $testing * @return void */ - public static function flushState(): void + public static function flushState(bool $testing = true): void { AboutCommand::flushState(); Artisan::forgetBootstrappers(); @@ -184,7 +185,11 @@ public static function flushState(): void Component::forgetComponentsResolver(); Component::forgetFactory(); ConvertEmptyStringsToNull::flushState(); - HandleExceptions::flushState(); + + if ($testing === true) { + HandleExceptions::flushState(); + } + JsonResource::wrap('data'); Once::flush(); Queue::createPayloadUsing(null); From 3d5da627b207d6e63990c3f8970a16f2468f1531 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 24 Apr 2024 17:35:35 +0800 Subject: [PATCH 03/11] wip Signed-off-by: Mior Muhammad Zaki --- src/Console/Commander.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Console/Commander.php b/src/Console/Commander.php index d0e17aac4..e8b8d7fdf 100644 --- a/src/Console/Commander.php +++ b/src/Console/Commander.php @@ -119,7 +119,10 @@ public function handle(): void } finally { $this->handleTerminatingConsole(); Workbench::flush(); - static::$testbench::flushState(false); + static::$testbench::flushState( + Env::has('TESTBENCH_PACKAGE_REMOTE') === false + && (isset($laravel) && $laravel->runningUnitTests() === true) + ); $this->untrap(); } From 13520e19ed1433a26f9dc9a2a7c69647c65c82dc Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 24 Apr 2024 17:39:24 +0800 Subject: [PATCH 04/11] wip Signed-off-by: Mior Muhammad Zaki --- src/Console/Commander.php | 5 +---- src/Foundation/Application.php | 7 ++++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Console/Commander.php b/src/Console/Commander.php index e8b8d7fdf..e7a2a966e 100644 --- a/src/Console/Commander.php +++ b/src/Console/Commander.php @@ -119,10 +119,7 @@ public function handle(): void } finally { $this->handleTerminatingConsole(); Workbench::flush(); - static::$testbench::flushState( - Env::has('TESTBENCH_PACKAGE_REMOTE') === false - && (isset($laravel) && $laravel->runningUnitTests() === true) - ); + static::$testbench::flushState($this); $this->untrap(); } diff --git a/src/Foundation/Application.php b/src/Foundation/Application.php index a66394566..13b6c9dcd 100644 --- a/src/Foundation/Application.php +++ b/src/Foundation/Application.php @@ -22,6 +22,7 @@ use Illuminate\Support\Sleep; use Illuminate\View\Component; use Orchestra\Testbench\Concerns\CreatesApplication; +use Orchestra\Testbench\Console\Commander; use Orchestra\Testbench\Contracts\Config as ConfigContract; use Orchestra\Testbench\Workbench\Workbench; @@ -173,10 +174,10 @@ public static function createFromConfig(ConfigContract $config, ?callable $resol /** * Flush the application states. * - * @param bool $testing + * @param \Orchestra\Testbench\Console\Commander|\Orchestra\Testbench\PHPUnit\TestCase $testing * @return void */ - public static function flushState(bool $testing = true): void + public static function flushState(object $instance): void { AboutCommand::flushState(); Artisan::forgetBootstrappers(); @@ -186,7 +187,7 @@ public static function flushState(bool $testing = true): void Component::forgetFactory(); ConvertEmptyStringsToNull::flushState(); - if ($testing === true) { + if (! $instance instanceof Commander) { HandleExceptions::flushState(); } From e89cf61bc7f8efb214ddd009256149c3dafd2f1a Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 24 Apr 2024 17:44:32 +0800 Subject: [PATCH 05/11] wip Signed-off-by: Mior Muhammad Zaki --- src/Concerns/ApplicationTestingHooks.php | 2 +- src/Foundation/Application.php | 2 +- tests/CreatesApplicationTest.php | 2 +- tests/Foundation/ApplicationTest.php | 2 +- tests/TestCaseTest.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Concerns/ApplicationTestingHooks.php b/src/Concerns/ApplicationTestingHooks.php index 6b9a7690d..95895c886 100644 --- a/src/Concerns/ApplicationTestingHooks.php +++ b/src/Concerns/ApplicationTestingHooks.php @@ -141,7 +141,7 @@ final protected function tearDownTheApplicationTestingHooks(?Closure $callback = $this->afterApplicationCreatedCallbacks = []; $this->beforeApplicationDestroyedCallbacks = []; - Testbench::flushState(); + Testbench::flushState($this); if ($this->callbackException) { throw $this->callbackException; diff --git a/src/Foundation/Application.php b/src/Foundation/Application.php index 13b6c9dcd..fdb1915c9 100644 --- a/src/Foundation/Application.php +++ b/src/Foundation/Application.php @@ -174,7 +174,7 @@ public static function createFromConfig(ConfigContract $config, ?callable $resol /** * Flush the application states. * - * @param \Orchestra\Testbench\Console\Commander|\Orchestra\Testbench\PHPUnit\TestCase $testing + * @param \Orchestra\Testbench\Console\Commander|\Orchestra\Testbench\PHPUnit\TestCase $instance * @return void */ public static function flushState(object $instance): void diff --git a/tests/CreatesApplicationTest.php b/tests/CreatesApplicationTest.php index e5b7f95e6..315187ee6 100644 --- a/tests/CreatesApplicationTest.php +++ b/tests/CreatesApplicationTest.php @@ -16,7 +16,7 @@ class CreatesApplicationTest extends TestCase #[\Override] protected function tearDown(): void { - Testbench::flushState(); + Testbench::flushState($this); } #[Test] diff --git a/tests/Foundation/ApplicationTest.php b/tests/Foundation/ApplicationTest.php index 7d2ce5bb6..197b43c19 100644 --- a/tests/Foundation/ApplicationTest.php +++ b/tests/Foundation/ApplicationTest.php @@ -14,7 +14,7 @@ class ApplicationTest extends TestCase #[\Override] protected function tearDown(): void { - Application::flushState(); + Application::flushState($this); } #[Test] diff --git a/tests/TestCaseTest.php b/tests/TestCaseTest.php index f31132508..2bcdb0a7b 100644 --- a/tests/TestCaseTest.php +++ b/tests/TestCaseTest.php @@ -18,7 +18,7 @@ class TestCaseTest extends TestCase #[\Override] protected function tearDown(): void { - Testbench::flushState(); + Testbench::flushState($this); } #[Test] From 539814ce777101b2843a2573558f2b704077dacc Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 24 Apr 2024 17:49:14 +0800 Subject: [PATCH 06/11] wip Signed-off-by: Mior Muhammad Zaki --- .github/workflows/collision-tests.yaml | 4 ++-- .github/workflows/parallel-tests.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/collision-tests.yaml b/.github/workflows/collision-tests.yaml index b208797db..f566663d4 100644 --- a/.github/workflows/collision-tests.yaml +++ b/.github/workflows/collision-tests.yaml @@ -54,7 +54,7 @@ jobs: if: matrix.dependencies == 'highest' - name: Execute tests (without deprecations on PHPUnit 10) - run: ./testbench package:test --exclude-group commander,deprecations + run: ./testbench package:test --exclude-group commander --exclude-group deprecations env: RAY_ENABLED: false TESTBENCH_CONVERT_DEPRECATIONS_TO_EXCEPTIONS: false @@ -102,7 +102,7 @@ jobs: composer show -D - name: Execute tests - run: ./testbench package:test --coverage --exclude-group commander,deprecations + run: ./testbench package:test --coverage --exclude-group commander --exclude-group deprecations env: RAY_ENABLED: false TESTBENCH_CONVERT_DEPRECATIONS_TO_EXCEPTIONS: false diff --git a/.github/workflows/parallel-tests.yaml b/.github/workflows/parallel-tests.yaml index 8a97c1a1c..710e16bf4 100644 --- a/.github/workflows/parallel-tests.yaml +++ b/.github/workflows/parallel-tests.yaml @@ -52,13 +52,13 @@ jobs: composer show -D - name: Execute tests (with deprecations on PHPUnit 10) - run: ./testbench package:test --parallel --exclude-group commander,without-parallel,database,session --no-coverage + run: ./testbench package:test --parallel --exclude-group commander --exclude-group without-parallel --exclude-group database --exclude-group session --no-coverage env: RAY_ENABLED: false if: matrix.dependencies == 'highest' - name: Execute tests (without deprecations on PHPUnit 10) - run: ./testbench package:test --parallel --exclude-group commander,without-parallel,database,session,deprecations --no-coverage + run: ./testbench package:test --parallel --exclude-group commander --exclude-group without-parallel --exclude-group database --exclude-group session --exclude-group deprecations --no-coverage env: RAY_ENABLED: false TESTBENCH_CONVERT_DEPRECATIONS_TO_EXCEPTIONS: false From fc7baa29433b34bfa0b1591356f71af74dc17431 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 24 Apr 2024 17:54:05 +0800 Subject: [PATCH 07/11] wip Signed-off-by: Mior Muhammad Zaki --- .github/workflows/parallel-tests.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/parallel-tests.yaml b/.github/workflows/parallel-tests.yaml index 710e16bf4..a76f9a87c 100644 --- a/.github/workflows/parallel-tests.yaml +++ b/.github/workflows/parallel-tests.yaml @@ -19,6 +19,8 @@ jobs: - "^8.0" paratest: - "^7.3" + phpunit: + - "^11.1" dependencies: - "highest" experimental: @@ -39,7 +41,7 @@ jobs: - name: Install Paratest run: | - composer require "nunomaduro/collision:${{ matrix.collision }}" "brianium/paratest:${{ matrix.paratest }}" --dev --no-interaction --no-update + composer require "nunomaduro/collision:${{ matrix.collision }}" "brianium/paratest:${{ matrix.paratest }}" "phpunit/phpunit:${{ matrix.phpunit }}" --dev --no-interaction --no-update - name: Install dependencies uses: "ramsey/composer-install@v3" From a3c209c734504b97ab1cdd042a89b6fe52fb699c Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 24 Apr 2024 17:59:56 +0800 Subject: [PATCH 08/11] wip Signed-off-by: Mior Muhammad Zaki --- .github/workflows/parallel-tests.yaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/parallel-tests.yaml b/.github/workflows/parallel-tests.yaml index a76f9a87c..e7fc61d54 100644 --- a/.github/workflows/parallel-tests.yaml +++ b/.github/workflows/parallel-tests.yaml @@ -20,7 +20,8 @@ jobs: paratest: - "^7.3" phpunit: - - "^11.1" + - "~10.5.0" + - "~11.0.0" dependencies: - "highest" experimental: @@ -53,14 +54,14 @@ jobs: run: | composer show -D - - name: Execute tests (with deprecations on PHPUnit 10) - run: ./testbench package:test --parallel --exclude-group commander --exclude-group without-parallel --exclude-group database --exclude-group session --no-coverage + - name: Execute tests (with deprecations) + run: ./testbench package:test --parallel --exclude-group commander,without-parallel,database,session --no-coverage env: RAY_ENABLED: false if: matrix.dependencies == 'highest' - - name: Execute tests (without deprecations on PHPUnit 10) - run: ./testbench package:test --parallel --exclude-group commander --exclude-group without-parallel --exclude-group database --exclude-group session --exclude-group deprecations --no-coverage + - name: Execute tests (without deprecations) + run: ./testbench package:test --parallel --exclude-group commander,without-parallel,database,session --exclude-group deprecations --no-coverage env: RAY_ENABLED: false TESTBENCH_CONVERT_DEPRECATIONS_TO_EXCEPTIONS: false From 32bf670d2a07a2a46bb9e8d9704d86efce627526 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 24 Apr 2024 18:00:26 +0800 Subject: [PATCH 09/11] wip Signed-off-by: Mior Muhammad Zaki --- .github/workflows/collision-tests.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/collision-tests.yaml b/.github/workflows/collision-tests.yaml index f566663d4..b208797db 100644 --- a/.github/workflows/collision-tests.yaml +++ b/.github/workflows/collision-tests.yaml @@ -54,7 +54,7 @@ jobs: if: matrix.dependencies == 'highest' - name: Execute tests (without deprecations on PHPUnit 10) - run: ./testbench package:test --exclude-group commander --exclude-group deprecations + run: ./testbench package:test --exclude-group commander,deprecations env: RAY_ENABLED: false TESTBENCH_CONVERT_DEPRECATIONS_TO_EXCEPTIONS: false @@ -102,7 +102,7 @@ jobs: composer show -D - name: Execute tests - run: ./testbench package:test --coverage --exclude-group commander --exclude-group deprecations + run: ./testbench package:test --coverage --exclude-group commander,deprecations env: RAY_ENABLED: false TESTBENCH_CONVERT_DEPRECATIONS_TO_EXCEPTIONS: false From 5faaebeedb301fe9b970989d19fc128a9c0010b6 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 24 Apr 2024 18:23:10 +0800 Subject: [PATCH 10/11] Update parallel-tests.yaml --- .github/workflows/parallel-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/parallel-tests.yaml b/.github/workflows/parallel-tests.yaml index e7fc61d54..9b8de6abb 100644 --- a/.github/workflows/parallel-tests.yaml +++ b/.github/workflows/parallel-tests.yaml @@ -61,7 +61,7 @@ jobs: if: matrix.dependencies == 'highest' - name: Execute tests (without deprecations) - run: ./testbench package:test --parallel --exclude-group commander,without-parallel,database,session --exclude-group deprecations --no-coverage + run: ./testbench package:test --parallel --exclude-group commander,without-parallel,database,session,deprecations --no-coverage env: RAY_ENABLED: false TESTBENCH_CONVERT_DEPRECATIONS_TO_EXCEPTIONS: false From fb0394420988efac237f3ea6a2c76981ca962422 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 24 Apr 2024 18:24:30 +0800 Subject: [PATCH 11/11] Update parallel-tests.yaml --- .github/workflows/parallel-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/parallel-tests.yaml b/.github/workflows/parallel-tests.yaml index 9b8de6abb..a2e7053da 100644 --- a/.github/workflows/parallel-tests.yaml +++ b/.github/workflows/parallel-tests.yaml @@ -27,7 +27,7 @@ jobs: experimental: - false - name: PHP${{ matrix.php }} on ${{ matrix.os }} (${{ matrix.dependencies }}) + name: PHP:${{ matrix.php }} with PHPUnit:${{ matrix.phpunit }} on ${{ matrix.os }} (${{ matrix.dependencies }}) steps: - name: Checkout code