diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c5d467f..0f15b20 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -110,7 +110,7 @@ jobs: - name: Get composer cache directory id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" + run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT" - name: Cache composer dependencies uses: actions/cache@v5 @@ -120,7 +120,8 @@ jobs: restore-keys: ${{ runner.os }}-composer- - name: Allow dev dependencies - run: if [ "${{ matrix.minimum-stability }}" = "dev" ]; then perl -pi -e 's/^}$/,"minimum-stability":"dev","prefer-stable":true}/' composer.json; fi; + if: matrix.minimum-stability == 'dev' + run: composer config minimum-stability dev && composer config prefer-stable true - name: Install Composer dependencies run: composer update --prefer-dist --no-interaction ${{ matrix.composer-flags }} diff --git a/.gitignore b/.gitignore index f218929..e093cc1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ # Third party /.php-cs-fixer.cache -/.phpunit.result.cache +/.phpunit.cache /composer.lock /vendor diff --git a/CHANGELOG.md b/CHANGELOG.md index e19d60d..190f9de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Added support for Symfony 8.2 * Replaced the `gifexception:optimize` command and `bin/optimizer.php` by the `castor optimize` task +* Upgraded the test suite to PHPUnit 11 ## 1.11.1 (2026-05-26) diff --git a/castor.php b/castor.php index 328c439..daa8a90 100644 --- a/castor.php +++ b/castor.php @@ -29,7 +29,7 @@ function cs(bool $dryRun = false): void #[AsTask(description: 'Run the test suite')] function test(): void { - run('vendor/bin/simple-phpunit'); + run('vendor/bin/phpunit'); } #[AsTask(description: 'Run static analysis')] diff --git a/composer.json b/composer.json index d6f4fbd..6450ee2 100644 --- a/composer.json +++ b/composer.json @@ -26,6 +26,7 @@ "doctrine/annotations": "^2.0", "friendsofphp/php-cs-fixer": "^3.17", "phpstan/phpstan": "^2.1", + "phpunit/phpunit": "^11.5", "symfony/asset": "^6.4 || ^7.3 || ^8.0", "symfony/browser-kit": "^6.4 || ^7.3 || ^8.0", "symfony/config": "^6.4 || ^7.3 || ^8.0", @@ -34,7 +35,7 @@ "symfony/error-handler": "^6.4 || ^7.3 || ^8.0", "symfony/http-kernel": "^6.4 || ^7.3 || ^8.0", "symfony/monolog-bundle": "^3.8 || ^4.0", - "symfony/phpunit-bridge": "^6.3 || ^7.0", + "symfony/phpunit-bridge": "^7.3 || ^8.0", "symfony/stopwatch": "^6.4 || ^7.3 || ^8.0", "symfony/web-profiler-bundle": "^6.4 || ^7.3 || ^8.0", "symfony/yaml": "^6.4 || ^7.3 || ^8.0" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 59cabc2..986d8ed 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,22 +1,13 @@ - - - - . - - - tests - vendor - - @@ -30,4 +21,16 @@ tests + + + . + + + tests + vendor + + + + + diff --git a/tests/FunctionalTest.php b/tests/FunctionalTest.php index 5343c51..a37040e 100644 --- a/tests/FunctionalTest.php +++ b/tests/FunctionalTest.php @@ -17,6 +17,26 @@ class FunctionalTest extends WebTestCase { + protected function tearDown(): void + { + parent::tearDown(); + + // FrameworkBundle::boot() calls ErrorHandler::register() on every kernel boot. Before + // symfony/error-handler 8.1, it left an exception handler registered when another error + // handler (PHPUnit's) was already in charge, which PHPUnit reports as a risky test. + // Remove this once Symfony < 8.1 is dropped. + while (true) { + $previous = set_exception_handler(static fn () => null); + restore_exception_handler(); + + if (null === $previous) { + break; + } + + restore_exception_handler(); + } + } + public function testItDoesNotDisplayGifOnExceptionPageIfTheBundleIsNotEnabled(): void { $client = static::createClient(['environment' => 'prod', 'debug' => true]);