From 4458a43250e8d06ae71efe801473eea0628d4fc1 Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Tue, 18 Nov 2025 08:18:12 +0100 Subject: [PATCH 01/17] [CI] Prepare migration to PHPUnit >= 11 --- .github/workflows/code-quality.yaml | 3 +-- .github/workflows/functional-tests.yml | 2 +- .github/workflows/unit-tests.yaml | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/code-quality.yaml b/.github/workflows/code-quality.yaml index 191c92d0bbe..43061e7605a 100644 --- a/.github/workflows/code-quality.yaml +++ b/.github/workflows/code-quality.yaml @@ -171,7 +171,6 @@ jobs: echo COLUMNS=120 >> $GITHUB_ENV echo COMPOSER_MIN_STAB='composer config minimum-stability ${{ matrix.minimum-stability || 'stable' }} --ansi' >> $GITHUB_ENV echo COMPOSER_UP='composer update ${{ matrix.dependency-version == 'lowest' && '--prefer-lowest' || '' }} --no-progress --no-interaction --ansi' >> $GITHUB_ENV - echo PHPUNIT_INSTALL='vendor/bin/simple-phpunit install' >> $GITHUB_ENV echo PHPSTAN='vendor/bin/phpstan' >> $GITHUB_ENV # TODO: Only Turbo has PHPStan configuration, let's improve this later :) @@ -211,4 +210,4 @@ jobs: run: | source .github/workflows/.utils.sh - echo "$PACKAGES" | xargs -n1 | parallel -j +3 "_run_task {} '(cd src/{} && $COMPOSER_MIN_STAB && $COMPOSER_UP && $PHPUNIT_INSTALL && $PHPSTAN)'" + echo "$PACKAGES" | xargs -n1 | parallel -j +3 "_run_task {} '(cd src/{} && $COMPOSER_MIN_STAB && $COMPOSER_UP && $PHPSTAN)'" diff --git a/.github/workflows/functional-tests.yml b/.github/workflows/functional-tests.yml index cfaf7d2a9e8..0f9a33d546e 100644 --- a/.github/workflows/functional-tests.yml +++ b/.github/workflows/functional-tests.yml @@ -93,6 +93,6 @@ jobs: working-directory: src/Turbo run: | [ 'lowest' = '${{ matrix.dependency-version }}' ] && export SYMFONY_DEPRECATIONS_HELPER=weak - vendor/bin/simple-phpunit + vendor/bin/phpunit env: SYMFONY_DEPRECATIONS_HELPER: 'max[self]=1' diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml index 9130e252782..acb5e791cca 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -74,7 +74,7 @@ jobs: echo COLUMNS=120 >> $GITHUB_ENV echo COMPOSER_MIN_STAB='composer config minimum-stability ${{ matrix.minimum-stability || 'stable' }} --ansi' >> $GITHUB_ENV echo COMPOSER_UP='composer update ${{ matrix.dependency-version == 'lowest' && '--prefer-lowest' || '' }} --no-progress --no-interaction --ansi' >> $GITHUB_ENV - echo PHPUNIT='vendor/bin/simple-phpunit ${{ matrix.dependency-version == 'lowest' && '--exclude-group skip-on-lowest' || '' }} ${{ matrix.os == 'windows-latest' && '--exclude-group transient-on-windows' || '' }}' >> $GITHUB_ENV + echo PHPUNIT='vendor/bin/phpunit ${{ matrix.dependency-version == 'lowest' && '--exclude-group skip-on-lowest' || '' }} ${{ matrix.os == 'windows-latest' && '--exclude-group transient-on-windows' || '' }}' >> $GITHUB_ENV [ 'lowest' = '${{ matrix.dependency-version }}' ] && export SYMFONY_DEPRECATIONS_HELPER=weak # Turbo has its own workflow file From 22bc86add45bee1bb44a067fc7c08aed1eac7549 Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Tue, 18 Nov 2025 08:18:38 +0100 Subject: [PATCH 02/17] [Autocomplete] Drop Symfony PHPUnit Bridge in favor of PHPUnit >= 11.0 --- src/Autocomplete/.gitignore | 3 ++- src/Autocomplete/composer.json | 4 +-- .../{phpunit.xml.dist => phpunit.dist.xml} | 25 ++++++++++++------- .../Form/AsEntityAutocompleteFieldTest.php | 5 ++-- src/Autocomplete/tests/bootstrap.php | 17 +++++++++++++ 5 files changed, 39 insertions(+), 15 deletions(-) rename src/Autocomplete/{phpunit.xml.dist => phpunit.dist.xml} (59%) create mode 100644 src/Autocomplete/tests/bootstrap.php diff --git a/src/Autocomplete/.gitignore b/src/Autocomplete/.gitignore index 1784dd6561c..123c390f298 100644 --- a/src/Autocomplete/.gitignore +++ b/src/Autocomplete/.gitignore @@ -2,6 +2,7 @@ /vendor/ /composer.lock /phpunit.xml -/.phpunit.result.cache +/.phpunit.cache /var +/config/reference.php diff --git a/src/Autocomplete/composer.json b/src/Autocomplete/composer.json index f191b0a93d7..6bacf0214c0 100644 --- a/src/Autocomplete/composer.json +++ b/src/Autocomplete/composer.json @@ -37,17 +37,17 @@ "doctrine/orm": "^2.9.4|^3.0", "fakerphp/faker": "^1.22", "mtdowling/jmespath.php": "^2.6", + "phpunit/phpunit": "^11.1|^12.0", "symfony/form": "^7.2|^8.0", "symfony/options-resolver": "^6.4|^7.0|^8.0", "symfony/framework-bundle": "^6.4|^7.0|^8.0", "symfony/maker-bundle": "^1.40", - "symfony/phpunit-bridge": "^7.2|^8.0", "symfony/process": "^6.4|^7.0|^8.0", "symfony/security-bundle": "^6.4|^7.0|^8.0", "symfony/twig-bundle": "^6.4|^7.0|^8.0", "symfony/uid": "^6.4|^7.0|^8.0", "twig/twig": "^2.14.7|^3.0.4", - "zenstruck/browser": "^1.1", + "zenstruck/browser": "^1.9", "zenstruck/foundry": "^2.0" }, "conflict": { diff --git a/src/Autocomplete/phpunit.xml.dist b/src/Autocomplete/phpunit.dist.xml similarity index 59% rename from src/Autocomplete/phpunit.xml.dist rename to src/Autocomplete/phpunit.dist.xml index 30cee25b744..7353d4aa2cc 100644 --- a/src/Autocomplete/phpunit.xml.dist +++ b/src/Autocomplete/phpunit.dist.xml @@ -2,16 +2,18 @@ - + @@ -22,13 +24,18 @@ - + - ./src + src - - - - + + trigger_deprecation + + diff --git a/src/Autocomplete/tests/Unit/Form/AsEntityAutocompleteFieldTest.php b/src/Autocomplete/tests/Unit/Form/AsEntityAutocompleteFieldTest.php index bad45d32f27..dfcfd4782c1 100644 --- a/src/Autocomplete/tests/Unit/Form/AsEntityAutocompleteFieldTest.php +++ b/src/Autocomplete/tests/Unit/Form/AsEntityAutocompleteFieldTest.php @@ -11,15 +11,14 @@ namespace Symfony\UX\Autocomplete\Tests\Unit\Form; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\UX\Autocomplete\Form\AsEntityAutocompleteField; use Symfony\UX\Autocomplete\Tests\Fixtures\Form\ProductType; class AsEntityAutocompleteFieldTest extends TestCase { - /** - * @dataProvider provideClassNames - */ + #[DataProvider('provideClassNames')] public function testShortName(string $shortName, string $className) { $this->assertEquals($shortName, AsEntityAutocompleteField::shortName($className)); diff --git a/src/Autocomplete/tests/bootstrap.php b/src/Autocomplete/tests/bootstrap.php new file mode 100644 index 00000000000..89a23684510 --- /dev/null +++ b/src/Autocomplete/tests/bootstrap.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Symfony\Component\ErrorHandler\ErrorHandler; + +require __DIR__.'/../vendor/autoload.php'; + +// @see https://github.com/symfony/symfony/issues/53812 +ErrorHandler::register(null, false); From ba7d268efbd95146c752ef1271157113cb5d7153 Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Tue, 18 Nov 2025 08:30:50 +0100 Subject: [PATCH 03/17] [Chartjs] Drop Symfony PHPUnit Bridge in favor of PHPUnit >= 11.0 --- src/Chartjs/.gitignore | 2 +- src/Chartjs/composer.json | 2 +- .../{phpunit.xml.dist => phpunit.dist.xml} | 24 ++++++++++++------- src/Chartjs/tests/bootstrap.php | 17 +++++++++++++ 4 files changed, 34 insertions(+), 11 deletions(-) rename src/Chartjs/{phpunit.xml.dist => phpunit.dist.xml} (52%) create mode 100644 src/Chartjs/tests/bootstrap.php diff --git a/src/Chartjs/.gitignore b/src/Chartjs/.gitignore index 2cc9f0231c3..095a90a8430 100644 --- a/src/Chartjs/.gitignore +++ b/src/Chartjs/.gitignore @@ -2,4 +2,4 @@ /vendor/ /composer.lock /phpunit.xml -/.phpunit.result.cache +/.phpunit.cache diff --git a/src/Chartjs/composer.json b/src/Chartjs/composer.json index 5d4b8304efe..d2d2e861953 100644 --- a/src/Chartjs/composer.json +++ b/src/Chartjs/composer.json @@ -35,8 +35,8 @@ "symfony/stimulus-bundle": "^2.9.1" }, "require-dev": { + "phpunit/phpunit": "^11.1|^12.0", "symfony/framework-bundle": "^6.4|^7.0|^8.0", - "symfony/phpunit-bridge": "^7.2|^8.0", "symfony/twig-bundle": "^6.4|^7.0|^8.0", "symfony/var-dumper": "^6.4|^7.0|^8.0" }, diff --git a/src/Chartjs/phpunit.xml.dist b/src/Chartjs/phpunit.dist.xml similarity index 52% rename from src/Chartjs/phpunit.xml.dist rename to src/Chartjs/phpunit.dist.xml index 7419f8ddf00..d9b7f51fc84 100644 --- a/src/Chartjs/phpunit.xml.dist +++ b/src/Chartjs/phpunit.dist.xml @@ -2,16 +2,17 @@ - @@ -20,13 +21,18 @@ - + - ./src + src - - - - + + trigger_deprecation + + diff --git a/src/Chartjs/tests/bootstrap.php b/src/Chartjs/tests/bootstrap.php new file mode 100644 index 00000000000..89a23684510 --- /dev/null +++ b/src/Chartjs/tests/bootstrap.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Symfony\Component\ErrorHandler\ErrorHandler; + +require __DIR__.'/../vendor/autoload.php'; + +// @see https://github.com/symfony/symfony/issues/53812 +ErrorHandler::register(null, false); From 871a60fcab6ebc9d94fd3373907be9f3258245af Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Tue, 18 Nov 2025 08:37:44 +0100 Subject: [PATCH 04/17] [Cropperjs] Drop Symfony PHPUnit Bridge in favor of PHPUnit >= 11.0 --- src/Cropperjs/.gitignore | 2 +- src/Cropperjs/composer.json | 2 +- .../{phpunit.xml.dist => phpunit.dist.xml} | 24 ++++++++++++------- src/Cropperjs/tests/CropperjsBundleTest.php | 5 ++-- src/Cropperjs/tests/bootstrap.php | 17 +++++++++++++ 5 files changed, 36 insertions(+), 14 deletions(-) rename src/Cropperjs/{phpunit.xml.dist => phpunit.dist.xml} (52%) create mode 100644 src/Cropperjs/tests/bootstrap.php diff --git a/src/Cropperjs/.gitignore b/src/Cropperjs/.gitignore index 2cc9f0231c3..095a90a8430 100644 --- a/src/Cropperjs/.gitignore +++ b/src/Cropperjs/.gitignore @@ -2,4 +2,4 @@ /vendor/ /composer.lock /phpunit.xml -/.phpunit.result.cache +/.phpunit.cache diff --git a/src/Cropperjs/composer.json b/src/Cropperjs/composer.json index 2531243b0ed..228fd9eb051 100644 --- a/src/Cropperjs/composer.json +++ b/src/Cropperjs/composer.json @@ -38,9 +38,9 @@ "symfony/validator": "^6.4|^7.0|^8.0" }, "require-dev": { + "phpunit/phpunit": "^11.1|^12.0", "symfony/expression-language": "^6.4|^7.0|^8.0", "symfony/framework-bundle": "^6.4|^7.0|^8.0", - "symfony/phpunit-bridge": "^7.2|^8.0", "symfony/twig-bundle": "^6.4|^7.0|^8.0", "symfony/var-dumper": "^6.4|^7.0|^8.0", "twig/twig": "^2.14.7|^3.0.4" diff --git a/src/Cropperjs/phpunit.xml.dist b/src/Cropperjs/phpunit.dist.xml similarity index 52% rename from src/Cropperjs/phpunit.xml.dist rename to src/Cropperjs/phpunit.dist.xml index c2213388a9b..dad877e4e25 100644 --- a/src/Cropperjs/phpunit.xml.dist +++ b/src/Cropperjs/phpunit.dist.xml @@ -2,16 +2,17 @@ - @@ -20,13 +21,18 @@ - + - ./src + src - - - - + + trigger_deprecation + + diff --git a/src/Cropperjs/tests/CropperjsBundleTest.php b/src/Cropperjs/tests/CropperjsBundleTest.php index 51f584caeda..919ace9d981 100644 --- a/src/Cropperjs/tests/CropperjsBundleTest.php +++ b/src/Cropperjs/tests/CropperjsBundleTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\Cropperjs\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpKernel\Kernel; use Symfony\UX\Cropperjs\Tests\Kernel\EmptyAppKernel; @@ -31,9 +32,7 @@ public static function provideKernels() yield 'twig' => [new TwigAppKernel('test', true)]; } - /** - * @dataProvider provideKernels - */ + #[DataProvider('provideKernels')] public function testBootKernel(Kernel $kernel) { $kernel->boot(); diff --git a/src/Cropperjs/tests/bootstrap.php b/src/Cropperjs/tests/bootstrap.php new file mode 100644 index 00000000000..89a23684510 --- /dev/null +++ b/src/Cropperjs/tests/bootstrap.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Symfony\Component\ErrorHandler\ErrorHandler; + +require __DIR__.'/../vendor/autoload.php'; + +// @see https://github.com/symfony/symfony/issues/53812 +ErrorHandler::register(null, false); From f5c1b6d17b525c00bbf99116f5f63e6f7691f6de Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Wed, 19 Nov 2025 08:42:01 +0100 Subject: [PATCH 05/17] [Dropzone] Drop Symfony PHPUnit Bridge in favor of PHPUnit >= 11.0 --- src/Dropzone/.gitignore | 2 +- src/Dropzone/composer.json | 2 +- .../{phpunit.xml.dist => phpunit.dist.xml} | 25 ++++++++++++------- src/Dropzone/tests/DropzoneBundleTest.php | 5 ++-- src/Dropzone/tests/bootstrap.php | 17 +++++++++++++ 5 files changed, 37 insertions(+), 14 deletions(-) rename src/Dropzone/{phpunit.xml.dist => phpunit.dist.xml} (52%) create mode 100644 src/Dropzone/tests/bootstrap.php diff --git a/src/Dropzone/.gitignore b/src/Dropzone/.gitignore index 2cc9f0231c3..095a90a8430 100644 --- a/src/Dropzone/.gitignore +++ b/src/Dropzone/.gitignore @@ -2,4 +2,4 @@ /vendor/ /composer.lock /phpunit.xml -/.phpunit.result.cache +/.phpunit.cache diff --git a/src/Dropzone/composer.json b/src/Dropzone/composer.json index 2231ff87ad0..53d364a85ce 100644 --- a/src/Dropzone/composer.json +++ b/src/Dropzone/composer.json @@ -36,8 +36,8 @@ "symfony/options-resolver": "^6.4|^7.0|^8.0" }, "require-dev": { + "phpunit/phpunit": "^11.1|^12.0", "symfony/framework-bundle": "^6.4|^7.0|^8.0", - "symfony/phpunit-bridge": "^7.2|^8.0", "symfony/twig-bundle": "^6.4|^7.0|^8.0", "symfony/var-dumper": "^6.4|^7.0|^8.0", "twig/twig": "^2.14.7|^3.0.4" diff --git a/src/Dropzone/phpunit.xml.dist b/src/Dropzone/phpunit.dist.xml similarity index 52% rename from src/Dropzone/phpunit.xml.dist rename to src/Dropzone/phpunit.dist.xml index 360207d3175..b1ce7e57d0f 100644 --- a/src/Dropzone/phpunit.xml.dist +++ b/src/Dropzone/phpunit.dist.xml @@ -2,16 +2,17 @@ - @@ -20,13 +21,19 @@ - + + - ./src + src - - - - + + trigger_deprecation + + diff --git a/src/Dropzone/tests/DropzoneBundleTest.php b/src/Dropzone/tests/DropzoneBundleTest.php index 6dcf2abbc1b..94aa5498f6c 100644 --- a/src/Dropzone/tests/DropzoneBundleTest.php +++ b/src/Dropzone/tests/DropzoneBundleTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\Dropzone\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpKernel\Kernel; use Symfony\UX\Dropzone\Tests\Kernel\EmptyAppKernel; @@ -31,9 +32,7 @@ public static function provideKernels() yield 'twig' => [new TwigAppKernel('test', true)]; } - /** - * @dataProvider provideKernels - */ + #[DataProvider('provideKernels')] public function testBootKernel(Kernel $kernel) { $kernel->boot(); diff --git a/src/Dropzone/tests/bootstrap.php b/src/Dropzone/tests/bootstrap.php new file mode 100644 index 00000000000..89a23684510 --- /dev/null +++ b/src/Dropzone/tests/bootstrap.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Symfony\Component\ErrorHandler\ErrorHandler; + +require __DIR__.'/../vendor/autoload.php'; + +// @see https://github.com/symfony/symfony/issues/53812 +ErrorHandler::register(null, false); From cbc0f2cab0aaedd6ea315a7b2f11bed868143065 Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Wed, 19 Nov 2025 08:42:05 +0100 Subject: [PATCH 06/17] [Icons] Drop Symfony PHPUnit Bridge in favor of PHPUnit >= 11.0 --- src/Icons/.gitignore | 3 +- src/Icons/composer.json | 2 +- .../{phpunit.xml.dist => phpunit.dist.xml} | 22 +++++---- .../Command/ImportIconCommandTest.php | 9 ++-- .../Command/LockIconsCommandTest.php | 9 ++-- src/Icons/tests/Unit/IconRendererTest.php | 11 ++--- src/Icons/tests/Unit/IconTest.php | 45 +++++-------------- src/Icons/tests/Unit/IconifyTest.php | 5 +-- .../Registry/LocalSvgIconRegistryTest.php | 13 ++---- src/Icons/tests/bootstrap.php | 5 ++- 10 files changed, 50 insertions(+), 74 deletions(-) rename src/Icons/{phpunit.xml.dist => phpunit.dist.xml} (58%) diff --git a/src/Icons/.gitignore b/src/Icons/.gitignore index 1784dd6561c..123c390f298 100644 --- a/src/Icons/.gitignore +++ b/src/Icons/.gitignore @@ -2,6 +2,7 @@ /vendor/ /composer.lock /phpunit.xml -/.phpunit.result.cache +/.phpunit.cache /var +/config/reference.php diff --git a/src/Icons/composer.json b/src/Icons/composer.json index a561c4ac79f..37df8cc1a9a 100644 --- a/src/Icons/composer.json +++ b/src/Icons/composer.json @@ -40,10 +40,10 @@ "symfony/twig-bundle": "^6.4|^7.0|^8.0" }, "require-dev": { + "phpunit/phpunit": "^11.1|^12.0", "symfony/asset-mapper": "^6.4|^7.0|^8.0", "symfony/console": "^6.4|^7.0|^8.0", "symfony/http-client": "^6.4|^7.0|^8.0", - "symfony/phpunit-bridge": "^7.2|^8.0", "symfony/ux-twig-component": "^2.14", "zenstruck/console-test": "^1.5", "psr/log": "^2|^3" diff --git a/src/Icons/phpunit.xml.dist b/src/Icons/phpunit.dist.xml similarity index 58% rename from src/Icons/phpunit.xml.dist rename to src/Icons/phpunit.dist.xml index ec32c7e2e44..12324b8c986 100644 --- a/src/Icons/phpunit.xml.dist +++ b/src/Icons/phpunit.dist.xml @@ -2,16 +2,17 @@ - @@ -21,13 +22,18 @@ - + - ./src + src - - - - + + trigger_deprecation + + diff --git a/src/Icons/tests/Integration/Command/ImportIconCommandTest.php b/src/Icons/tests/Integration/Command/ImportIconCommandTest.php index 1e007364724..414b47e9f3f 100644 --- a/src/Icons/tests/Integration/Command/ImportIconCommandTest.php +++ b/src/Icons/tests/Integration/Command/ImportIconCommandTest.php @@ -11,6 +11,8 @@ namespace Symfony\UX\Icons\Tests\Integration\Command; +use PHPUnit\Framework\Attributes\After; +use PHPUnit\Framework\Attributes\Before; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\Filesystem\Filesystem; use Zenstruck\Console\Test\InteractsWithConsole; @@ -25,11 +27,8 @@ final class ImportIconCommandTest extends KernelTestCase private const ICON_DIR = __DIR__.'/../../Fixtures/icons'; private const ICONS = ['uiw/dashboard.svg', 'lucide/circle.svg']; - /** - * @before - * - * @after - */ + #[Before] + #[After] public static function cleanup(): void { $fs = new Filesystem(); diff --git a/src/Icons/tests/Integration/Command/LockIconsCommandTest.php b/src/Icons/tests/Integration/Command/LockIconsCommandTest.php index b7e8a005052..836aff16119 100644 --- a/src/Icons/tests/Integration/Command/LockIconsCommandTest.php +++ b/src/Icons/tests/Integration/Command/LockIconsCommandTest.php @@ -11,6 +11,8 @@ namespace Symfony\UX\Icons\Tests\Integration\Command; +use PHPUnit\Framework\Attributes\After; +use PHPUnit\Framework\Attributes\Before; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\Filesystem\Filesystem; use Zenstruck\Console\Test\InteractsWithConsole; @@ -29,11 +31,8 @@ final class LockIconsCommandTest extends KernelTestCase __DIR__.'/../../Fixtures/icons/lucide/circle-off.svg', ]; - /** - * @before - * - * @after - */ + #[Before] + #[After] public static function cleanup(): void { $fs = new Filesystem(); diff --git a/src/Icons/tests/Unit/IconRendererTest.php b/src/Icons/tests/Unit/IconRendererTest.php index 03193363175..0d094d1093f 100644 --- a/src/Icons/tests/Unit/IconRendererTest.php +++ b/src/Icons/tests/Unit/IconRendererTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\Icons\Tests\Unit; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\UX\Icons\Exception\IconNotFoundException; use Symfony\UX\Icons\Icon; @@ -81,9 +82,7 @@ public function testRenderIconWithDefaultAttributes() $this->assertSame('', $svg); } - /** - * @dataProvider provideRenderIconWithAttributeCascadeCases - */ + #[DataProvider('provideRenderIconWithAttributeCascadeCases')] public function testRenderIconWithAttributeCascade( array $iconAttributes, array $defaultAttributes = [], @@ -276,11 +275,10 @@ public static function provideRenderIconWithAttributeCascadeCases(): iterable } /** - * @dataProvider provideAriaHiddenCases - * * @param string|array{string, array} $icon * @param array $attributes */ + #[DataProvider('provideAriaHiddenCases')] public function testRenderIconWithAutoAriaHidden(string|array $icon, array $attributes, string $expectedSvg) { $icon = (array) $icon; @@ -366,9 +364,8 @@ public function testRenderIconWithAliases() /** * @param array $attributes - * - * @dataProvider provideRenderIconWithIconSetAttributes */ + #[DataProvider('provideRenderIconWithIconSetAttributes')] public function testRenderIconWithIconSetAttributes(string $name, array $attributes, string $expectedSvg) { $registry = $this->createRegistry([ diff --git a/src/Icons/tests/Unit/IconTest.php b/src/Icons/tests/Unit/IconTest.php index 3c4c91dba7d..c7343978711 100644 --- a/src/Icons/tests/Unit/IconTest.php +++ b/src/Icons/tests/Unit/IconTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\Icons\Tests\Unit; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\UX\Icons\Icon; @@ -23,17 +24,13 @@ public function testConstructor() $this->assertSame('bar', $icon->getAttributes()['foo']); } - /** - * @dataProvider provideIdToName - */ + #[DataProvider('provideIdToName')] public function testIdToName(string $id, string $name) { $this->assertSame($name, Icon::idToName($id)); } - /** - * @dataProvider provideInvalidIds - */ + #[DataProvider('provideInvalidIds')] public function testIdToNameThrowsException(string $id) { $this->expectException(\InvalidArgumentException::class); @@ -42,17 +39,13 @@ public function testIdToNameThrowsException(string $id) Icon::idToName($id); } - /** - * @dataProvider provideNameToId - */ + #[DataProvider('provideNameToId')] public function testNameToId(string $name, string $id) { $this->assertEquals($id, Icon::nameToId($name)); } - /** - * @dataProvider provideInvalidNames - */ + #[DataProvider('provideInvalidNames')] public function testNameToIdThrowsException(string $name) { $this->expectException(\InvalidArgumentException::class); @@ -61,41 +54,31 @@ public function testNameToIdThrowsException(string $name) Icon::nameToId($name); } - /** - * @dataProvider provideValidIds - */ + #[DataProvider('provideValidIds')] public function testIsValidIdWithValidIds(string $id) { $this->assertTrue(Icon::isValidId($id)); } - /** - * @dataProvider provideInvalidIds - */ + #[DataProvider('provideInvalidIds')] public function testIsValidIdWithInvalidIds(string $id) { $this->assertFalse(Icon::isValidId($id)); } - /** - * @dataProvider provideValidNames - */ + #[DataProvider('provideValidNames')] public function testIsValidNameWithValidNames(string $name) { $this->assertTrue(Icon::isValidName($name)); } - /** - * @dataProvider provideInvalidNames - */ + #[DataProvider('provideInvalidNames')] public function testIsValidNameWithInvalidNames(string $name) { $this->assertFalse(Icon::isValidName($name)); } - /** - * @dataProvider provideInvalidIds - */ + #[DataProvider('provideInvalidIds')] public function testInvalidIdToName(string $id) { $this->expectException(\InvalidArgumentException::class); @@ -105,18 +88,14 @@ public function testInvalidIdToName(string $id) Icon::idToName($id); } - /** - * @dataProvider provideRenderAttributesTestCases - */ + #[DataProvider('provideRenderAttributesTestCases')] public function testRenderAttributes(array $attributes, string $expected) { $icon = new Icon('', $attributes); $this->assertStringStartsWith($expected, $icon->toHtml()); } - /** - * @dataProvider provideWithAttributesTestCases - */ + #[DataProvider('provideWithAttributesTestCases')] public function testWithAttributes(array $attributes, array $withAttributes, array $expected) { $icon = new Icon('foo', $attributes); diff --git a/src/Icons/tests/Unit/IconifyTest.php b/src/Icons/tests/Unit/IconifyTest.php index b4686378a73..cdaaea5655c 100644 --- a/src/Icons/tests/Unit/IconifyTest.php +++ b/src/Icons/tests/Unit/IconifyTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\Icons\Tests\Unit; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Cache\Adapter\NullAdapter; use Symfony\Component\HttpClient\MockHttpClient; @@ -279,9 +280,7 @@ public function testGetMetadata() $this->assertSame('Font Awesome Solid', $metadata['name']); } - /** - * @dataProvider provideChunkCases - */ + #[DataProvider('provideChunkCases')] public function testChunk(int $maxQueryLength, string $prefix, array $names, array $chunks) { $iconify = new Iconify( diff --git a/src/Icons/tests/Unit/Registry/LocalSvgIconRegistryTest.php b/src/Icons/tests/Unit/Registry/LocalSvgIconRegistryTest.php index 2c8e7502114..133b700bfca 100644 --- a/src/Icons/tests/Unit/Registry/LocalSvgIconRegistryTest.php +++ b/src/Icons/tests/Unit/Registry/LocalSvgIconRegistryTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\Icons\Tests\Unit\Registry; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\UX\Icons\Icon; use Symfony\UX\Icons\Registry\LocalSvgIconRegistry; @@ -20,9 +21,7 @@ */ final class LocalSvgIconRegistryTest extends TestCase { - /** - * @dataProvider validSvgProvider - */ + #[DataProvider('validSvgProvider')] public function testValidSvgs(string $name, array $expectedAttributes, string $expectedContent) { $icon = $this->registry()->get($name); @@ -64,9 +63,7 @@ public static function validSvgProvider(): iterable ]; } - /** - * @dataProvider invalidSvgProvider - */ + #[DataProvider('invalidSvgProvider')] public function testInvalidSvgs(string $name) { $this->expectException(\RuntimeException::class); @@ -82,9 +79,7 @@ public static function invalidSvgProvider(): iterable yield ['invalid4']; } - /** - * @dataProvider provideIconSetPathsCases - */ + #[DataProvider('provideIconSetPathsCases')] public function testIconSetPaths(string $name, array $iconSetPaths, ?string $expectedContent) { $registry = new LocalSvgIconRegistry( diff --git a/src/Icons/tests/bootstrap.php b/src/Icons/tests/bootstrap.php index 3a6f67b1c33..89a23684510 100644 --- a/src/Icons/tests/bootstrap.php +++ b/src/Icons/tests/bootstrap.php @@ -9,8 +9,9 @@ * file that was distributed with this source code. */ -use Symfony\Component\Filesystem\Filesystem; +use Symfony\Component\ErrorHandler\ErrorHandler; require __DIR__.'/../vendor/autoload.php'; -(new Filesystem())->remove(__DIR__.'/../var'); +// @see https://github.com/symfony/symfony/issues/53812 +ErrorHandler::register(null, false); From 18fbdf92bed9aa89e1ecabbe73726bd2edef6c8e Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Wed, 19 Nov 2025 08:42:11 +0100 Subject: [PATCH 07/17] [LiveComponent] Drop Symfony PHPUnit Bridge in favor of PHPUnit >= 11.0 --- src/LiveComponent/.gitignore | 4 ++- src/LiveComponent/composer.json | 4 +-- .../{phpunit.xml.dist => phpunit.dist.xml} | 24 +++++++++------ .../DeferLiveComponentSubscriberTest.php | 5 ++-- .../LiveComponentSubscriberTest.php | 21 ++++---------- .../EventListener/LiveUrlSubscriberTest.php | 11 ++++--- .../Util/RequestPropsExtractorTest.php | 7 ++--- .../Integration/LiveComponentHydratorTest.php | 20 +++++-------- .../DeferLiveComponentSubscriberTest.php | 8 ++--- .../tests/Unit/LiveCollectionTraitTest.php | 5 ++-- .../Unit/Metadata/LivePropMetadataTest.php | 29 ++++++++----------- .../tests/Unit/Util/LiveFormUtilityTest.php | 9 ++---- .../Unit/Util/ModelBindingParserTest.php | 5 ++-- src/LiveComponent/tests/bootstrap.php | 17 +++++++++++ 14 files changed, 82 insertions(+), 87 deletions(-) rename src/LiveComponent/{phpunit.xml.dist => phpunit.dist.xml} (58%) create mode 100644 src/LiveComponent/tests/bootstrap.php diff --git a/src/LiveComponent/.gitignore b/src/LiveComponent/.gitignore index 6c06c7ffa62..123c390f298 100644 --- a/src/LiveComponent/.gitignore +++ b/src/LiveComponent/.gitignore @@ -2,5 +2,7 @@ /vendor/ /composer.lock /phpunit.xml -/.phpunit.result.cache +/.phpunit.cache + /var +/config/reference.php diff --git a/src/LiveComponent/composer.json b/src/LiveComponent/composer.json index 5225932eef8..2e20ed37dc6 100644 --- a/src/LiveComponent/composer.json +++ b/src/LiveComponent/composer.json @@ -41,18 +41,18 @@ "doctrine/orm": "^2.9.4|^3.0", "doctrine/persistence": "^2.5.2|^3.0", "phpdocumentor/reflection-docblock": "5.x-dev", + "phpunit/phpunit": "^11.1|^12.0", "symfony/dependency-injection": "^6.4|^7.0|^8.0", "symfony/expression-language": "^6.4|^7.0|^8.0", "symfony/form": "^6.4|^7.0|^8.0", "symfony/framework-bundle": "^6.4|^7.0|^8.0", "symfony/options-resolver": "^6.4|^7.0|^8.0", - "symfony/phpunit-bridge": "^7.2|^8.0", "symfony/security-bundle": "^6.4|^7.0|^8.0", "symfony/serializer": "^6.4|^7.0|^8.0", "symfony/twig-bundle": "^6.4|^7.0|^8.0", "symfony/uid": "^6.4|^7.0|^8.0", "symfony/validator": "^6.4|^7.0|^8.0", - "zenstruck/browser": "^1.2.0", + "zenstruck/browser": "^1.9", "zenstruck/foundry": "^2.0" }, "conflict": { diff --git a/src/LiveComponent/phpunit.xml.dist b/src/LiveComponent/phpunit.dist.xml similarity index 58% rename from src/LiveComponent/phpunit.xml.dist rename to src/LiveComponent/phpunit.dist.xml index feed5201511..eb8bf374971 100644 --- a/src/LiveComponent/phpunit.xml.dist +++ b/src/LiveComponent/phpunit.dist.xml @@ -2,16 +2,17 @@ - @@ -22,13 +23,18 @@ - + - ./src + src - - - - + + trigger_deprecation + + diff --git a/src/LiveComponent/tests/Functional/EventListener/DeferLiveComponentSubscriberTest.php b/src/LiveComponent/tests/Functional/EventListener/DeferLiveComponentSubscriberTest.php index a979283a761..c7fdd302fc6 100644 --- a/src/LiveComponent/tests/Functional/EventListener/DeferLiveComponentSubscriberTest.php +++ b/src/LiveComponent/tests/Functional/EventListener/DeferLiveComponentSubscriberTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\LiveComponent\Tests\Functional\EventListener; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\UX\LiveComponent\Tests\LiveComponentTestHelper; use Zenstruck\Browser\Test\HasBrowser; @@ -122,9 +123,7 @@ public function testLazyComponentIsNotRendered() $this->assertSame('live:appear->live#$render', $div->attr('data-action')); } - /** - * @dataProvider provideLoadingValues - */ + #[DataProvider('provideLoadingValues')] public function testLazyComponentRenderingDependsOnLazyValue(mixed $lazy, bool $isRendered) { $crawler = $this->browser() diff --git a/src/LiveComponent/tests/Functional/EventListener/LiveComponentSubscriberTest.php b/src/LiveComponent/tests/Functional/EventListener/LiveComponentSubscriberTest.php index ef29bb2174a..e1d3ae5645e 100644 --- a/src/LiveComponent/tests/Functional/EventListener/LiveComponentSubscriberTest.php +++ b/src/LiveComponent/tests/Functional/EventListener/LiveComponentSubscriberTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\LiveComponent\Tests\Functional\EventListener; +use PHPUnit\Framework\Attributes\Group; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\Security\Core\User\InMemoryUser; use Symfony\Component\Security\Http\Attribute\IsGranted; @@ -91,9 +92,7 @@ public function testCanRenderComponentAsHtmlWithAlternateRoute() ; } - /** - * @group transient-on-windows - */ + #[Group('transient-on-windows')] public function testCanExecuteComponentActionNormalRoute() { $templateName = 'render_embedded_with_blocks.html.twig'; @@ -192,9 +191,7 @@ public function testPreReRenderHookOnlyExecutedDuringAjax() ; } - /** - * @group transient-on-windows - */ + #[Group('transient-on-windows')] public function testItAddsEmbeddedTemplateContextToEmbeddedComponents() { $templateName = 'render_embedded_with_blocks.html.twig'; @@ -232,9 +229,7 @@ public function testItAddsEmbeddedTemplateContextToEmbeddedComponents() ; } - /** - * @group transient-on-windows - */ + #[Group('transient-on-windows')] public function testItWorksWithNamespacedTemplateNamesForEmbeddedComponents() { $templateName = 'render_embedded_with_blocks.html.twig'; @@ -248,9 +243,7 @@ public function testItWorksWithNamespacedTemplateNamesForEmbeddedComponents() ; } - /** - * @group transient-on-windows - */ + #[Group('transient-on-windows')] public function testItUseBlocksFromEmbeddedContextUsingMultipleComponents() { $templateName = 'render_multiple_embedded_with_blocks.html.twig'; @@ -283,9 +276,7 @@ public function testItUseBlocksFromEmbeddedContextUsingMultipleComponents() ; } - /** - * @group transient-on-windows - */ + #[Group('transient-on-windows')] public function testItUseBlocksFromEmbeddedContextUsingMultipleComponentsWithNamespacedTemplate() { $templateName = 'render_multiple_embedded_with_blocks.html.twig'; diff --git a/src/LiveComponent/tests/Functional/EventListener/LiveUrlSubscriberTest.php b/src/LiveComponent/tests/Functional/EventListener/LiveUrlSubscriberTest.php index 91224e668f1..9641953b6ca 100644 --- a/src/LiveComponent/tests/Functional/EventListener/LiveUrlSubscriberTest.php +++ b/src/LiveComponent/tests/Functional/EventListener/LiveUrlSubscriberTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\LiveComponent\Tests\Functional\EventListener; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\UX\LiveComponent\Tests\Fixtures\Dto\Address; use Symfony\UX\LiveComponent\Tests\LiveComponentTestHelper; @@ -21,7 +22,7 @@ class LiveUrlSubscriberTest extends KernelTestCase use HasBrowser; use LiveComponentTestHelper; - public function getTestData(): iterable + public static function getTestData(): iterable { yield 'Missing header' => [ 'previousLocation' => null, @@ -229,16 +230,14 @@ public function getTestData(): iterable ]; } - /** - * @dataProvider getTestData - */ + #[DataProvider('getTestData')] public function testNewLiveUrlAfterLiveAction( ?string $previousLocation, ?string $expectedLocation, - array $initalComponentData, + array $initialComponentData, array $args, ): void { - $component = $this->mountComponent('component_with_url_bound_props', $initalComponentData); + $component = $this->mountComponent('component_with_url_bound_props', $initialComponentData); $dehydrated = $this->dehydrateComponent($component); $this->browser() diff --git a/src/LiveComponent/tests/Functional/Util/RequestPropsExtractorTest.php b/src/LiveComponent/tests/Functional/Util/RequestPropsExtractorTest.php index 80bbb738323..abae06bcb37 100644 --- a/src/LiveComponent/tests/Functional/Util/RequestPropsExtractorTest.php +++ b/src/LiveComponent/tests/Functional/Util/RequestPropsExtractorTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\LiveComponent\Tests\Functional\Util; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\UX\LiveComponent\Metadata\LiveComponentMetadataFactory; @@ -22,9 +23,7 @@ class RequestPropsExtractorTest extends KernelTestCase { use LiveComponentTestHelper; - /** - * @dataProvider getQueryStringTests - */ + #[DataProvider('getQueryStringTests')] public function testExtractFromQueryString(string $queryString, array $expected, array $attributes = []) { $extractor = new RequestPropsExtractor($this->hydrator()); @@ -43,7 +42,7 @@ public function testExtractFromQueryString(string $queryString, array $expected, $this->assertEquals($expected, $data); } - public function getQueryStringTests(): iterable + public static function getQueryStringTests(): iterable { yield from [ 'no query string' => ['', []], diff --git a/src/LiveComponent/tests/Integration/LiveComponentHydratorTest.php b/src/LiveComponent/tests/Integration/LiveComponentHydratorTest.php index f34715299c3..ec86e874b5e 100644 --- a/src/LiveComponent/tests/Integration/LiveComponentHydratorTest.php +++ b/src/LiveComponent/tests/Integration/LiveComponentHydratorTest.php @@ -11,6 +11,8 @@ namespace Symfony\UX\LiveComponent\Tests\Integration; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\Uid\Ulid; @@ -153,10 +155,8 @@ private function executeHydrationTestCase(callable $testFactory, ?int $minPhpVer $this->assertEquals($componentAfterHydration, $hydratedComponent2, 'After another round of (de)hydration, things still match'); } - /** - * @group transient-on-windows - * @dataProvider provideDehydrationHydrationTests - */ + #[Group('transient-on-windows')] + #[DataProvider('provideDehydrationHydrationTests')] public function testCanDehydrateAndHydrateComponentWithTestCases(callable $testFactory, ?int $minPhpVersion = null) { $this->executeHydrationTestCase($testFactory, $minPhpVersion); @@ -1636,9 +1636,7 @@ public function testInterfaceTypedLivePropCannotBeDehydrated() $this->hydrator()->dehydrate($component, $this->createComponentAttributes(), $this->createLiveMetadata($component)); } - /** - * @dataProvider provideInvalidHydrationTests - */ + #[DataProvider('provideInvalidHydrationTests')] public function testInvalidTypeHydration(callable $testFactory, ?int $minPhpVersion = null) { $this->executeHydrationTestCase($testFactory, $minPhpVersion); @@ -1897,9 +1895,7 @@ public function testCanDehydrateAndHydrateComponentsWithEmptyAttributes() $this->assertSame([], $actualAttributes->all()); } - /** - * @dataProvider truthyValueProvider - */ + #[DataProvider('truthyValueProvider')] public function testCoerceTruthyValuesForScalarTypes($prop, $value, $expected) { $dehydratedProps = $this->dehydrateComponent($this->mountComponent('scalar_types'))->getProps(); @@ -1911,9 +1907,7 @@ public function testCoerceTruthyValuesForScalarTypes($prop, $value, $expected) $this->assertSame($expected, $hydratedComponent->$prop); } - /** - * @dataProvider falseyValueProvider - */ + #[DataProvider('falseyValueProvider')] public function testCoerceFalseyValuesForScalarTypes($prop, $value, $expected) { $dehydratedProps = $this->dehydrateComponent($this->mountComponent('scalar_types'))->getProps(); diff --git a/src/LiveComponent/tests/Unit/EventListener/DeferLiveComponentSubscriberTest.php b/src/LiveComponent/tests/Unit/EventListener/DeferLiveComponentSubscriberTest.php index 741de46c486..4dba7ab6d1f 100644 --- a/src/LiveComponent/tests/Unit/EventListener/DeferLiveComponentSubscriberTest.php +++ b/src/LiveComponent/tests/Unit/EventListener/DeferLiveComponentSubscriberTest.php @@ -11,8 +11,8 @@ namespace Symfony\UX\LiveComponent\Tests\Unit\EventListener; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; -use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; use Symfony\UX\LiveComponent\EventListener\DeferLiveComponentSubscriber; use Symfony\UX\TwigComponent\ComponentMetadata; use Symfony\UX\TwigComponent\Event\PostMountEvent; @@ -22,8 +22,6 @@ */ class DeferLiveComponentSubscriberTest extends TestCase { - use ExpectDeprecationTrait; - public function testLoadingAttributeIsExtracted() { $subscriber = new DeferLiveComponentSubscriber(); @@ -65,9 +63,7 @@ public function testLoadingAttributesAreRemoved() $this->assertArrayNotHasKey('loading-tag', $event->getData()); } - /** - * @dataProvider provideInvalidLoadingValues - */ + #[DataProvider('provideInvalidLoadingValues')] public function testInvalidLoadingValuesThrows(mixed $value) { $subscriber = new DeferLiveComponentSubscriber(); diff --git a/src/LiveComponent/tests/Unit/LiveCollectionTraitTest.php b/src/LiveComponent/tests/Unit/LiveCollectionTraitTest.php index 12e92730e77..2280912cafc 100644 --- a/src/LiveComponent/tests/Unit/LiveCollectionTraitTest.php +++ b/src/LiveComponent/tests/Unit/LiveCollectionTraitTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\LiveComponent\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Form\FormInterface; use Symfony\Component\PropertyAccess\PropertyAccess; @@ -21,7 +22,7 @@ */ final class LiveCollectionTraitTest extends TestCase { - /** @dataProvider provideAddedItems */ + #[DataProvider('provideAddedItems')] public function testAddCollectionItem(array $postedFormData, string $collectionFieldName, array $expectedFormData) { $component = $this->createComponent($postedFormData); @@ -31,7 +32,7 @@ public function testAddCollectionItem(array $postedFormData, string $collectionF self::assertSame($expectedFormData[$component->formName], $component->formValues); } - /** @dataProvider provideRemovedItems */ + #[DataProvider('provideRemovedItems')] public function testRemoveCollectionItem(array $postedFormData, string $collectionFieldName, int $index, array $expectedFormData) { $component = $this->createComponent($postedFormData); diff --git a/src/LiveComponent/tests/Unit/Metadata/LivePropMetadataTest.php b/src/LiveComponent/tests/Unit/Metadata/LivePropMetadataTest.php index b3ffd9f1bfa..10811344ae8 100644 --- a/src/LiveComponent/tests/Unit/Metadata/LivePropMetadataTest.php +++ b/src/LiveComponent/tests/Unit/Metadata/LivePropMetadataTest.php @@ -22,15 +22,12 @@ public function testWithModifier() $liveProp = new LiveProp(modifier: 'modifyProp'); $livePropMetadata = new LivePropMetadata('propWithModifier', $liveProp, null, false, false, null); - $component = $this->getMockBuilder(\stdClass::class) - ->addMethods(['modifyProp']) - ->getMock(); - - $component - ->expects($this->once()) - ->method('modifyProp') - ->with($liveProp, 'propWithModifier') - ->willReturn($liveProp->withFieldName('customField')); + $component = new class { + public function modifyProp(LiveProp $liveProp, string $propertyName): LiveProp + { + return $liveProp->withFieldName('customField'); + } + }; $livePropMetadata = $livePropMetadata->withModifier($component); @@ -53,14 +50,12 @@ public function testWithModifierThrowsAnErrorIfModifierMethodDoesNotReturnLivePr $liveProp = new LiveProp(modifier: 'modifyProp'); $livePropMetadata = new LivePropMetadata('propWithModifier', $liveProp, null, false, false, null); - $component = $this->getMockBuilder(\stdClass::class) - ->addMethods(['modifyProp']) - ->getMock(); - - $component - ->expects($this->once()) - ->method('modifyProp') - ->willReturn(false); + $component = new class { + public function modifyProp(LiveProp $liveProp, string $propertyName) + { + return false; + } + }; $this->expectException(\LogicException::class); $this->expectExceptionMessageMatches(\sprintf('/Method ".*::modifyProp\(\)" should return an instance of "%s" \(given: "bool"\)\./', preg_quote(LiveProp::class))); diff --git a/src/LiveComponent/tests/Unit/Util/LiveFormUtilityTest.php b/src/LiveComponent/tests/Unit/Util/LiveFormUtilityTest.php index c6357d17406..cc0a449ea36 100644 --- a/src/LiveComponent/tests/Unit/Util/LiveFormUtilityTest.php +++ b/src/LiveComponent/tests/Unit/Util/LiveFormUtilityTest.php @@ -11,15 +11,14 @@ namespace Symfony\UX\LiveComponent\Tests\Unit\Util; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Form\FormView; use Symfony\UX\LiveComponent\Util\LiveFormUtility; final class LiveFormUtilityTest extends TestCase { - /** - * @dataProvider getPathsTests - */ + #[DataProvider('getPathsTests')] public function testRemovePathsNotInData(array $inputPaths, array $inputData, array $expectedPaths) { $this->assertEquals($expectedPaths, LiveFormUtility::removePathsNotInData($inputPaths, $inputData)); @@ -63,9 +62,7 @@ public static function getPathsTests(): iterable ]; } - /** - * @dataProvider provideFormContainsAnyErrorsTests - */ + #[DataProvider('provideFormContainsAnyErrorsTests')] public function testDoesFormContainAnyErrors(FormView $formView, bool $expected) { $this->assertSame($expected, LiveFormUtility::doesFormContainAnyErrors($formView)); diff --git a/src/LiveComponent/tests/Unit/Util/ModelBindingParserTest.php b/src/LiveComponent/tests/Unit/Util/ModelBindingParserTest.php index e8220b59c85..926f8daacf2 100644 --- a/src/LiveComponent/tests/Unit/Util/ModelBindingParserTest.php +++ b/src/LiveComponent/tests/Unit/Util/ModelBindingParserTest.php @@ -11,14 +11,13 @@ namespace Symfony\UX\LiveComponent\Tests\Unit\Util; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\UX\LiveComponent\Util\ModelBindingParser; final class ModelBindingParserTest extends TestCase { - /** - * @dataProvider getModelStringTests - */ + #[DataProvider('getModelStringTests')] public function testParseAllValidStrings(string $input, array $expectedBindings) { $parser = new ModelBindingParser(); diff --git a/src/LiveComponent/tests/bootstrap.php b/src/LiveComponent/tests/bootstrap.php new file mode 100644 index 00000000000..89a23684510 --- /dev/null +++ b/src/LiveComponent/tests/bootstrap.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Symfony\Component\ErrorHandler\ErrorHandler; + +require __DIR__.'/../vendor/autoload.php'; + +// @see https://github.com/symfony/symfony/issues/53812 +ErrorHandler::register(null, false); From 0b6a1a6ef16a4096d9ed143f14747adc5655d550 Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Wed, 19 Nov 2025 08:42:21 +0100 Subject: [PATCH 08/17] [Map] Drop Symfony PHPUnit Bridge in favor of PHPUnit >= 11.0 --- src/Map/.gitignore | 8 ++++--- src/Map/composer.json | 5 ++-- .../{phpunit.xml.dist => phpunit.dist.xml} | 23 +++++++++++------- src/Map/src/Bridge/Google/.gitignore | 8 ++++--- src/Map/src/Bridge/Google/composer.json | 5 ++-- .../{phpunit.xml.dist => phpunit.dist.xml} | 24 ++++++++++++------- src/Map/src/Bridge/Google/tests/bootstrap.php | 17 +++++++++++++ src/Map/src/Bridge/Leaflet/.gitignore | 8 ++++--- src/Map/src/Bridge/Leaflet/composer.json | 5 ++-- .../{phpunit.xml.dist => phpunit.dist.xml} | 24 ++++++++++++------- .../src/Bridge/Leaflet/tests/bootstrap.php | 17 +++++++++++++ .../Cluster/ClusteringPerformanceTest.php | 10 ++++---- .../tests/Distance/DistanceCalculatorTest.php | 4 ++-- src/Map/tests/Distance/DistanceUnitTest.php | 5 ++-- src/Map/tests/IconTest.php | 16 ++++--------- src/Map/tests/MapTest.php | 15 ++++++------ src/Map/tests/PointTest.php | 5 ++-- src/Map/tests/Renderer/DsnTest.php | 9 +++---- src/Map/tests/Renderer/NullRendererTest.php | 13 +++++----- src/Map/tests/Twig/MapExtensionTest.php | 3 --- src/Map/tests/UXMapBundleTest.php | 7 +++--- src/Map/tests/bootstrap.php | 17 +++++++++++++ 22 files changed, 151 insertions(+), 97 deletions(-) rename src/Map/{phpunit.xml.dist => phpunit.dist.xml} (55%) rename src/Map/src/Bridge/Google/{phpunit.xml.dist => phpunit.dist.xml} (52%) create mode 100644 src/Map/src/Bridge/Google/tests/bootstrap.php rename src/Map/src/Bridge/Leaflet/{phpunit.xml.dist => phpunit.dist.xml} (52%) create mode 100644 src/Map/src/Bridge/Leaflet/tests/bootstrap.php create mode 100644 src/Map/tests/bootstrap.php diff --git a/src/Map/.gitignore b/src/Map/.gitignore index 50b321e33a2..095a90a8430 100644 --- a/src/Map/.gitignore +++ b/src/Map/.gitignore @@ -1,3 +1,5 @@ -vendor -composer.lock -.phpunit.result.cache +/assets/node_modules/ +/vendor/ +/composer.lock +/phpunit.xml +/.phpunit.cache diff --git a/src/Map/composer.json b/src/Map/composer.json index 23c4684dd18..0e4993a7da6 100644 --- a/src/Map/composer.json +++ b/src/Map/composer.json @@ -38,12 +38,11 @@ "require-dev": { "symfony/asset-mapper": "^6.4|^7.0|^8.0", "symfony/framework-bundle": "^6.4|^7.0|^8.0", - "symfony/phpunit-bridge": "^7.2|^8.0", + "phpunit/phpunit": "^11.1|^12.0", "symfony/twig-bundle": "^6.4|^7.0|^8.0", "symfony/ux-twig-component": "^2.18|^8.0", "symfony/ux-icons": "^2.18", - "spatie/phpunit-snapshot-assertions": "^4.2.17|^5.2.3", - "phpunit/phpunit": "^9.6.22" + "spatie/phpunit-snapshot-assertions": "^5.2.3" }, "conflict": { "symfony/ux-twig-component": "<2.21" diff --git a/src/Map/phpunit.xml.dist b/src/Map/phpunit.dist.xml similarity index 55% rename from src/Map/phpunit.xml.dist rename to src/Map/phpunit.dist.xml index 49fe75b856a..1ed6b714ccc 100644 --- a/src/Map/phpunit.xml.dist +++ b/src/Map/phpunit.dist.xml @@ -2,11 +2,13 @@ @@ -20,13 +22,18 @@ - + - ./src + src - - - - + + trigger_deprecation + + diff --git a/src/Map/src/Bridge/Google/.gitignore b/src/Map/src/Bridge/Google/.gitignore index c49a5d8df5c..095a90a8430 100644 --- a/src/Map/src/Bridge/Google/.gitignore +++ b/src/Map/src/Bridge/Google/.gitignore @@ -1,3 +1,5 @@ -vendor/ -composer.lock -phpunit.xml +/assets/node_modules/ +/vendor/ +/composer.lock +/phpunit.xml +/.phpunit.cache diff --git a/src/Map/src/Bridge/Google/composer.json b/src/Map/src/Bridge/Google/composer.json index cac29784247..c859ae52de2 100644 --- a/src/Map/src/Bridge/Google/composer.json +++ b/src/Map/src/Bridge/Google/composer.json @@ -21,10 +21,9 @@ "symfony/ux-map": "^2.19" }, "require-dev": { - "symfony/phpunit-bridge": "^7.2|^8.0", + "phpunit/phpunit": "^11.1|^12.0", "symfony/ux-icons": "^2.18", - "spatie/phpunit-snapshot-assertions": "^4.2.17|^5.2.3", - "phpunit/phpunit": "^9.6.22" + "spatie/phpunit-snapshot-assertions": "^5.2.3" }, "autoload": { "psr-4": { "Symfony\\UX\\Map\\Bridge\\Google\\": "src/" }, diff --git a/src/Map/src/Bridge/Google/phpunit.xml.dist b/src/Map/src/Bridge/Google/phpunit.dist.xml similarity index 52% rename from src/Map/src/Bridge/Google/phpunit.xml.dist rename to src/Map/src/Bridge/Google/phpunit.dist.xml index b7d1271f870..e03a1fc6e10 100644 --- a/src/Map/src/Bridge/Google/phpunit.xml.dist +++ b/src/Map/src/Bridge/Google/phpunit.dist.xml @@ -2,16 +2,17 @@ - @@ -20,13 +21,18 @@ - + - ./src + src - - - - + + trigger_deprecation + + diff --git a/src/Map/src/Bridge/Google/tests/bootstrap.php b/src/Map/src/Bridge/Google/tests/bootstrap.php new file mode 100644 index 00000000000..89a23684510 --- /dev/null +++ b/src/Map/src/Bridge/Google/tests/bootstrap.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Symfony\Component\ErrorHandler\ErrorHandler; + +require __DIR__.'/../vendor/autoload.php'; + +// @see https://github.com/symfony/symfony/issues/53812 +ErrorHandler::register(null, false); diff --git a/src/Map/src/Bridge/Leaflet/.gitignore b/src/Map/src/Bridge/Leaflet/.gitignore index c49a5d8df5c..095a90a8430 100644 --- a/src/Map/src/Bridge/Leaflet/.gitignore +++ b/src/Map/src/Bridge/Leaflet/.gitignore @@ -1,3 +1,5 @@ -vendor/ -composer.lock -phpunit.xml +/assets/node_modules/ +/vendor/ +/composer.lock +/phpunit.xml +/.phpunit.cache diff --git a/src/Map/src/Bridge/Leaflet/composer.json b/src/Map/src/Bridge/Leaflet/composer.json index b86071d68a2..535a820d722 100644 --- a/src/Map/src/Bridge/Leaflet/composer.json +++ b/src/Map/src/Bridge/Leaflet/composer.json @@ -21,10 +21,9 @@ "symfony/ux-map": "^2.19" }, "require-dev": { - "symfony/phpunit-bridge": "^7.2|^8.0", + "phpunit/phpunit": "^11.1|^12.0", "symfony/ux-icons": "^2.18", - "spatie/phpunit-snapshot-assertions": "^4.2.17|^5.2.3", - "phpunit/phpunit": "^9.6.22" + "spatie/phpunit-snapshot-assertions": "^5.2.3" }, "autoload": { "psr-4": { "Symfony\\UX\\Map\\Bridge\\Leaflet\\": "src/" }, diff --git a/src/Map/src/Bridge/Leaflet/phpunit.xml.dist b/src/Map/src/Bridge/Leaflet/phpunit.dist.xml similarity index 52% rename from src/Map/src/Bridge/Leaflet/phpunit.xml.dist rename to src/Map/src/Bridge/Leaflet/phpunit.dist.xml index 0a4ff1cee04..64e6aa61587 100644 --- a/src/Map/src/Bridge/Leaflet/phpunit.xml.dist +++ b/src/Map/src/Bridge/Leaflet/phpunit.dist.xml @@ -2,16 +2,17 @@ - @@ -20,13 +21,18 @@ - + - ./src + src - - - - + + trigger_deprecation + + diff --git a/src/Map/src/Bridge/Leaflet/tests/bootstrap.php b/src/Map/src/Bridge/Leaflet/tests/bootstrap.php new file mode 100644 index 00000000000..89a23684510 --- /dev/null +++ b/src/Map/src/Bridge/Leaflet/tests/bootstrap.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Symfony\Component\ErrorHandler\ErrorHandler; + +require __DIR__.'/../vendor/autoload.php'; + +// @see https://github.com/symfony/symfony/issues/53812 +ErrorHandler::register(null, false); diff --git a/src/Map/tests/Cluster/ClusteringPerformanceTest.php b/src/Map/tests/Cluster/ClusteringPerformanceTest.php index 9fa6740e35d..00e6a20ff33 100644 --- a/src/Map/tests/Cluster/ClusteringPerformanceTest.php +++ b/src/Map/tests/Cluster/ClusteringPerformanceTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\Map\Tests\Cluster; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\UX\Map\Cluster\ClusteringAlgorithmInterface; use Symfony\UX\Map\Cluster\GridClusteringAlgorithm; @@ -50,9 +51,8 @@ public static function algorithmProvider(): iterable /** * Scenario 1: Large number of points (50,000), concentrated area (Paris region). - * - * @dataProvider algorithmProvider */ + #[DataProvider('algorithmProvider')] public function testScenarioRegion50000(ClusteringAlgorithmInterface $algorithm, float $zoom) { $points = $this->generatePoints(50000, 48.8, 49, 2.2, 2.5); @@ -62,9 +62,8 @@ public function testScenarioRegion50000(ClusteringAlgorithmInterface $algorithm, /** * Scenario 2: Moderate number of points (5,000), broad area (France and surroundings). - * - * @dataProvider algorithmProvider */ + #[DataProvider('algorithmProvider')] public function testScenarioCountry5000(ClusteringAlgorithmInterface $algorithm, float $zoom) { $points = $this->generatePoints(5000, 30, 60, -10, 35); @@ -74,9 +73,8 @@ public function testScenarioCountry5000(ClusteringAlgorithmInterface $algorithm, /** * Scenario 3: Very large number of points (100,000), global distribution. - * - * @dataProvider algorithmProvider */ + #[DataProvider('algorithmProvider')] public function testScenarioWorld100000(ClusteringAlgorithmInterface $algorithm, float $zoom) { $points = $this->generatePoints(100000, -90, 90, -180, 180); diff --git a/src/Map/tests/Distance/DistanceCalculatorTest.php b/src/Map/tests/Distance/DistanceCalculatorTest.php index 5c7b9742d09..9155027f4fa 100644 --- a/src/Map/tests/Distance/DistanceCalculatorTest.php +++ b/src/Map/tests/Distance/DistanceCalculatorTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\Map\Tests\Distance; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\UX\Map\Distance\DistanceCalculator; use Symfony\UX\Map\Distance\DistanceCalculatorInterface; @@ -38,9 +39,8 @@ public function calculateDistance(Point $point1, Point $point2): float /** * Test that the non-reference calculators (Haversine and Spherical Cosine) * produce results close to the reference (Vincenty) within an acceptable margin. - * - * @dataProvider distanceAccuracyProvider */ + #[DataProvider('distanceAccuracyProvider')] public function testAccuracyAgainstVincenty(Point $point1, Point $point2, float $tolerance) { $vincenty = new VincentyDistanceCalculator(); diff --git a/src/Map/tests/Distance/DistanceUnitTest.php b/src/Map/tests/Distance/DistanceUnitTest.php index c6d8b1a057b..34de7e57bc2 100644 --- a/src/Map/tests/Distance/DistanceUnitTest.php +++ b/src/Map/tests/Distance/DistanceUnitTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\Map\Tests\Distance; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\UX\Map\Distance\DistanceUnit; @@ -30,9 +31,7 @@ public function testConversionFactorToMeterIsSameAsConversionFactor() } } - /** - * @dataProvider provideConvertedUnits - */ + #[DataProvider('provideConvertedUnits')] public function testConversionFactorFrom(DistanceUnit $unit, DistanceUnit $otherUnit, float $expected) { $this->assertEqualsWithDelta($expected, $unit->getConversionFactorFrom($otherUnit), 0.001); diff --git a/src/Map/tests/IconTest.php b/src/Map/tests/IconTest.php index 68c42cf1b35..59a32e13ae8 100644 --- a/src/Map/tests/IconTest.php +++ b/src/Map/tests/IconTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\Map\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\UX\Map\Icon\Icon; use Symfony\UX\Map\Icon\SvgIcon; @@ -39,26 +40,21 @@ public static function provideIcons(): iterable } /** - * @dataProvider provideIcons - * * @param class-string $expectedInstance */ + #[DataProvider('provideIcons')] public function testIconConstruction(Icon $icon, string $expectedInstance, array $expectedToArray) { self::assertInstanceOf($expectedInstance, $icon); } - /** - * @dataProvider provideIcons - */ + #[DataProvider('provideIcons')] public function testToArray(Icon $icon, string $expectedInstance, array $expectedToArray) { self::assertSame($expectedToArray, $icon->toArray()); } - /** - * @dataProvider provideIcons - */ + #[DataProvider('provideIcons')] public function testFromArray(Icon $icon, string $expectedInstance, array $expectedToArray) { self::assertEquals($icon, Icon::fromArray($expectedToArray)); @@ -84,9 +80,7 @@ public static function dataProviderForTestSvgIconCustomizationMethodsCanNotBeCal } } - /** - * @dataProvider dataProviderForTestSvgIconCustomizationMethodsCanNotBeCalled - */ + #[DataProvider('dataProviderForTestSvgIconCustomizationMethodsCanNotBeCalled')] public function testSvgIconCustomizationMethodsCanNotBeCalled(string $method, mixed ...$args) { $this->expectException(\LogicException::class); diff --git a/src/Map/tests/MapTest.php b/src/Map/tests/MapTest.php index 1008e141279..e4f85e647c6 100644 --- a/src/Map/tests/MapTest.php +++ b/src/Map/tests/MapTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\Map\Tests; +use PHPUnit\Framework\Attributes\TestWith; use PHPUnit\Framework\TestCase; use Symfony\UX\Map\Circle; use Symfony\UX\Map\Exception\InvalidArgumentException; @@ -408,14 +409,12 @@ public function testWithMaximumConfiguration() ], $map->toArray()); } - /** - * @testWith [-1, null, null, "The \"minZoom\" must be greater than or equal to 0."] - * [null, -1, null, "The \"zoom\" must be greater than or equal to 0."] - * [null, null, -1, "The \"maxZoom\" must be greater than or equal to 0."] - * [5, 2, null, "The \"zoom\" must be greater than or equal to \"minZoom\"."] - * [null, 5, 2, "The \"zoom\" must be less than or equal to \"maxZoom\"."] - * [2.1, null, 2.0, "The \"minZoom\" must be less than or equal to \"maxZoom\"."] - */ + #[TestWith([-1.0, null, null, 'The "minZoom" must be greater than or equal to 0.'])] + #[TestWith([null, -1.0, null, 'The "zoom" must be greater than or equal to 0.'])] + #[TestWith([null, null, -1.0, 'The "maxZoom" must be greater than or equal to 0.'])] + #[TestWith([5.0, 2.0, null, 'The "zoom" must be greater than or equal to "minZoom".'])] + #[TestWith([null, 5.0, 2.0, 'The "zoom" must be less than or equal to "maxZoom".'])] + #[TestWith([2.1, null, 2.0, 'The "minZoom" must be less than or equal to "maxZoom".'])] public function testZoomsValidation(?float $minZoom, ?float $zoom, ?float $maxZoom, string $expectedExceptionMessage) { self::expectException(InvalidArgumentException::class); diff --git a/src/Map/tests/PointTest.php b/src/Map/tests/PointTest.php index 2d33e1d4a9d..391952c288c 100644 --- a/src/Map/tests/PointTest.php +++ b/src/Map/tests/PointTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\Map\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\UX\Map\Exception\InvalidArgumentException; use Symfony\UX\Map\Point; @@ -25,9 +26,7 @@ public static function provideInvalidPoint(): iterable yield [0, -181, 'Longitude must be between -180 and 180 degrees, "-181" given.']; } - /** - * @dataProvider provideInvalidPoint - */ + #[DataProvider('provideInvalidPoint')] public function testInvalidPoint(float $latitude, float $longitude, string $expectedExceptionMessage) { self::expectException(InvalidArgumentException::class); diff --git a/src/Map/tests/Renderer/DsnTest.php b/src/Map/tests/Renderer/DsnTest.php index 52766a4318a..7d42cb58db7 100644 --- a/src/Map/tests/Renderer/DsnTest.php +++ b/src/Map/tests/Renderer/DsnTest.php @@ -11,15 +11,14 @@ namespace Symfony\UX\Map\Tests\Renderer; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\UX\Map\Exception\InvalidArgumentException; use Symfony\UX\Map\Renderer\Dsn; final class DsnTest extends TestCase { - /** - * @dataProvider constructDsn - */ + #[DataProvider('constructDsn')] public function testConstruct(string $dsnString, string $scheme, string $host, ?string $user = null, array $options = [], ?string $path = null) { $dsn = new Dsn($dsnString); @@ -77,9 +76,7 @@ public static function constructDsn(): iterable ]; } - /** - * @dataProvider invalidDsn - */ + #[DataProvider('invalidDsn')] public function testInvalidDsn(string $dsnString, string $exceptionMessage) { self::expectException(InvalidArgumentException::class); diff --git a/src/Map/tests/Renderer/NullRendererTest.php b/src/Map/tests/Renderer/NullRendererTest.php index f46d36efd4a..d03eeb0b446 100644 --- a/src/Map/tests/Renderer/NullRendererTest.php +++ b/src/Map/tests/Renderer/NullRendererTest.php @@ -13,6 +13,7 @@ namespace Symfony\UX\Map\Tests\Renderer; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\UX\Map\Exception\LogicException; use Symfony\UX\Map\Map; @@ -21,29 +22,27 @@ final class NullRendererTest extends TestCase { - public function provideTestRenderMap(): iterable + public static function provideTestRenderMap(): iterable { yield 'no bridges' => [ - 'expected_exception_message' => 'You must install at least one bridge package to use the Symfony UX Map component.', + 'expectedExceptionMessage' => 'You must install at least one bridge package to use the Symfony UX Map component.', 'renderer' => new NullRenderer(), ]; yield 'one bridge' => [ - 'expected_exception_message' => 'You must install at least one bridge package to use the Symfony UX Map component.' + 'expectedExceptionMessage' => 'You must install at least one bridge package to use the Symfony UX Map component.' .\PHP_EOL.'Try running "composer require symfony/ux-leaflet-map".', 'renderer' => new NullRenderer(['symfony/ux-leaflet-map']), ]; yield 'two bridges' => [ - 'expected_exception_message' => 'You must install at least one bridge package to use the Symfony UX Map component.' + 'expectedExceptionMessage' => 'You must install at least one bridge package to use the Symfony UX Map component.' .\PHP_EOL.'Try running "composer require symfony/ux-leaflet-map" or "composer require symfony/ux-google-map".', 'renderer' => new NullRenderer(['symfony/ux-leaflet-map', 'symfony/ux-google-map']), ]; } - /** - * @dataProvider provideTestRenderMap - */ + #[DataProvider('provideTestRenderMap')] public function testRenderMap(string $expectedExceptionMessage, RendererInterface $renderer) { self::expectException(LogicException::class); diff --git a/src/Map/tests/Twig/MapExtensionTest.php b/src/Map/tests/Twig/MapExtensionTest.php index e3a1bf63f3e..ee0467c4ee2 100644 --- a/src/Map/tests/Twig/MapExtensionTest.php +++ b/src/Map/tests/Twig/MapExtensionTest.php @@ -11,7 +11,6 @@ namespace Symfony\UX\Map\Tests\Twig; -use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\UX\Map\Map; use Symfony\UX\Map\Point; @@ -23,8 +22,6 @@ class MapExtensionTest extends KernelTestCase { - use ExpectDeprecationTrait; - protected static function getKernelClass(): string { return TwigAppKernel::class; diff --git a/src/Map/tests/UXMapBundleTest.php b/src/Map/tests/UXMapBundleTest.php index dd385a2f6a3..7e48a4403a2 100644 --- a/src/Map/tests/UXMapBundleTest.php +++ b/src/Map/tests/UXMapBundleTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\Map\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; use Symfony\Component\HttpKernel\Kernel; @@ -31,10 +32,9 @@ public static function provideKernelClasses(): iterable } /** - * @dataProvider provideKernelClasses - * * @param class-string $kernelClass */ + #[DataProvider('provideKernelClasses')] public function testBootKernel(string $kernelClass) { $kernel = new $kernelClass('test', true); @@ -44,10 +44,9 @@ public function testBootKernel(string $kernelClass) } /** - * @dataProvider provideKernelClasses - * * @param class-string $kernelClass */ + #[DataProvider('provideKernelClasses')] public function testNullRendererAsDefault(string $kernelClass) { $expectedRenderer = new NullRenderer(['symfony/ux-google-map', 'symfony/ux-leaflet-map']); diff --git a/src/Map/tests/bootstrap.php b/src/Map/tests/bootstrap.php new file mode 100644 index 00000000000..89a23684510 --- /dev/null +++ b/src/Map/tests/bootstrap.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Symfony\Component\ErrorHandler\ErrorHandler; + +require __DIR__.'/../vendor/autoload.php'; + +// @see https://github.com/symfony/symfony/issues/53812 +ErrorHandler::register(null, false); From c4ecc6f41c14c463b3f1194fbaa107f7ac329fe1 Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Wed, 19 Nov 2025 08:42:36 +0100 Subject: [PATCH 09/17] [Notify] Drop Symfony PHPUnit Bridge in favor of PHPUnit >= 11.0 --- src/Notify/.gitignore | 2 +- src/Notify/composer.json | 2 +- .../{phpunit.xml.dist => phpunit.dist.xml} | 23 ++++++++++++------- src/Notify/tests/Twig/NotifyRuntimeTest.php | 5 ++-- src/Notify/tests/bootstrap.php | 17 ++++++++++++++ 5 files changed, 36 insertions(+), 13 deletions(-) rename src/Notify/{phpunit.xml.dist => phpunit.dist.xml} (55%) create mode 100644 src/Notify/tests/bootstrap.php diff --git a/src/Notify/.gitignore b/src/Notify/.gitignore index 2cc9f0231c3..095a90a8430 100644 --- a/src/Notify/.gitignore +++ b/src/Notify/.gitignore @@ -2,4 +2,4 @@ /vendor/ /composer.lock /phpunit.xml -/.phpunit.result.cache +/.phpunit.cache diff --git a/src/Notify/composer.json b/src/Notify/composer.json index 651ed19ba9f..7041a85c455 100644 --- a/src/Notify/composer.json +++ b/src/Notify/composer.json @@ -38,8 +38,8 @@ "symfony/twig-bundle": "^6.4|^7.0|^8.0" }, "require-dev": { + "phpunit/phpunit": "^11.1|^12.0", "symfony/framework-bundle": "^6.4|^7.0|^8.0", - "symfony/phpunit-bridge": "^7.2|^8.0", "symfony/var-dumper": "^6.4|^7.0|^8.0" }, "conflict": { diff --git a/src/Notify/phpunit.xml.dist b/src/Notify/phpunit.dist.xml similarity index 55% rename from src/Notify/phpunit.xml.dist rename to src/Notify/phpunit.dist.xml index fbc17b8c5fc..04a858de434 100644 --- a/src/Notify/phpunit.xml.dist +++ b/src/Notify/phpunit.dist.xml @@ -2,11 +2,13 @@ @@ -20,13 +22,18 @@ - + - ./src + src - - - - + + trigger_deprecation + + diff --git a/src/Notify/tests/Twig/NotifyRuntimeTest.php b/src/Notify/tests/Twig/NotifyRuntimeTest.php index 8c3b3786337..23111946c00 100644 --- a/src/Notify/tests/Twig/NotifyRuntimeTest.php +++ b/src/Notify/tests/Twig/NotifyRuntimeTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\Notify\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\UX\Notify\Tests\Kernel\TwigAppKernel; use Symfony\UX\Notify\Twig\NotifyRuntime; @@ -22,9 +23,7 @@ */ class NotifyRuntimeTest extends TestCase { - /** - * @dataProvider streamNotificationsDataProvider - */ + #[DataProvider('streamNotificationsDataProvider')] public function testStreamNotifications(array $params, string $expected) { $kernel = new TwigAppKernel('test', true); diff --git a/src/Notify/tests/bootstrap.php b/src/Notify/tests/bootstrap.php new file mode 100644 index 00000000000..89a23684510 --- /dev/null +++ b/src/Notify/tests/bootstrap.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Symfony\Component\ErrorHandler\ErrorHandler; + +require __DIR__.'/../vendor/autoload.php'; + +// @see https://github.com/symfony/symfony/issues/53812 +ErrorHandler::register(null, false); From aa484e0583efb927e56d527741d421f4a2c4db9b Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Wed, 19 Nov 2025 08:42:43 +0100 Subject: [PATCH 10/17] [React] Drop Symfony PHPUnit Bridge in favor of PHPUnit >= 11.0 --- src/React/.gitignore | 2 +- src/React/composer.json | 2 +- .../{phpunit.xml.dist => phpunit.dist.xml} | 24 ++++++++++++------- .../Twig/ReactComponentExtensionTest.php | 5 ++-- src/React/tests/bootstrap.php | 17 +++++++++++++ 5 files changed, 36 insertions(+), 14 deletions(-) rename src/React/{phpunit.xml.dist => phpunit.dist.xml} (52%) create mode 100644 src/React/tests/bootstrap.php diff --git a/src/React/.gitignore b/src/React/.gitignore index 2cc9f0231c3..095a90a8430 100644 --- a/src/React/.gitignore +++ b/src/React/.gitignore @@ -2,4 +2,4 @@ /vendor/ /composer.lock /phpunit.xml -/.phpunit.result.cache +/.phpunit.cache diff --git a/src/React/composer.json b/src/React/composer.json index 3a7aff73124..361a68fdfe7 100644 --- a/src/React/composer.json +++ b/src/React/composer.json @@ -32,10 +32,10 @@ "symfony/stimulus-bundle": "^2.9.1" }, "require-dev": { + "phpunit/phpunit": "^11.1|^12.0", "symfony/asset-mapper": "^6.4|^7.0|^8.0", "symfony/finder": "^6.4|^7.0|^8.0", "symfony/framework-bundle": "^6.4|^7.0|^8.0", - "symfony/phpunit-bridge": "^7.2|^8.0", "symfony/twig-bundle": "^6.4|^7.0|^8.0", "symfony/var-dumper": "^6.4|^7.0|^8.0" }, diff --git a/src/React/phpunit.xml.dist b/src/React/phpunit.dist.xml similarity index 52% rename from src/React/phpunit.xml.dist rename to src/React/phpunit.dist.xml index 0f279ee6c46..8d365a4c568 100644 --- a/src/React/phpunit.xml.dist +++ b/src/React/phpunit.dist.xml @@ -2,16 +2,17 @@ - @@ -20,13 +21,18 @@ - + - ./src + src - - - - + + trigger_deprecation + + diff --git a/src/React/tests/Twig/ReactComponentExtensionTest.php b/src/React/tests/Twig/ReactComponentExtensionTest.php index a522572f16b..27e52006ab8 100644 --- a/src/React/tests/Twig/ReactComponentExtensionTest.php +++ b/src/React/tests/Twig/ReactComponentExtensionTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\React\Tests\Twig; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\UX\React\Tests\Kernel\TwigAppKernel; use Symfony\UX\React\Twig\ReactComponentExtension; @@ -41,9 +42,7 @@ public function testRenderComponent() ); } - /** - * @dataProvider provideOptions - */ + #[DataProvider('provideOptions')] public function testRenderComponentWithOptions(array $options, string|false $expected) { $kernel = new TwigAppKernel('test', true); diff --git a/src/React/tests/bootstrap.php b/src/React/tests/bootstrap.php new file mode 100644 index 00000000000..89a23684510 --- /dev/null +++ b/src/React/tests/bootstrap.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Symfony\Component\ErrorHandler\ErrorHandler; + +require __DIR__.'/../vendor/autoload.php'; + +// @see https://github.com/symfony/symfony/issues/53812 +ErrorHandler::register(null, false); From 5bd2f3ebc91bcd7255ebbe51590b06205a95708f Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Wed, 19 Nov 2025 08:42:50 +0100 Subject: [PATCH 11/17] [StimulusBundle] Drop Symfony PHPUnit Bridge in favor of PHPUnit >= 11.0 --- src/StimulusBundle/.gitignore | 3 +- src/StimulusBundle/composer.json | 4 +-- .../{phpunit.xml.dist => phpunit.dist.xml} | 28 ++++++++++--------- .../tests/Dto/StimulusAttributesTest.php | 5 ++-- .../tests/Twig/StimulusTwigExtensionTest.php | 13 +++------ src/StimulusBundle/tests/bootstrap.php | 17 +++++++++++ 6 files changed, 42 insertions(+), 28 deletions(-) rename src/StimulusBundle/{phpunit.xml.dist => phpunit.dist.xml} (58%) create mode 100644 src/StimulusBundle/tests/bootstrap.php diff --git a/src/StimulusBundle/.gitignore b/src/StimulusBundle/.gitignore index 6e705b91ed7..8f238213ef5 100644 --- a/src/StimulusBundle/.gitignore +++ b/src/StimulusBundle/.gitignore @@ -2,6 +2,7 @@ /vendor/ /composer.lock /phpunit.xml -/.phpunit.result.cache +/.phpunit.cache /tests/fixtures/var +/config/reference.php diff --git a/src/StimulusBundle/composer.json b/src/StimulusBundle/composer.json index b0c7378966d..4020ef5220b 100644 --- a/src/StimulusBundle/composer.json +++ b/src/StimulusBundle/composer.json @@ -25,11 +25,11 @@ "symfony/asset-mapper": "<6.4" }, "require-dev": { + "phpunit/phpunit": "^11.1|^12.0", "symfony/asset-mapper": "^6.4|^7.0|^8.0", "symfony/framework-bundle": "^6.4|^7.0|^8.0", - "symfony/phpunit-bridge": "^7.2|^8.0", "symfony/twig-bundle": "^6.4|^7.0|^8.0", - "zenstruck/browser": "^1.4" + "zenstruck/browser": "^1.9" }, "minimum-stability": "dev", "autoload": { diff --git a/src/StimulusBundle/phpunit.xml.dist b/src/StimulusBundle/phpunit.dist.xml similarity index 58% rename from src/StimulusBundle/phpunit.xml.dist rename to src/StimulusBundle/phpunit.dist.xml index 44e817636e2..ebda37a0aa7 100644 --- a/src/StimulusBundle/phpunit.xml.dist +++ b/src/StimulusBundle/phpunit.dist.xml @@ -2,16 +2,17 @@ - @@ -22,17 +23,18 @@ - + - ./src + src - - - - - - - - + + trigger_deprecation + + diff --git a/src/StimulusBundle/tests/Dto/StimulusAttributesTest.php b/src/StimulusBundle/tests/Dto/StimulusAttributesTest.php index 9240146fa16..d34d85a4d44 100644 --- a/src/StimulusBundle/tests/Dto/StimulusAttributesTest.php +++ b/src/StimulusBundle/tests/Dto/StimulusAttributesTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\StimulusBundle\Tests\Dto; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\UX\StimulusBundle\Dto\StimulusAttributes; use Twig\Environment; @@ -149,9 +150,7 @@ public function testAddAttribute() $this->assertSame(['foo' => 'bar baz'], $this->stimulusAttributes->toArray()); } - /** - * @dataProvider provideAddComplexActionData - */ + #[DataProvider('provideAddComplexActionData')] public function testAddComplexAction(string $controllerName, string $actionName, ?string $eventName, string $expectedAction) { $this->stimulusAttributes->addAction($controllerName, $actionName, $eventName); diff --git a/src/StimulusBundle/tests/Twig/StimulusTwigExtensionTest.php b/src/StimulusBundle/tests/Twig/StimulusTwigExtensionTest.php index c7a0b142d94..a3c640e34c4 100644 --- a/src/StimulusBundle/tests/Twig/StimulusTwigExtensionTest.php +++ b/src/StimulusBundle/tests/Twig/StimulusTwigExtensionTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\StimulusBundle\Tests\Twig; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\UX\StimulusBundle\Helper\StimulusHelper; use Symfony\UX\StimulusBundle\Tests\StimulusIntegrationTestKernel; @@ -29,9 +30,7 @@ protected function setUp(): void $this->twig = $container->get(Environment::class); } - /** - * @dataProvider provideRenderStimulusController - */ + #[DataProvider('provideRenderStimulusController')] public function testRenderStimulusController(string $controllerName, array $controllerValues, array $controllerClasses, array $controllerOutlets, string $expectedString, array $expectedArray) { $extension = new StimulusTwigExtension(new StimulusHelper($this->twig)); @@ -140,9 +139,7 @@ public function testAppendStimulusController() ); } - /** - * @dataProvider provideRenderStimulusAction - */ + #[DataProvider('provideRenderStimulusAction')] public function testRenderStimulusAction(string $controllerName, ?string $actionName, ?string $eventName, array $parameters, string $expectedString, array $expectedArray) { $extension = new StimulusTwigExtension(new StimulusHelper($this->twig)); @@ -218,9 +215,7 @@ public function testAppendStimulusAction() ); } - /** - * @dataProvider provideRenderStimulusTarget - */ + #[DataProvider('provideRenderStimulusTarget')] public function testRenderStimulusTarget(string $controllerName, ?string $targetName, string $expectedString, array $expectedArray) { $extension = new StimulusTwigExtension(new StimulusHelper($this->twig)); diff --git a/src/StimulusBundle/tests/bootstrap.php b/src/StimulusBundle/tests/bootstrap.php new file mode 100644 index 00000000000..89a23684510 --- /dev/null +++ b/src/StimulusBundle/tests/bootstrap.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Symfony\Component\ErrorHandler\ErrorHandler; + +require __DIR__.'/../vendor/autoload.php'; + +// @see https://github.com/symfony/symfony/issues/53812 +ErrorHandler::register(null, false); From d451bd87291f3111a5d528a739eb34398c9e7d59 Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Wed, 19 Nov 2025 08:42:57 +0100 Subject: [PATCH 12/17] [Svelte] Drop Symfony PHPUnit Bridge in favor of PHPUnit >= 11.0 --- src/Svelte/.gitignore | 2 +- src/Svelte/composer.json | 2 +- .../{phpunit.xml.dist => phpunit.dist.xml} | 24 ++++++++++++------- src/Svelte/tests/bootstrap.php | 20 ++++++++++++++++ 4 files changed, 37 insertions(+), 11 deletions(-) rename src/Svelte/{phpunit.xml.dist => phpunit.dist.xml} (52%) create mode 100644 src/Svelte/tests/bootstrap.php diff --git a/src/Svelte/.gitignore b/src/Svelte/.gitignore index 2cc9f0231c3..095a90a8430 100644 --- a/src/Svelte/.gitignore +++ b/src/Svelte/.gitignore @@ -2,4 +2,4 @@ /vendor/ /composer.lock /phpunit.xml -/.phpunit.result.cache +/.phpunit.cache diff --git a/src/Svelte/composer.json b/src/Svelte/composer.json index 3cb44abe061..c3db94eb868 100644 --- a/src/Svelte/composer.json +++ b/src/Svelte/composer.json @@ -36,10 +36,10 @@ "symfony/stimulus-bundle": "^2.9.1" }, "require-dev": { + "phpunit/phpunit": "^11.1|^12.0", "symfony/asset-mapper": "^6.4|^7.0|^8.0", "symfony/finder": "^6.4|^7.0|^8.0", "symfony/framework-bundle": "^6.4|^7.0|^8.0", - "symfony/phpunit-bridge": "^7.2|^8.0", "symfony/twig-bundle": "^6.4|^7.0|^8.0", "symfony/var-dumper": "^6.4|^7.0|^8.0" }, diff --git a/src/Svelte/phpunit.xml.dist b/src/Svelte/phpunit.dist.xml similarity index 52% rename from src/Svelte/phpunit.xml.dist rename to src/Svelte/phpunit.dist.xml index cf90cc4987e..530ee2876e8 100644 --- a/src/Svelte/phpunit.xml.dist +++ b/src/Svelte/phpunit.dist.xml @@ -2,16 +2,17 @@ - @@ -20,13 +21,18 @@ - + - ./src + src - - - - + + trigger_deprecation + + diff --git a/src/Svelte/tests/bootstrap.php b/src/Svelte/tests/bootstrap.php new file mode 100644 index 00000000000..519f959c9fa --- /dev/null +++ b/src/Svelte/tests/bootstrap.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Symfony\Component\ErrorHandler\ErrorHandler; +use Symfony\Component\Filesystem\Filesystem; + +require __DIR__.'/../vendor/autoload.php'; + +(new Filesystem())->remove(__DIR__.'/../var'); + +// @see https://github.com/symfony/symfony/issues/53812 +ErrorHandler::register(null, false); From 0d895677ab9b0faa1856c7e63cf24a46d042de57 Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Wed, 19 Nov 2025 08:43:05 +0100 Subject: [PATCH 13/17] [Toolkit] Drop Symfony PHPUnit Bridge in favor of PHPUnit >= 11.0 --- src/Toolkit/.gitignore | 15 +++++---- src/Toolkit/composer.json | 5 ++- .../{phpunit.xml.dist => phpunit.dist.xml} | 23 ++++++++----- src/Toolkit/tests/AssertTest.php | 33 +++++-------------- .../Functional/ComponentsRenderingTest.php | 9 +++-- .../tests/Registry/RegistryFactoryTest.php | 9 ++--- 6 files changed, 41 insertions(+), 53 deletions(-) rename src/Toolkit/{phpunit.xml.dist => phpunit.dist.xml} (55%) diff --git a/src/Toolkit/.gitignore b/src/Toolkit/.gitignore index cf8b688b719..4bc74b892f6 100644 --- a/src/Toolkit/.gitignore +++ b/src/Toolkit/.gitignore @@ -1,7 +1,8 @@ -vendor -composer.lock -.phpunit.result.cache -var -.twig-cs-fixer.cache -tests/ui/output -tests/ui/screens +/vendor/ +/composer.lock +/phpunit.xml +/.phpunit.cache +/.twig-cs-fixer.cache + +/var +/config/reference.php diff --git a/src/Toolkit/composer.json b/src/Toolkit/composer.json index 3e88adcebac..1291f5556f1 100644 --- a/src/Toolkit/composer.json +++ b/src/Toolkit/composer.json @@ -46,10 +46,9 @@ "zenstruck/console-test": "^1.7", "symfony/http-client": "^6.4|^7.0|^8.0", "symfony/stopwatch": "^6.4|^7.0|^8.0", - "symfony/phpunit-bridge": "^7.2|^8.0", + "phpunit/phpunit": "^11.1|^12.0", "vincentlanglet/twig-cs-fixer": "^3.9", - "spatie/phpunit-snapshot-assertions": "^4.2.17|^5.2.3", - "phpunit/phpunit": "^9.6.22", + "spatie/phpunit-snapshot-assertions": "^5.2.3", "symfony/ux-icons": "^2.18", "tales-from-a-dev/twig-tailwind-extra": "^0.4.0" }, diff --git a/src/Toolkit/phpunit.xml.dist b/src/Toolkit/phpunit.dist.xml similarity index 55% rename from src/Toolkit/phpunit.xml.dist rename to src/Toolkit/phpunit.dist.xml index 98f7852b2a1..1b80abde612 100644 --- a/src/Toolkit/phpunit.xml.dist +++ b/src/Toolkit/phpunit.dist.xml @@ -1,12 +1,14 @@ - + @@ -21,13 +23,18 @@ - + - ./src + src - - - - + + trigger_deprecation + + diff --git a/src/Toolkit/tests/AssertTest.php b/src/Toolkit/tests/AssertTest.php index 86da179bb9b..dd949f64643 100644 --- a/src/Toolkit/tests/AssertTest.php +++ b/src/Toolkit/tests/AssertTest.php @@ -11,14 +11,13 @@ namespace Symfony\UX\Toolkit\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\UX\Toolkit\Assert; class AssertTest extends TestCase { - /** - * @dataProvider provideValidKitNames - */ + #[DataProvider('provideValidKitNames')] public function testValidKitName(string $name) { $this->expectNotToPerformAssertions(); @@ -50,9 +49,7 @@ public static function provideValidKitNames(): \Generator yield ['my_kit']; } - /** - * @dataProvider provideInvalidKitNames - */ + #[DataProvider('provideInvalidKitNames')] public function testInvalidKitName(string $name) { $this->expectException(\InvalidArgumentException::class); @@ -82,9 +79,7 @@ public static function provideInvalidKitNames(): \Generator yield ['.abc']; } - /** - * @dataProvider provideValidComponentNames - */ + #[DataProvider('provideValidComponentNames')] public function testValidComponentName(string $name) { $this->expectNotToPerformAssertions(); @@ -106,9 +101,7 @@ public static function provideValidComponentNames(): iterable yield ['Component123:Sub456']; } - /** - * @dataProvider provideInvalidComponentNames - */ + #[DataProvider('provideInvalidComponentNames')] public function testInvalidComponentName(string $name) { $this->expectException(\InvalidArgumentException::class); @@ -143,9 +136,7 @@ public static function provideInvalidComponentNames(): iterable yield ['123:456']; } - /** - * @dataProvider provideValidPhpPackageNames - */ + #[DataProvider('provideValidPhpPackageNames')] public function testValidPhpPackageName(string $name) { $this->expectNotToPerformAssertions(); @@ -159,9 +150,7 @@ public static function provideValidPhpPackageNames(): iterable yield ['tales-from-a-dev/twig-tailwind-extra']; } - /** - * @dataProvider provideInvalidPhpPackageNames - */ + #[DataProvider('provideInvalidPhpPackageNames')] public function testInvalidPhpPackageName(string $name) { $this->expectException(\InvalidArgumentException::class); @@ -178,9 +167,7 @@ public static function provideInvalidPhpPackageNames(): iterable yield ['twig/html-extra/twig']; } - /** - * @dataProvider provideValidNpmPackageNames - */ + #[DataProvider('provideValidNpmPackageNames')] public function testValidNpmPackageName(string $name) { $this->expectNotToPerformAssertions(); @@ -202,9 +189,7 @@ public static function provideValidNpmPackageNames(): iterable yield ['~foo']; } - /** - * @dataProvider provideInvalidNpmPackageNames - */ + #[DataProvider('provideInvalidNpmPackageNames')] public function testInvalidNpmPackageName(string $name) { $this->expectException(\InvalidArgumentException::class); diff --git a/src/Toolkit/tests/Functional/ComponentsRenderingTest.php b/src/Toolkit/tests/Functional/ComponentsRenderingTest.php index ea715cdabb6..250d790273e 100644 --- a/src/Toolkit/tests/Functional/ComponentsRenderingTest.php +++ b/src/Toolkit/tests/Functional/ComponentsRenderingTest.php @@ -11,6 +11,8 @@ namespace Symfony\UX\Toolkit\Tests\Functional; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Group; use Spatie\Snapshots\Drivers\HtmlDriver; use Spatie\Snapshots\MatchesSnapshots; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; @@ -60,11 +62,8 @@ public static function provideTestComponentRendering(): iterable } } - /** - * @dataProvider provideTestComponentRendering - * - * @group skip-on-lowest - */ + #[DataProvider('provideTestComponentRendering')] + #[Group('skip-on-lowest')] public function testComponentRendering(string $kitName, string $recipeName, string $code) { $twig = self::getContainer()->get('twig'); diff --git a/src/Toolkit/tests/Registry/RegistryFactoryTest.php b/src/Toolkit/tests/Registry/RegistryFactoryTest.php index 079a5abb810..211e8266cb7 100644 --- a/src/Toolkit/tests/Registry/RegistryFactoryTest.php +++ b/src/Toolkit/tests/Registry/RegistryFactoryTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\Toolkit\Tests\Registry; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\UX\Toolkit\Registry\GitHubRegistry; use Symfony\UX\Toolkit\Registry\LocalRegistry; @@ -31,9 +32,7 @@ public static function provideRegistryNames(): array ]; } - /** - * @dataProvider provideRegistryNames - */ + #[DataProvider('provideRegistryNames')] public function testCanCreateRegistry(string $registryName, string $expectedRegistryClass) { $registryFactory = self::getContainer()->get('ux_toolkit.registry.registry_factory'); @@ -53,9 +52,7 @@ public static function provideInvalidRegistryNames(): array ]; } - /** - * @dataProvider provideInvalidRegistryNames - */ + #[DataProvider('provideInvalidRegistryNames')] public function testShouldFailIfRegistryIsNotFound(string $registryName) { $registryFactory = self::getContainer()->get('ux_toolkit.registry.registry_factory'); From a8b1002112502219df7afd0671e0cd97bcf22977 Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Wed, 19 Nov 2025 08:43:17 +0100 Subject: [PATCH 14/17] [Translator] Drop Symfony PHPUnit Bridge in favor of PHPUnit >= 11.0 --- src/Translator/.gitignore | 2 +- src/Translator/composer.json | 2 +- .../{phpunit.xml.dist => phpunit.dist.xml} | 22 ++++++++++++------- .../tests/Intl/IntlMessageParserTest.php | 5 ++--- .../IntlMessageParametersExtractorTest.php | 5 ++--- .../MessageParametersExtractorTest.php | 5 ++--- ...TypeScriptMessageParametersPrinterTest.php | 5 ++--- .../tests/UxTranslatorBundleTest.php | 5 ++--- src/Translator/tests/bootstrap.php | 6 ++++- 9 files changed, 31 insertions(+), 26 deletions(-) rename src/Translator/{phpunit.xml.dist => phpunit.dist.xml} (55%) diff --git a/src/Translator/.gitignore b/src/Translator/.gitignore index 1784dd6561c..e60038353de 100644 --- a/src/Translator/.gitignore +++ b/src/Translator/.gitignore @@ -2,6 +2,6 @@ /vendor/ /composer.lock /phpunit.xml -/.phpunit.result.cache +/.phpunit.cache /var diff --git a/src/Translator/composer.json b/src/Translator/composer.json index f690f450380..93798771365 100644 --- a/src/Translator/composer.json +++ b/src/Translator/composer.json @@ -35,8 +35,8 @@ "symfony/translation": "^6.4|^7.0|^8.0" }, "require-dev": { + "phpunit/phpunit": "^11.1|^12.0", "symfony/framework-bundle": "^6.4|^7.0|^8.0", - "symfony/phpunit-bridge": "^7.2|^8.0", "symfony/var-dumper": "^6.4|^7.0|^8.0", "symfony/yaml": "^6.4|^7.0|^8.0" }, diff --git a/src/Translator/phpunit.xml.dist b/src/Translator/phpunit.dist.xml similarity index 55% rename from src/Translator/phpunit.xml.dist rename to src/Translator/phpunit.dist.xml index b9b855e238e..3fc6d405709 100644 --- a/src/Translator/phpunit.xml.dist +++ b/src/Translator/phpunit.dist.xml @@ -2,16 +2,17 @@ - @@ -20,13 +21,18 @@ - + - ./src + src - - - - + + trigger_deprecation + + diff --git a/src/Translator/tests/Intl/IntlMessageParserTest.php b/src/Translator/tests/Intl/IntlMessageParserTest.php index cd731fbf038..7369d6a7cfb 100644 --- a/src/Translator/tests/Intl/IntlMessageParserTest.php +++ b/src/Translator/tests/Intl/IntlMessageParserTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\Translator\Tests\Intl; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\UX\Translator\Intl\ErrorKind; use Symfony\UX\Translator\Intl\IntlMessageParser; @@ -20,9 +21,7 @@ class IntlMessageParserTest extends TestCase { - /** - * @dataProvider provideParse - */ + #[DataProvider('provideParse')] public function testIntlMessageParser(string $message, array $expectedAst) { $intlMessageParser = new IntlMessageParser($message); diff --git a/src/Translator/tests/MessageParameters/Extractor/IntlMessageParametersExtractorTest.php b/src/Translator/tests/MessageParameters/Extractor/IntlMessageParametersExtractorTest.php index f69a8fb89d5..47d21e3a0b7 100644 --- a/src/Translator/tests/MessageParameters/Extractor/IntlMessageParametersExtractorTest.php +++ b/src/Translator/tests/MessageParameters/Extractor/IntlMessageParametersExtractorTest.php @@ -11,14 +11,13 @@ namespace Symfony\UX\Translator\Tests\MessageParameters; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\UX\Translator\MessageParameters\Extractor\IntlMessageParametersExtractor; class IntlMessageParametersExtractorTest extends TestCase { - /** - * @dataProvider provideExtract - */ + #[DataProvider('provideExtract')] public function testExtract(string $message, array $expectedParameters) { $intlMessageParametersExtractor = new IntlMessageParametersExtractor(); diff --git a/src/Translator/tests/MessageParameters/Extractor/MessageParametersExtractorTest.php b/src/Translator/tests/MessageParameters/Extractor/MessageParametersExtractorTest.php index 102e6b10334..ae287ef8318 100644 --- a/src/Translator/tests/MessageParameters/Extractor/MessageParametersExtractorTest.php +++ b/src/Translator/tests/MessageParameters/Extractor/MessageParametersExtractorTest.php @@ -11,14 +11,13 @@ namespace Symfony\UX\Translator\Tests\MessageParameters; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\UX\Translator\MessageParameters\Extractor\MessageParametersExtractor; class MessageParametersExtractorTest extends TestCase { - /** - * @dataProvider provideExtract - */ + #[DataProvider('provideExtract')] public function testExtract(string $message, array $expectedParameters) { $messageParametersExtractor = new MessageParametersExtractor(); diff --git a/src/Translator/tests/MessageParameters/Printer/TypeScriptMessageParametersPrinterTest.php b/src/Translator/tests/MessageParameters/Printer/TypeScriptMessageParametersPrinterTest.php index 4b11b220baa..993ee9d1205 100644 --- a/src/Translator/tests/MessageParameters/Printer/TypeScriptMessageParametersPrinterTest.php +++ b/src/Translator/tests/MessageParameters/Printer/TypeScriptMessageParametersPrinterTest.php @@ -11,14 +11,13 @@ namespace Symfony\UX\Translator\Tests\Printer; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\UX\Translator\MessageParameters\Printer\TypeScriptMessageParametersPrinter; class TypeScriptMessageParametersPrinterTest extends TestCase { - /** - * @dataProvider providePrint - */ + #[DataProvider('providePrint')] public function testPrint(array $parameters, string $expectedTypeScriptType) { $typeScriptMessageParametersPrinter = new TypeScriptMessageParametersPrinter(); diff --git a/src/Translator/tests/UxTranslatorBundleTest.php b/src/Translator/tests/UxTranslatorBundleTest.php index 8f244289558..71366de428e 100644 --- a/src/Translator/tests/UxTranslatorBundleTest.php +++ b/src/Translator/tests/UxTranslatorBundleTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\Translator\Tests; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpKernel\Kernel; use Symfony\UX\Translator\Tests\Kernel\EmptyAppKernel; @@ -24,9 +25,7 @@ public static function provideKernels() yield 'framework' => [new FrameworkAppKernel('test', true)]; } - /** - * @dataProvider provideKernels - */ + #[DataProvider('provideKernels')] public function testBootKernel(Kernel $kernel) { $kernel->boot(); diff --git a/src/Translator/tests/bootstrap.php b/src/Translator/tests/bootstrap.php index 1172565510f..688aec774cb 100644 --- a/src/Translator/tests/bootstrap.php +++ b/src/Translator/tests/bootstrap.php @@ -11,6 +11,7 @@ use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Input\StringInput; +use Symfony\Component\ErrorHandler\ErrorHandler; use Symfony\Component\Filesystem\Filesystem; use Symfony\UX\Translator\Tests\Kernel\FrameworkAppKernel; @@ -18,8 +19,11 @@ (new Filesystem())->remove(__DIR__.'/../var'); +// @see https://github.com/symfony/symfony/issues/53812 +ErrorHandler::register(null, false); + $kernel = new FrameworkAppKernel('test', true); $application = new Application($kernel); // Trigger Symfony Translator and UX Translator cache warmers -$application->run(new StringInput('cache:clear')); +// $application->run(new StringInput('cache:clear')); From 64405b774f339f587111845863e755fa16189de7 Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Wed, 19 Nov 2025 08:43:23 +0100 Subject: [PATCH 15/17] [Turbo] Drop Symfony PHPUnit Bridge in favor of PHPUnit >= 11.0 --- src/Turbo/.gitignore | 2 +- src/Turbo/composer.json | 2 +- src/Turbo/phpstan.dist.neon | 2 -- .../{phpunit.xml.dist => phpunit.dist.xml} | 28 ++++++++++--------- .../Mercure/TurboStreamListenRendererTest.php | 4 +-- src/Turbo/tests/Helper/TurboStreamTest.php | 25 ++++++++--------- src/Turbo/tests/bootstrap.php | 17 +++++++++++ 7 files changed, 47 insertions(+), 33 deletions(-) rename src/Turbo/{phpunit.xml.dist => phpunit.dist.xml} (62%) create mode 100644 src/Turbo/tests/bootstrap.php diff --git a/src/Turbo/.gitignore b/src/Turbo/.gitignore index d365c4b922b..a8d4330cfb9 100644 --- a/src/Turbo/.gitignore +++ b/src/Turbo/.gitignore @@ -3,7 +3,7 @@ /composer.lock /drivers/ /phpunit.xml -/.phpunit.result.cache +/.phpunit.cache /tests/app/assets/vendor/ /tests/app/public/assets/ /tests/app/public/build/ diff --git a/src/Turbo/composer.json b/src/Turbo/composer.json index 6a8fdfb5a9e..c15da8ce480 100644 --- a/src/Turbo/composer.json +++ b/src/Turbo/composer.json @@ -48,7 +48,7 @@ "symfony/mercure-bundle": "^0.3.7", "symfony/messenger": "^6.4|^7.0|^8.0", "symfony/panther": "^2.2", - "symfony/phpunit-bridge": "^7.2|^8.0", + "phpunit/phpunit": "^11.1|^12.0", "symfony/process": "^6.4|^7.0|^8.0", "symfony/property-access": "^6.4|^7.0|^8.0", "symfony/security-core": "^6.4|^7.0|^8.0", diff --git a/src/Turbo/phpstan.dist.neon b/src/Turbo/phpstan.dist.neon index 7db52b17d53..e420052a9b8 100644 --- a/src/Turbo/phpstan.dist.neon +++ b/src/Turbo/phpstan.dist.neon @@ -10,8 +10,6 @@ parameters: # to allow installing with various phsptan versions without reporting old errors here reportUnmatchedIgnoredErrors: false inferPrivatePropertyTypeFromConstructor: true - bootstrapFiles: - - vendor/bin/.phpunit/phpunit/vendor/autoload.php ignoreErrors: - message: "#^Method .*::test.*\\(\\) has no return type specified\\.$#" diff --git a/src/Turbo/phpunit.xml.dist b/src/Turbo/phpunit.dist.xml similarity index 62% rename from src/Turbo/phpunit.xml.dist rename to src/Turbo/phpunit.dist.xml index 2ec303c5e46..9110df00e21 100644 --- a/src/Turbo/phpunit.xml.dist +++ b/src/Turbo/phpunit.dist.xml @@ -2,16 +2,17 @@ - @@ -25,17 +26,18 @@ - + - ./src + src - - - - - - - - + + trigger_deprecation + + diff --git a/src/Turbo/tests/Bridge/Mercure/TurboStreamListenRendererTest.php b/src/Turbo/tests/Bridge/Mercure/TurboStreamListenRendererTest.php index 4ba54a0fc90..c8da5e17e7d 100644 --- a/src/Turbo/tests/Bridge/Mercure/TurboStreamListenRendererTest.php +++ b/src/Turbo/tests/Bridge/Mercure/TurboStreamListenRendererTest.php @@ -12,16 +12,16 @@ namespace Symfony\UX\Turbo\Tests\Bridge\Mercure; use App\Entity\Book; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\UX\StimulusBundle\Dto\StimulusAttributes; final class TurboStreamListenRendererTest extends KernelTestCase { /** - * @dataProvider provideTestCases - * * @param array $context */ + #[DataProvider('provideTestCases')] public function testRenderTurboStreamListen(string $template, array $context, string $expectedResult) { $twig = self::getContainer()->get('twig'); diff --git a/src/Turbo/tests/Helper/TurboStreamTest.php b/src/Turbo/tests/Helper/TurboStreamTest.php index 1757487c347..27a2e72c3d6 100644 --- a/src/Turbo/tests/Helper/TurboStreamTest.php +++ b/src/Turbo/tests/Helper/TurboStreamTest.php @@ -11,19 +11,19 @@ namespace Symfony\UX\Turbo\Tests\Helper; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\TestWith; use PHPUnit\Framework\TestCase; use Symfony\UX\Turbo\Helper\TurboStream; class TurboStreamTest extends TestCase { - /** - * @testWith ["append"] - * ["prepend"] - * ["replace"] - * ["update"] - * ["before"] - * ["after"] - */ + #[TestWith(['append'])] + #[TestWith(['prepend'])] + #[TestWith(['replace'])] + #[TestWith(['update'])] + #[TestWith(['before'])] + #[TestWith(['after'])] public function testStream(string $action) { $this->assertSame(<<assertSame(<< $attr */ + #[DataProvider('customThrowsExceptionDataProvider')] public function testCustomThrowsException(string $action, string $target, string $html, array $attr) { $this->expectException(\InvalidArgumentException::class); diff --git a/src/Turbo/tests/bootstrap.php b/src/Turbo/tests/bootstrap.php new file mode 100644 index 00000000000..89a23684510 --- /dev/null +++ b/src/Turbo/tests/bootstrap.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Symfony\Component\ErrorHandler\ErrorHandler; + +require __DIR__.'/../vendor/autoload.php'; + +// @see https://github.com/symfony/symfony/issues/53812 +ErrorHandler::register(null, false); From 194b716c15dcee875c20693fcc7c0fe7d49d001f Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Wed, 19 Nov 2025 08:43:30 +0100 Subject: [PATCH 16/17] [TwigComponent] Drop Symfony PHPUnit Bridge in favor of PHPUnit >= 11.0 --- src/TwigComponent/.gitignore | 3 ++- src/TwigComponent/composer.json | 2 +- .../{phpunit.xml.dist => phpunit.dist.xml} | 24 ++++++++++++------- .../tests/Integration/ComponentEventTest.php | 5 ++-- .../Integration/ComponentExtensionTest.php | 17 ++++--------- .../Integration/ComponentFactoryTest.php | 19 +++++++-------- .../Test/InteractsWithTwigComponentsTest.php | 13 ++++------ .../Integration/Twig/ComponentParserTest.php | 13 ++++------ .../Twig/ComponentPropsParserTest.php | 5 ++-- .../tests/Unit/ComponentAttributesTest.php | 13 ++++------ .../TwigComponentDataCollectorTest.php | 7 +++--- .../tests/Unit/TwigPreLexerTest.php | 9 +++---- src/TwigComponent/tests/bootstrap.php | 17 +++++++++++++ 13 files changed, 70 insertions(+), 77 deletions(-) rename src/TwigComponent/{phpunit.xml.dist => phpunit.dist.xml} (56%) create mode 100644 src/TwigComponent/tests/bootstrap.php diff --git a/src/TwigComponent/.gitignore b/src/TwigComponent/.gitignore index 1784dd6561c..123c390f298 100644 --- a/src/TwigComponent/.gitignore +++ b/src/TwigComponent/.gitignore @@ -2,6 +2,7 @@ /vendor/ /composer.lock /phpunit.xml -/.phpunit.result.cache +/.phpunit.cache /var +/config/reference.php diff --git a/src/TwigComponent/composer.json b/src/TwigComponent/composer.json index a049345495d..f1f7deb5d66 100644 --- a/src/TwigComponent/composer.json +++ b/src/TwigComponent/composer.json @@ -34,11 +34,11 @@ "twig/twig": "^3.10.3" }, "require-dev": { + "phpunit/phpunit": "^11.1|^12.0", "symfony/console": "^6.4|^7.0|^8.0", "symfony/css-selector": "^6.4|^7.0|^8.0", "symfony/dom-crawler": "^6.4|^7.0|^8.0", "symfony/framework-bundle": "^6.4|^7.0|^8.0", - "symfony/phpunit-bridge": "^7.2|^8.0", "symfony/stimulus-bundle": "^2.9.1", "symfony/twig-bundle": "^6.4|^7.0|^8.0" }, diff --git a/src/TwigComponent/phpunit.xml.dist b/src/TwigComponent/phpunit.dist.xml similarity index 56% rename from src/TwigComponent/phpunit.xml.dist rename to src/TwigComponent/phpunit.dist.xml index c66770e92ff..f41657868f2 100644 --- a/src/TwigComponent/phpunit.xml.dist +++ b/src/TwigComponent/phpunit.dist.xml @@ -2,16 +2,17 @@ - @@ -21,13 +22,18 @@ - + - ./src + src - - - - + + trigger_deprecation + + diff --git a/src/TwigComponent/tests/Integration/ComponentEventTest.php b/src/TwigComponent/tests/Integration/ComponentEventTest.php index 4c9c13189d7..c776de8c3a0 100644 --- a/src/TwigComponent/tests/Integration/ComponentEventTest.php +++ b/src/TwigComponent/tests/Integration/ComponentEventTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\TwigComponent\Tests\Integration; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Twig\Environment; use Twig\Loader\ArrayLoader; @@ -22,9 +23,7 @@ */ final class ComponentEventTest extends KernelTestCase { - /** - * @dataProvider provideFooBarSyntaxes - */ + #[DataProvider('provideFooBarSyntaxes')] public function testTemplateIsUpdatedByEventListener(string $syntax) { /** @var Environment $environment */ diff --git a/src/TwigComponent/tests/Integration/ComponentExtensionTest.php b/src/TwigComponent/tests/Integration/ComponentExtensionTest.php index be86a08cb57..82c9bf9ed74 100644 --- a/src/TwigComponent/tests/Integration/ComponentExtensionTest.php +++ b/src/TwigComponent/tests/Integration/ComponentExtensionTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\TwigComponent\Tests\Integration; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\UX\TwigComponent\Tests\Fixtures\User; use Twig\Environment; @@ -219,9 +220,7 @@ public function testComponentPropsWithTrailingComma() $this->assertStringContainsString('Hello FOO, 123, and 456', $output); } - /** - * @dataProvider renderingAttributesManuallyProvider - */ + #[DataProvider('renderingAttributesManuallyProvider')] public function testRenderingAttributesManually(array $attributes, string $expected) { $actual = trim($this->renderComponent('RenderAttributes', $attributes)); @@ -303,9 +302,7 @@ public function testRenderingComponentWithNestedAttributes() ); } - /** - * @dataProvider providePrefixedAttributesCases - */ + #[DataProvider('providePrefixedAttributesCases')] public function testRenderPrefixedAttributes(string $attributes, bool $expectContains) { /** @var Environment $twig */ @@ -422,9 +419,7 @@ public function testComponentWithEmptyProps() $this->assertStringContainsString('I have an empty props tag', $output); } - /** - * @dataProvider provideUnsafeAttributes - */ + #[DataProvider('provideUnsafeAttributes')] public function testHtmlSyntaxEscapesAttributeValues(string $input) { $output = self::getContainer()->get(Environment::class)->render( @@ -436,9 +431,7 @@ public function testHtmlSyntaxEscapesAttributeValues(string $input) $this->assertStringContainsString('<scr', $output); } - /** - * @dataProvider provideUnsafeAttributes - */ + #[DataProvider('provideUnsafeAttributes')] public function testDynamicSyntaxEscapesAttributeValues(string $input) { $output = self::getContainer()->get(Environment::class)->render( diff --git a/src/TwigComponent/tests/Integration/ComponentFactoryTest.php b/src/TwigComponent/tests/Integration/ComponentFactoryTest.php index df8c65754fb..3fb157af01b 100644 --- a/src/TwigComponent/tests/Integration/ComponentFactoryTest.php +++ b/src/TwigComponent/tests/Integration/ComponentFactoryTest.php @@ -11,10 +11,11 @@ namespace Symfony\UX\TwigComponent\Tests\Integration; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; +use PHPUnit\Framework\Attributes\TestWith; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\DependencyInjection\Exception\LogicException; use Symfony\UX\TwigComponent\ComponentFactory; -use Symfony\UX\TwigComponent\Tests\Fixtures\Component\BasicComponent; use Symfony\UX\TwigComponent\Tests\Fixtures\Component\ComponentA; use Symfony\UX\TwigComponent\Tests\Fixtures\Component\ComponentB; use Symfony\UX\TwigComponent\Tests\Fixtures\Component\ComponentC; @@ -204,13 +205,11 @@ public function testCannotGetConfigByNameForNonRegisteredComponent() $this->factory()->metadataFor('tabler'); } - /** - * @testWith ["tabler", "Unknown component \"tabler\". Did you mean this: \"table\"?"] - * ["Basic", "Unknown component \"Basic\". Did you mean this: \"BasicComponent\"?"] - * ["basic", "Unknown component \"basic\". Did you mean this: \"BasicComponent\"?"] - * ["with", "Unknown component \"with\". Did you mean one of these: \"with_attributes\", \"with_exposed_variables\", \"WithSlots\"?"] - * ["anonAnon", "Unknown component \"anonAnon\". And no matching anonymous component template was found."] - */ + #[TestWith(['tabler', 'Unknown component "tabler". Did you mean this: "table"?'])] + #[TestWith(['Basic', 'Unknown component "Basic". Did you mean this: "BasicComponent"?'])] + #[TestWith(['basic', 'Unknown component "basic". Did you mean this: "BasicComponent"?'])] + #[TestWith(['with', 'Unknown component "with". Did you mean one of these: "with_attributes", "with_exposed_variables", "WithSlots"?'])] + #[TestWith(['anonAnon', 'Unknown component "anonAnon". And no matching anonymous component template was found.'])] public function testCannotGetInvalidComponent(string $name, string $expectedExceptionMessage) { $this->expectException(\InvalidArgumentException::class); @@ -225,9 +224,7 @@ public function testInputPropsStoredOnMountedComponent() $this->assertSame(['propA' => 'A', 'propB' => 'B'], $mountedComponent->getInputProps()); } - /** - * @doesNotPerformAssertions - */ + #[DoesNotPerformAssertions] public function testGetComponentWithClassName() { $factory = $this->factory(); diff --git a/src/TwigComponent/tests/Integration/Test/InteractsWithTwigComponentsTest.php b/src/TwigComponent/tests/Integration/Test/InteractsWithTwigComponentsTest.php index 1d2b78524c5..19a220e4050 100644 --- a/src/TwigComponent/tests/Integration/Test/InteractsWithTwigComponentsTest.php +++ b/src/TwigComponent/tests/Integration/Test/InteractsWithTwigComponentsTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\TwigComponent\Tests\Integration\Test; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\UX\TwigComponent\Test\InteractsWithTwigComponents; use Symfony\UX\TwigComponent\Tests\Fixtures\Component\ComponentA; @@ -21,9 +22,7 @@ final class InteractsWithTwigComponentsTest extends KernelTestCase { use InteractsWithTwigComponents; - /** - * @dataProvider componentANameProvider - */ + #[DataProvider('componentANameProvider')] public function testCanMountComponent(string $name) { $component = $this->mountTwigComponent($name, [ @@ -37,9 +36,7 @@ public function testCanMountComponent(string $name) $this->assertSame('prop b value', $component->getPropB()); } - /** - * @dataProvider componentANameProvider - */ + #[DataProvider('componentANameProvider')] public function testCanRenderComponent(string $name) { $rendered = $this->renderTwigComponent($name, [ @@ -53,9 +50,7 @@ public function testCanRenderComponent(string $name) $this->assertCount(2, $rendered->crawler()->filter('ul li')); } - /** - * @dataProvider withSlotsNameProvider - */ + #[DataProvider('withSlotsNameProvider')] public function testCanRenderComponentWithSlots(string $name) { $rendered = $this->renderTwigComponent( diff --git a/src/TwigComponent/tests/Integration/Twig/ComponentParserTest.php b/src/TwigComponent/tests/Integration/Twig/ComponentParserTest.php index e5806747328..b957191101b 100644 --- a/src/TwigComponent/tests/Integration/Twig/ComponentParserTest.php +++ b/src/TwigComponent/tests/Integration/Twig/ComponentParserTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\TwigComponent\Tests\Integration\Twig; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Twig\Environment; use Twig\Error\SyntaxError; @@ -24,9 +25,7 @@ */ final class ComponentParserTest extends KernelTestCase { - /** - * @dataProvider provideValidComponentNames - */ + #[DataProvider('provideValidComponentNames')] public function testAcceptTwigComponentTagWithValidComponentName(string $name) { $environment = $this->createEnvironment(); @@ -37,9 +36,7 @@ public function testAcceptTwigComponentTagWithValidComponentName(string $name) $this->assertInstanceOf(TemplateWrapper::class, $template); } - /** - * @dataProvider provideValidComponentNames - */ + #[DataProvider('provideValidComponentNames')] public function testAcceptHtmlComponentTagWithValidComponentName(string $name) { $environment = $this->createEnvironment(); @@ -50,9 +47,7 @@ public function testAcceptHtmlComponentTagWithValidComponentName(string $name) $this->assertInstanceOf(TemplateWrapper::class, $template); } - /** - * @dataProvider provideValidComponentNames - */ + #[DataProvider('provideValidComponentNames')] public function testAcceptHtmlSelfClosingComponentTagWithValidComponentName(string $name) { $environment = $this->createEnvironment(); diff --git a/src/TwigComponent/tests/Integration/Twig/ComponentPropsParserTest.php b/src/TwigComponent/tests/Integration/Twig/ComponentPropsParserTest.php index c7d48de8578..9a6a8b5c03b 100644 --- a/src/TwigComponent/tests/Integration/Twig/ComponentPropsParserTest.php +++ b/src/TwigComponent/tests/Integration/Twig/ComponentPropsParserTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\TwigComponent\Tests\Integration\Twig; +use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\UX\TwigComponent\Twig\PropsNode; use Twig\Environment; @@ -25,9 +26,7 @@ */ class ComponentPropsParserTest extends KernelTestCase { - /** - * @dataProvider providePropsData - */ + #[DataProvider('providePropsData')] public function testPropsData(string $template, array $props, string $text) { $loader = new ArrayLoader(['template' => $template]); diff --git a/src/TwigComponent/tests/Unit/ComponentAttributesTest.php b/src/TwigComponent/tests/Unit/ComponentAttributesTest.php index c674c39d0be..b53a4627327 100644 --- a/src/TwigComponent/tests/Unit/ComponentAttributesTest.php +++ b/src/TwigComponent/tests/Unit/ComponentAttributesTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\TwigComponent\Tests\Unit; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\UX\StimulusBundle\Dto\StimulusAttributes; use Symfony\UX\TwigComponent\ComponentAttributes; @@ -227,9 +228,7 @@ public function testConvertTrueAriaAttributeValue() $attributes->render('aria-bar'); } - /** - * @dataProvider provideSpecialSyntaxAttributeNames - */ + #[DataProvider('provideSpecialSyntaxAttributeNames')] public function testAllowsSpecialSyntaxAttributeNames(string $name) { $attributes = new ComponentAttributes([$name => 'value'], new EscaperRuntime()); @@ -253,9 +252,7 @@ public function testThrowsTypeErrorWithoutEscaperRuntime() new ComponentAttributes([]); } - /** - * @dataProvider nameProvider - */ + #[DataProvider('nameProvider')] public function testEscapeName(string $input, string $expected) { $runtime = new EscaperRuntime(); @@ -264,9 +261,7 @@ public function testEscapeName(string $input, string $expected) $this->assertSame(' '.$expected.'="foo"', (string) $attributes); } - /** - * @dataProvider valueProvider - */ + #[DataProvider('valueProvider')] public function testEscapeValue(string $input, string $expected) { $runtime = new EscaperRuntime(); diff --git a/src/TwigComponent/tests/Unit/DataCollector/TwigComponentDataCollectorTest.php b/src/TwigComponent/tests/Unit/DataCollector/TwigComponentDataCollectorTest.php index e0cca8e8f47..832a72a172c 100644 --- a/src/TwigComponent/tests/Unit/DataCollector/TwigComponentDataCollectorTest.php +++ b/src/TwigComponent/tests/Unit/DataCollector/TwigComponentDataCollectorTest.php @@ -11,6 +11,7 @@ namespace Symfony\UX\TwigComponent\Tests\Unit\DataCollector; +use PHPUnit\Framework\Attributes\TestWith; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -61,10 +62,8 @@ public function testLateCollectWithNoCollectedData() $this->assertEquals(0.0, $dataCollector->getRenderTime()); } - /** - * @testWith [true] - * [false] - */ + #[TestWith([true])] + #[TestWith([false])] public function testLateCollectWithCollectedData(bool $collectComponents) { $logger = new TwigComponentLoggerListener(); diff --git a/src/TwigComponent/tests/Unit/TwigPreLexerTest.php b/src/TwigComponent/tests/Unit/TwigPreLexerTest.php index c056c5ffea1..130bc7bb305 100644 --- a/src/TwigComponent/tests/Unit/TwigPreLexerTest.php +++ b/src/TwigComponent/tests/Unit/TwigPreLexerTest.php @@ -11,24 +11,21 @@ namespace Symfony\UX\TwigComponent\Tests\Unit; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\UX\TwigComponent\Twig\TwigPreLexer; use Twig\Error\SyntaxError; final class TwigPreLexerTest extends TestCase { - /** - * @dataProvider getLexTests - */ + #[DataProvider('getLexTests')] public function testPreLex(string $input, string $expectedOutput) { $lexer = new TwigPreLexer(); $this->assertSame($expectedOutput, $lexer->preLexComponents($input)); } - /** - * @dataProvider getInvalidSyntaxTests - */ + #[DataProvider('getInvalidSyntaxTests')] public function testPreLexThrowsExceptionOnInvalidSyntax(string $input, string $expectedMessage) { $this->expectException(SyntaxError::class); diff --git a/src/TwigComponent/tests/bootstrap.php b/src/TwigComponent/tests/bootstrap.php new file mode 100644 index 00000000000..89a23684510 --- /dev/null +++ b/src/TwigComponent/tests/bootstrap.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Symfony\Component\ErrorHandler\ErrorHandler; + +require __DIR__.'/../vendor/autoload.php'; + +// @see https://github.com/symfony/symfony/issues/53812 +ErrorHandler::register(null, false); From b91e7295be50208f790ae6d24ef1b52128fc8954 Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Wed, 19 Nov 2025 08:43:36 +0100 Subject: [PATCH 17/17] [Vue] Drop Symfony PHPUnit Bridge in favor of PHPUnit >= 11.0 --- src/Vue/.gitignore | 2 +- src/Vue/composer.json | 2 +- .../{phpunit.xml.dist => phpunit.dist.xml} | 24 ++++++++++++------- src/Vue/tests/bootstrap.php | 17 +++++++++++++ 4 files changed, 34 insertions(+), 11 deletions(-) rename src/Vue/{phpunit.xml.dist => phpunit.dist.xml} (52%) create mode 100644 src/Vue/tests/bootstrap.php diff --git a/src/Vue/.gitignore b/src/Vue/.gitignore index 2cc9f0231c3..095a90a8430 100644 --- a/src/Vue/.gitignore +++ b/src/Vue/.gitignore @@ -2,4 +2,4 @@ /vendor/ /composer.lock /phpunit.xml -/.phpunit.result.cache +/.phpunit.cache diff --git a/src/Vue/composer.json b/src/Vue/composer.json index 61550c467d6..0f812c4ee47 100644 --- a/src/Vue/composer.json +++ b/src/Vue/composer.json @@ -36,10 +36,10 @@ "symfony/stimulus-bundle": "^2.9.1" }, "require-dev": { + "phpunit/phpunit": "^11.1|^12.0", "symfony/asset-mapper": "^6.4|^7.0|^8.0", "symfony/finder": "^6.4|^7.0|^8.0", "symfony/framework-bundle": "^6.4|^7.0|^8.0", - "symfony/phpunit-bridge": "^7.2|^8.0", "symfony/twig-bundle": "^6.4|^7.0|^8.0", "symfony/var-dumper": "^6.4|^7.0|^8.0" }, diff --git a/src/Vue/phpunit.xml.dist b/src/Vue/phpunit.dist.xml similarity index 52% rename from src/Vue/phpunit.xml.dist rename to src/Vue/phpunit.dist.xml index e969286d27c..f9c71639b73 100644 --- a/src/Vue/phpunit.xml.dist +++ b/src/Vue/phpunit.dist.xml @@ -2,16 +2,17 @@ - @@ -20,13 +21,18 @@ - + - ./src + src - - - - + + trigger_deprecation + + diff --git a/src/Vue/tests/bootstrap.php b/src/Vue/tests/bootstrap.php new file mode 100644 index 00000000000..89a23684510 --- /dev/null +++ b/src/Vue/tests/bootstrap.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Symfony\Component\ErrorHandler\ErrorHandler; + +require __DIR__.'/../vendor/autoload.php'; + +// @see https://github.com/symfony/symfony/issues/53812 +ErrorHandler::register(null, false);