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
[PhpUnitBridge] PHPUnit 8 incompatibility #30071
Comments
Another solution could be using class_alias: see #30084 |
…schranz) This PR was merged into the 3.4 branch. Discussion ---------- Fix KernelTestCase compatibility for PhpUnit 8 | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? |no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #30071 | License | MIT | Doc PR | As the PhpUnit 8 Testcase has different return types as PhpUnit 7 there need to be 2 different classes to support both PhpUnit 8 and PhpUnit 7. With a class alias we can then change which version is used based on the PhpUnit Version constant. The fix is a little bit hacky but to support different major versions I see no other way. Not sure as we can't upgrade symfony/symfony to PhpUnit 8 how we can create a TestCase for this change. Commits ------- 83a56a0 Fix phpunit 8 compatibility
I think we can close here now that the related PRs were merged. |
Wasn't #30124 merged only into 3.4 branch only? This bug report is about 4.2 |
We regularly merge lower branches up into branches for all still maintained Symfony versions. So the bugfix will also be part of the next 4.2 patch release. |
What about other Symfony tests? |
@garak There should be two distinct approaches. One for |
@nicolas-grekas I'd be glad to propose a PR, but I'm afraid I'm a bit lost... I tried to search in related issues and PRs and only found something related to |
I think the same strategy as https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Test/KernelShutdownOnTearDownTrait.php could work for |
But in this case the content of |
Adding |
This PR was merged into the 3.4 branch. Discussion ---------- compatibility with phpunit8 This basically adds the same phpunit8 compatibility layer added in #30084 (but for other test classes) See also discussion in #30071 | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #30071 | License | MIT | Doc PR | none Commits ------- 5ef254f compatibility with phpunit8
How can I restrict php-unit version to <8.0? |
@StevenCarre when using |
thank you. Can you tell me where this file is located please? |
You can place the xml configuration file where you want, but you have to point to the configuration file when running See https://phpunit.readthedocs.io/en/8.1/textui.html and https://phpunit.readthedocs.io/en/8.1/configuration.html |
Hi there, i have a problem when executing ./vendor/bin/simple-phpunit in a docker testing stage container. Each time i make a build, test are slow cause simple-phpunit dowload phpunit. How can i download it with other command to mantain it in cache? |
you should run |
@nicolas-grekas , thanks. I've installed phpunit with that command. The problem is when i run Looks like simple-phpunit is not detecting the installation itself, try to install and fail cause the folder already exists. |
In addition, trying setting version in phpunit.xml.dist, and the |
The problem vanish when i use a single line to copy the entire app and just one composer install: RUN composer install
COPY [".", "/var/www/"]
RUN ./vendor/bin/simple-phpunit install
# Crea la base de datos y la carga con fixtures
RUN php bin/console doctrine:database:create --env=test --no-debug
RUN php bin/console doctrine:schema:update --env=test --force --no-debug
RUN php bin/console hautelook:fixtures:load --env=test
# Ejecuta testing
RUN ./vendor/bin/simple-phpunit but error in test execution when i do this: # Copia solo dependencias y las instala
COPY composer.json composer.json
COPY composer.lock composer.lock
COPY symfony.lock symfony.lock
RUN composer install --prefer-dist --no-scripts --no-autoloader && rm -rf /root/.composer
RUN ./vendor/bin/simple-phpunit install
# Copia el codigo fuente a donde corresponde dentro del contenedor
COPY [".", "/var/www/"]
# Finish composer
RUN composer dump-autoload --no-scripts --optimize
# Crea la base de datos y la carga con fixtures
RUN php bin/console doctrine:database:create --env=test --no-debug
RUN php bin/console doctrine:schema:update --env=test --force --no-debug
RUN php bin/console hautelook:fixtures:load --env=test
# Ejecuta testing
RUN ./vendor/bin/simple-phpunit |
I replaced |
@enriquerene one year later thanks, it worked for me too. Cheers |
Symfony version(s) affected: 4.2.x (but probably all
PHP<7.0
compatible versions too)Description
Using the
symfony/testpack
,symfony/phpunit-bridge
and setting thephpunit
version on8.0
. When creating a test which extendsSymfony\Bundle\FrameworkBundle\Test\KernelTestCase
it will throw the following error:How to reproduce
https://github.com/evertharmeling/symfony-phpunit-8
Using the 'reproducer' project:
composer install
in project root.vendor/bin/simple-phpunit
in project root.Possible Solution
phpunit/phpunit
version to<8.0
Additional context
Somewhat related #14736. Because this could solve for support on
phpunit >=8.0
The text was updated successfully, but these errors were encountered: