Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support PHPUnit 11.1 #206

Merged
merged 11 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/coveralls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
php:
- 8.2
phpunit:
- "10.5.x"
- "^11.0.0"
dependencies:
- "highest"
experimental:
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/parallel-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ jobs:
- "^8.0"
paratest:
- "^7.3"
phpunit:
- "~10.5.0"
- "~11.0.0"
dependencies:
- "highest"
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
Expand All @@ -39,7 +42,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"
Expand All @@ -51,13 +54,13 @@ jobs:
run: |
composer show -D

- name: Execute tests (with deprecations on PHPUnit 10)
- 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)
- name: Execute tests (without deprecations)
run: ./testbench package:test --parallel --exclude-group commander,without-parallel,database,session,deprecations --no-coverage
env:
RAY_ENABLED: false
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/strict-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
- "~10.5.0"
- "10.5.4"
- "~11.0.0"
- "~11.1.0"
dependencies:
- "highest"
experimental:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
- "~10.5.0"
- "10.5.4"
- "~11.0.0"
- "~11.1.0"
dependencies:
- "highest"
- "lowest"
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
2 changes: 1 addition & 1 deletion src/Concerns/ApplicationTestingHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Commander.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function handle(): void
} finally {
$this->handleTerminatingConsole();
Workbench::flush();
static::$testbench::flushState();
static::$testbench::flushState($this);

$this->untrap();
}
Expand Down
10 changes: 8 additions & 2 deletions src/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -173,9 +174,10 @@ public static function createFromConfig(ConfigContract $config, ?callable $resol
/**
* Flush the application states.
*
* @param \Orchestra\Testbench\Console\Commander|\Orchestra\Testbench\PHPUnit\TestCase $instance
* @return void
*/
public static function flushState(): void
public static function flushState(object $instance): void
{
AboutCommand::flushState();
Artisan::forgetBootstrappers();
Expand All @@ -184,7 +186,11 @@ public static function flushState(): void
Component::forgetComponentsResolver();
Component::forgetFactory();
ConvertEmptyStringsToNull::flushState();
HandleExceptions::flushState();

if (! $instance instanceof Commander) {
HandleExceptions::flushState();
}

JsonResource::wrap('data');
Once::flush();
Queue::createPayloadUsing(null);
Expand Down
2 changes: 1 addition & 1 deletion tests/CreatesApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class CreatesApplicationTest extends TestCase
#[\Override]
protected function tearDown(): void
{
Testbench::flushState();
Testbench::flushState($this);
}

#[Test]
Expand Down
2 changes: 1 addition & 1 deletion tests/Foundation/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ApplicationTest extends TestCase
#[\Override]
protected function tearDown(): void
{
Application::flushState();
Application::flushState($this);
}

#[Test]
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class TestCaseTest extends TestCase
#[\Override]
protected function tearDown(): void
{
Testbench::flushState();
Testbench::flushState($this);
}

#[Test]
Expand Down
Loading