Skip to content

run tests using PHPUnit 11.5 #58370

New issue

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

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

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: 7.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ jobs:
git diff --exit-code src/ || (echo '::error::Run "php .github/sync-translations.php" to fix XLIFF files.' && exit 1)

- name: Run tests
run: ./phpunit --group integration -v
run: ./phpunit --group integration
env:
INTEGRATION_FTP_URL: 'ftp://test:test@localhost'
REDIS_HOST: 'localhost:16379'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
([ -d "$COMPOSER_HOME" ] || mkdir "$COMPOSER_HOME") && cp .github/composer-config.json "$COMPOSER_HOME/config.json"
export COMPOSER_ROOT_VERSION=$(grep ' VERSION = ' src/Symfony/Component/HttpKernel/Kernel.php | grep -P -o '[0-9]+\.[0-9]+').x-dev
composer remove --dev --no-update --no-interaction symfony/phpunit-bridge
composer require --no-progress --ansi --no-plugins psalm/phar:@stable phpunit/phpunit:^9.6 php-http/discovery psr/event-dispatcher mongodb/mongodb jetbrains/phpstorm-stubs
composer require --no-progress --ansi --no-plugins psalm/phar:@stable phpunit/phpunit:^11.5 php-http/discovery psr/event-dispatcher mongodb/mongodb jetbrains/phpstorm-stubs

- name: Generate Psalm baseline
run: |
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
([ -d "$COMPOSER_HOME" ] || mkdir "$COMPOSER_HOME") && cp .github/composer-config.json "$COMPOSER_HOME/config.json"

echo COLUMNS=120 >> $GITHUB_ENV
echo PHPUNIT="$(pwd)/phpunit --exclude-group tty,benchmark,intl-data,integration" >> $GITHUB_ENV
echo PHPUNIT="$(pwd)/phpunit --exclude-group tty --exclude-group benchmark --exclude-group intl-data --exclude-group integration" >> $GITHUB_ENV
echo COMPOSER_UP='composer update --no-progress --ansi'$([[ "${{ matrix.mode }}" != low-deps ]] && echo ' --ignore-platform-req=php+') >> $GITHUB_ENV

SYMFONY_VERSIONS=$(git ls-remote -q --heads | cut -f2 | grep -o '/[1-9][0-9]*\.[0-9].*' | sort -V)
Expand All @@ -103,7 +103,6 @@ jobs:
if [[ ! "${{ matrix.mode }}" = *-deps ]]; then
php .github/build-packages.php HEAD^ $SYMFONY_VERSION src/Symfony/Bridge/PhpUnit
else
echo SYMFONY_DEPRECATIONS_HELPER=weak >> $GITHUB_ENV
cp composer.json composer.json.orig
echo -e '{\n"require":{'"$(grep phpunit-bridge composer.json)"'"php":"*"},"minimum-stability":"dev"}' > composer.json
php .github/build-packages.php HEAD^ $SYMFONY_VERSION $(find src/Symfony -mindepth 2 -type f -name composer.json -printf '%h\n' | grep -v src/Symfony/Component/Emoji/Resources/bin)
Expand Down Expand Up @@ -238,18 +237,18 @@ jobs:
run: |
mkdir build
cd build
wget -q https://github.com/symfony/binary-utils/releases/download/v0.1/php-8.2.0-pcntl-sigchild.tar.bz2
wget -q https://github.com/xabbuh/binary-utils/releases/download/test/php-8.2.0-pcntl-sigchild.tar.bz2
tar -xjf php-8.2.0-pcntl-sigchild.tar.bz2
cd ..

mkdir -p /opt/php/lib
echo memory_limit=-1 > /opt/php/lib/php.ini
./build/php/bin/php ./phpunit --colors=always src/Symfony/Component/Process
./phpunit install
./build/php/bin/php ./phpunit src/Symfony/Component/Process

- name: Run PhpUnitBridge tests with PHPUnit 11
- name: Run PhpUnitBridge tests with PHPUnit 9.6
if: '! matrix.mode'
run: |
./phpunit src/Symfony/Bridge/PhpUnit
env:
SYMFONY_PHPUNIT_VERSION: '11.3'
SYMFONY_DEPRECATIONS_HELPER: 'disabled'
SYMFONY_PHPUNIT_VERSION: '9.6'
137 changes: 101 additions & 36 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions:
contents: read

jobs:
windows:
windows-minimal-exts:
name: x86 / minimal-exts / lowest-php

defaults:
Expand All @@ -23,7 +23,6 @@ jobs:

env:
COMPOSER_NO_INTERACTION: '1'
SYMFONY_DEPRECATIONS_HELPER: 'strict'
ANSICON: '121x90 (121x90)'
SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE: '1'

Expand Down Expand Up @@ -51,30 +50,17 @@ jobs:
iwr -outf php_redis-6.0.0-dev-8.2-ts-vs16-x86.zip https://github.com/symfony/binary-utils/releases/download/v0.1/php_redis-6.0.0-dev-8.2-ts-vs16-x86.zip
7z x php_redis-6.0.0-dev-8.2-ts-vs16-x86.zip -y >nul
cd ..
Copy php.ini-development php.ini-min
"memory_limit=-1" >> php.ini-min
"serialize_precision=-1" >> php.ini-min
"max_execution_time=1200" >> php.ini-min
"post_max_size=2047M" >> php.ini-min
"upload_max_filesize=2047M" >> php.ini-min
"date.timezone=`"America/Los_Angeles`"" >> php.ini-min
"extension_dir=ext" >> php.ini-min
"extension=php_xsl.dll" >> php.ini-min
"extension=php_mbstring.dll" >> php.ini-min
Copy php.ini-min php.ini-max
"zend_extension=php_opcache.dll" >> php.ini-max
"opcache.enable_cli=1" >> php.ini-max
"extension=php_openssl.dll" >> php.ini-max
"extension=php_apcu.dll" >> php.ini-max
"extension=php_igbinary.dll" >> php.ini-max
"extension=php_redis.dll" >> php.ini-max
"apc.enable_cli=1" >> php.ini-max
"extension=php_intl.dll" >> php.ini-max
"extension=php_fileinfo.dll" >> php.ini-max
"extension=php_pdo_sqlite.dll" >> php.ini-max
"extension=php_curl.dll" >> php.ini-max
"extension=php_sodium.dll" >> php.ini-max
Copy php.ini-max php.ini
Copy php.ini-development php.ini
"memory_limit=-1" >> php.ini
"serialize_precision=-1" >> php.ini
"max_execution_time=1200" >> php.ini
"post_max_size=2047M" >> php.ini
"upload_max_filesize=2047M" >> php.ini
"date.timezone=`"America/Los_Angeles`"" >> php.ini
"extension_dir=ext" >> php.ini
"extension=php_xsl.dll" >> php.ini
"extension=php_mbstring.dll" >> php.ini
"extension=php_openssl.dll" >> php.ini
cd ${{ github.workspace }}
iwr -outf composer.phar https://getcomposer.org/download/latest-stable/composer.phar

Expand All @@ -100,32 +86,111 @@ jobs:
run: |
choco install --no-progress memurai-developer

- name: Run tests (minimal extensions)
if: always() && steps.setup.outcome == 'success'
- name: Run tests
run: |
$env:Path = 'c:\php;' + $env:Path
$env:SYMFONY_PHPUNIT_SKIPPED_TESTS = 'phpunit.skipped'
$x = 0

Copy c:\php\php.ini-min c:\php\php.ini
Remove-Item -Path src\Symfony\Bridge\PhpUnit -Recurse
mv src\Symfony\Component\HttpClient\phpunit.xml.dist src\Symfony\Component\HttpClient\phpunit.xml
php phpunit src\Symfony --exclude-group tty,benchmark,intl-data,network,transient-on-windows || ($x = 1)
php phpunit src\Symfony --exclude-group tty --exclude-group benchmark --exclude-group intl-data --exclude-group network --exclude-group transient-on-windows || ($x = 1)
# HttpClient tests need to run separately, they block when run with other components' tests concurrently
php phpunit src\Symfony\Component\HttpClient || ($x = 1)

exit $x

windows-all-extensions:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make things easier to maintain, would it be worth backporting this split of the Windows jobs ? what do you think @nicolas-grekas ?

Copy link
Member Author

@xabbuh xabbuh Apr 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we talked about that in #58721 but decided to not split the two test runs as we would otherwise run many of the tests twice since the phpunit.skipped would not be shared

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any discussion about that in the PR you linked

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, maybe @nicolas-grekas and me talked about that on Slack directly 🤔

name: x86 / all extensions / lowest-php

defaults:
run:
shell: pwsh

runs-on: windows-2022

env:
COMPOSER_NO_INTERACTION: '1'
ANSICON: '121x90 (121x90)'
SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE: '1'

steps:
- name: Setup Git
run: |
git config --global core.autocrlf false
git config --global user.email ""
git config --global user.name "Symfony"

- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Setup PHP
run: |
$env:Path = 'c:\php;' + $env:Path
mkdir c:\php && cd c:\php
iwr -outf php-8.2.0-Win32-vs16-x86.zip https://github.com/symfony/binary-utils/releases/download/v0.1/php-8.2.0-Win32-vs16-x86.zip
7z x php-8.2.0-Win32-vs16-x86.zip -y >nul
cd ext
iwr -outf php_apcu-5.1.22-8.2-ts-vs16-x86.zip https://github.com/symfony/binary-utils/releases/download/v0.1/php_apcu-5.1.22-8.2-ts-vs16-x86.zip
7z x php_apcu-5.1.22-8.2-ts-vs16-x86.zip -y >nul
iwr -outf php_redis-6.0.0-dev-8.2-ts-vs16-x86.zip https://github.com/symfony/binary-utils/releases/download/v0.1/php_redis-6.0.0-dev-8.2-ts-vs16-x86.zip
7z x php_redis-6.0.0-dev-8.2-ts-vs16-x86.zip -y >nul
cd ..
Copy php.ini-development php.ini
"memory_limit=-1" >> php.ini
"serialize_precision=-1" >> php.ini
"max_execution_time=1200" >> php.ini
"post_max_size=2047M" >> php.ini
"upload_max_filesize=2047M" >> php.ini
"date.timezone=`"America/Los_Angeles`"" >> php.ini
"extension_dir=ext" >> php.ini
"extension=php_xsl.dll" >> php.ini
"extension=php_mbstring.dll" >> php.ini
"zend_extension=php_opcache.dll" >> php.ini
"opcache.enable_cli=1" >> php.ini
"extension=php_openssl.dll" >> php.ini
"extension=php_apcu.dll" >> php.ini
"extension=php_igbinary.dll" >> php.ini
"extension=php_redis.dll" >> php.ini
"apc.enable_cli=1" >> php.ini
"extension=php_intl.dll" >> php.ini
"extension=php_fileinfo.dll" >> php.ini
"extension=php_pdo_sqlite.dll" >> php.ini
"extension=php_curl.dll" >> php.ini
"extension=php_sodium.dll" >> php.ini
cd ${{ github.workspace }}
iwr -outf composer.phar https://getcomposer.org/download/latest-stable/composer.phar

- name: Install dependencies
id: setup
run: |
$env:Path = 'c:\php;' + $env:Path
mkdir $env:APPDATA\Composer && Copy .github\composer-config.json $env:APPDATA\Composer\config.json

$env:SYMFONY_VERSION=(Select-String -CaseSensitive -Pattern " VERSION =" -SimpleMatch -Path src/Symfony/Component/HttpKernel/Kernel.php | Select Line | Select-String -Pattern "([0-9][0-9]*\.[0-9])").Matches.Value
$env:COMPOSER_ROOT_VERSION=$env:SYMFONY_VERSION + ".x-dev"

php .github/build-packages.php HEAD^ $env:SYMFONY_VERSION src\Symfony\Bridge\PhpUnit
php composer.phar update --no-progress --ansi

- name: Install PHPUnit
run: |
$env:Path = 'c:\php;' + $env:Path

php phpunit install

- name: Install memurai-developer
run: |
choco install --no-progress memurai-developer

- name: Run tests
if: always() && steps.setup.outcome == 'success'
run: |
$env:Path = 'c:\php;' + $env:Path
$env:SYMFONY_PHPUNIT_SKIPPED_TESTS = 'phpunit.skipped'
$x = 0

Copy c:\php\php.ini-max c:\php\php.ini
php phpunit src\Symfony --exclude-group tty,benchmark,intl-data,network,transient-on-windows || ($x = 1)
php phpunit src\Symfony --exclude-group tty --exclude-group benchmark --exclude-group intl-data --exclude-group network --exclude-group transient-on-windows --requires-php-extension apcu --requires-php-extension curl --requires-php-extension fileinfo --requires-php-extension igbinary --requires-php-extension intl --requires-php-extension openssl --requires-php-extension pdo_sqlite --requires-php-extension redis --requires-php-extension sodium || ($x = 1)
# HttpClient tests need to run separately, they block when run with other components' tests concurrently
php phpunit src\Symfony\Component\HttpClient || ($x = 1)
php phpunit src\Symfony\Component\HttpClient --requires-php-extension curl --requires-php-extension openssl || ($x = 1)

exit $x
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ composer.lock
phpunit.xml
.php-cs-fixer.cache
.php-cs-fixer.php
.phpunit.cache
.phpunit.result.cache
composer.phar
package.tar
Expand Down
2 changes: 1 addition & 1 deletion phpunit
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
exit(1);
}
if (!getenv('SYMFONY_PHPUNIT_VERSION')) {
putenv('SYMFONY_PHPUNIT_VERSION=9.6');
putenv('SYMFONY_PHPUNIT_VERSION=11.5');
}
if (!getenv('SYMFONY_PATCH_TYPE_DECLARATIONS')) {
putenv('SYMFONY_PATCH_TYPE_DECLARATIONS=deprecations=1');
Expand Down
36 changes: 10 additions & 26 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/9.3/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.3/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
failOnDeprecation="true"
failOnRisky="true"
failOnWarning="true"
>
Expand Down Expand Up @@ -46,15 +47,15 @@
</exclude>
</groups>

<coverage>
<source ignoreSuppressionOfDeprecations="true">
<include>
<directory>./src/Symfony/</directory>
</include>
<exclude>
<directory>./src/Symfony/Bridge/*/Tests</directory>
<directory>./src/Symfony/Component/*/Tests</directory>
<directory>./src/Symfony/Component/*/*/Tests</directory>
<directory>./src/Symfony/Contract/*/Tests</directory>
<directory>./src/Symfony/Contracts/*/Tests</directory>
<directory>./src/Symfony/Bundle/*/Tests</directory>
<directory>./src/Symfony/Bundle/*/Resources</directory>
<directory>./src/Symfony/Component/*/Resources</directory>
Expand All @@ -65,28 +66,11 @@
<directory>./src/Symfony/Component/*/*/vendor</directory>
<directory>./src/Symfony/Contracts/*/vendor</directory>
</exclude>
</coverage>
</source>

<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener">
<arguments>
<array>
<element key="time-sensitive">
<array>
<element key="0"><string>Cache\IntegrationTests</string></element>
<element key="1"><string>Symfony\Bridge\Doctrine\Middleware\Debug</string></element>
<element key="2"><string>Symfony\Bridge\Doctrine\Middleware\IdleConnection</string></element>
<element key="3"><string>Symfony\Component\Cache</string></element>
<element key="4"><string>Symfony\Component\Cache\Tests\Fixtures</string></element>
<element key="5"><string>Symfony\Component\Cache\Tests\Traits</string></element>
<element key="6"><string>Symfony\Component\Cache\Traits</string></element>
<element key="7"><string>Symfony\Component\Console</string></element>
<element key="8"><string>Symfony\Component\HttpFoundation</string></element>
<element key="9"><string>Symfony\Component\Uid</string></element>
</array>
</element>
</array>
</arguments>
</listener>
</listeners>
<extensions>
<bootstrap class="Symfony\Bridge\PhpUnit\SymfonyExtension">
<parameter name="clock-mock-namespaces" value="Cache\IntegrationTests,Symfony\Bridge\Doctrine\Middleware\Debug,Symfony\Bridge\Doctrine\Middleware\IdleConnection,Symfony\Component\Cache,Symfony\Component\Cache\Tests\Fixtures,Symfony\Component\Cache\Tests\Traits,Symfony\Component\Cache\Traits,Symfony\Component\Console,Symfony\Component\HttpFoundation,Symfony\Component\Uid" />
</bootstrap>
</extensions>
</phpunit>
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Doctrine\Persistence\Mapping\ClassMetadata;
use Doctrine\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectRepository;
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Doctrine\ArgumentResolver\EntityValueResolver;
Expand Down Expand Up @@ -64,9 +65,7 @@ public function testResolveWithoutManager()
$this->assertSame([], $resolver->resolve($request, $argument));
}

/**
* @group legacy
*/
#[IgnoreDeprecations]
public function testResolveWithNoIdAndDataOptional()
{
$manager = $this->createMock(ObjectManager::class);
Expand Down Expand Up @@ -251,9 +250,7 @@ public static function idsProvider(): iterable
yield ['foo'];
}

/**
* @group legacy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we keep a legacy group for our tests covering deprecated behaviors ? Our deps=high job is excluding this group when running tests for a version that is not part of the last major version (as the dependencies could be installed at the next major version already):

# Legacy tests are skipped when deps=high and when the current branch version has not the same major version number as the next one
[[ "${{ matrix.mode }}" = high-deps && $SYMFONY_VERSION = *.4 ]] && echo LEGACY=,legacy >> $GITHUB_ENV || true

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thinking about this again, I think this option was overkill and was leading to not testing some parts of the code in CI in our LTS branches. Many legacy tests we have are about testing deprecations of their own component, which does not need such exclusion. Tests relying on cross-package deprecations could be responsible for skipping themselves when needed.

*/
#[IgnoreDeprecations]
public function testResolveGuessOptional()
{
$manager = $this->createMock(ObjectManager::class);
Expand Down
Loading
Loading