-
-
Notifications
You must be signed in to change notification settings - Fork 482
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
[phpunit] limited support for PHPUnit 10 #1174
base: main
Are you sure you want to change the base?
Conversation
Thanks for the PR 😍 How to test these changes in your application
Diff between recipe versionsIn order to help with the review stage, I'm in charge of computing the diff between the various versions of patched recipes. phpunit/phpunit4.7 vs 9.3diff --git a/phpunit/phpunit/4.7/phpunit.xml.dist b/phpunit/phpunit/9.3/phpunit.xml.dist
index 5e90897..af3f147 100644
--- a/phpunit/phpunit/4.7/phpunit.xml.dist
+++ b/phpunit/phpunit/9.3/phpunit.xml.dist
@@ -6,12 +6,15 @@
backupGlobals="false"
colors="true"
bootstrap="tests/bootstrap.php"
+ convertDeprecationsToExceptions="false"
>
<php>
<ini name="display_errors" value="1" />
<ini name="error_reporting" value="-1" />
<server name="APP_ENV" value="test" force="true" />
<server name="SHELL_VERBOSITY" value="-1" />
+ <server name="SYMFONY_PHPUNIT_REMOVE" value="" />
+ <server name="SYMFONY_PHPUNIT_VERSION" value="9.5" />
</php>
<testsuites>
@@ -20,11 +23,11 @@
</testsuite>
</testsuites>
- <filter>
- <whitelist processUncoveredFilesFromWhitelist="true">
+ <coverage processUncoveredFiles="true">
+ <include>
<directory suffix=".php">src</directory>
- </whitelist>
- </filter>
+ </include>
+ </coverage>
<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" /> 9.3 vs 10.0diff --git a/phpunit/phpunit/9.3/phpunit.xml.dist b/phpunit/phpunit/10.0/phpunit.xml.dist
index af3f147..ad9789c 100644
--- a/phpunit/phpunit/9.3/phpunit.xml.dist
+++ b/phpunit/phpunit/10.0/phpunit.xml.dist
@@ -6,7 +6,6 @@
backupGlobals="false"
colors="true"
bootstrap="tests/bootstrap.php"
- convertDeprecationsToExceptions="false"
>
<php>
<ini name="display_errors" value="1" />
@@ -14,7 +13,7 @@
<server name="APP_ENV" value="test" force="true" />
<server name="SHELL_VERBOSITY" value="-1" />
<server name="SYMFONY_PHPUNIT_REMOVE" value="" />
- <server name="SYMFONY_PHPUNIT_VERSION" value="9.5" />
+ <server name="SYMFONY_PHPUNIT_VERSION" value="10.0" />
</php>
<testsuites>
@@ -23,16 +22,12 @@
</testsuite>
</testsuites>
- <coverage processUncoveredFiles="true">
+ <coverage>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
- <listeners>
- <listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
- </listeners>
-
<!-- Run `composer require symfony/panther` before enabling this extension -->
<!--
<extensions> symfony/phpunit-bridge3.3 vs 4.1diff --git a/symfony/phpunit-bridge/3.3/.env.test b/symfony/phpunit-bridge/4.1/.env.test
index 24a43c0..9e7162f 100644
--- a/symfony/phpunit-bridge/3.3/.env.test
+++ b/symfony/phpunit-bridge/4.1/.env.test
@@ -2,3 +2,5 @@
KERNEL_CLASS='App\Kernel'
APP_SECRET='$ecretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=999999
+PANTHER_APP_ENV=panther
+PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots
diff --git a/symfony/phpunit-bridge/3.3/bin/phpunit b/symfony/phpunit-bridge/4.1/bin/phpunit
index 0b79fd4..63dae24 100755
--- a/symfony/phpunit-bridge/3.3/bin/phpunit
+++ b/symfony/phpunit-bridge/4.1/bin/phpunit
@@ -6,12 +6,6 @@ if (!file_exists(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-php
exit(1);
}
-if (false === getenv('SYMFONY_PHPUNIT_VERSION')) {
- putenv('SYMFONY_PHPUNIT_VERSION=6.5');
-}
-if (false === getenv('SYMFONY_PHPUNIT_REMOVE')) {
- putenv('SYMFONY_PHPUNIT_REMOVE=symfony/yaml');
-}
if (false === getenv('SYMFONY_PHPUNIT_DIR')) {
putenv('SYMFONY_PHPUNIT_DIR='.__DIR__.'/.phpunit');
}
diff --git a/symfony/phpunit-bridge/3.3/phpunit.xml.dist b/symfony/phpunit-bridge/4.1/phpunit.xml.dist
index 294a559..d81f0c3 100644
--- a/symfony/phpunit-bridge/3.3/phpunit.xml.dist
+++ b/symfony/phpunit-bridge/4.1/phpunit.xml.dist
@@ -8,10 +8,11 @@
bootstrap="tests/bootstrap.php"
>
<php>
- <ini name="display_errors" value="1" />
<ini name="error_reporting" value="-1" />
<server name="APP_ENV" value="test" force="true" />
<server name="SHELL_VERBOSITY" value="-1" />
+ <server name="SYMFONY_PHPUNIT_REMOVE" value="" />
+ <server name="SYMFONY_PHPUNIT_VERSION" value="7.5" />
</php>
<testsuites>
@@ -21,8 +22,8 @@
</testsuites>
<filter>
- <whitelist>
- <directory>src</directory>
+ <whitelist processUncoveredFilesFromWhitelist="true">
+ <directory suffix=".php">src</directory>
</whitelist>
</filter>
4.1 vs 4.3diff --git a/symfony/phpunit-bridge/4.1/bin/phpunit b/symfony/phpunit-bridge/4.3/bin/phpunit
index 63dae24..4d1ed05 100755
--- a/symfony/phpunit-bridge/4.1/bin/phpunit
+++ b/symfony/phpunit-bridge/4.3/bin/phpunit
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
-if (!file_exists(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
- echo "Unable to find the `simple-phpunit` script in `vendor/symfony/phpunit-bridge/bin/`.\n";
+if (!file_exists(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php')) {
+ echo "Unable to find the `simple-phpunit.php` script in `vendor/symfony/phpunit-bridge/bin/`.\n";
exit(1);
}
@@ -10,4 +10,4 @@ if (false === getenv('SYMFONY_PHPUNIT_DIR')) {
putenv('SYMFONY_PHPUNIT_DIR='.__DIR__.'/.phpunit');
}
-require dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit';
+require dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php';
diff --git a/symfony/phpunit-bridge/4.1/phpunit.xml.dist b/symfony/phpunit-bridge/4.3/phpunit.xml.dist
index d81f0c3..5766779 100644
--- a/symfony/phpunit-bridge/4.1/phpunit.xml.dist
+++ b/symfony/phpunit-bridge/4.3/phpunit.xml.dist
@@ -8,6 +8,7 @@
bootstrap="tests/bootstrap.php"
>
<php>
+ <ini name="display_errors" value="1" />
<ini name="error_reporting" value="-1" />
<server name="APP_ENV" value="test" force="true" />
<server name="SHELL_VERBOSITY" value="-1" /> 4.3 vs 5.1diff --git a/symfony/phpunit-bridge/4.3/phpunit.xml.dist b/symfony/phpunit-bridge/5.1/phpunit.xml.dist
index 5766779..0bd20c8 100644
--- a/symfony/phpunit-bridge/4.3/phpunit.xml.dist
+++ b/symfony/phpunit-bridge/5.1/phpunit.xml.dist
@@ -8,12 +8,11 @@
bootstrap="tests/bootstrap.php"
>
<php>
- <ini name="display_errors" value="1" />
<ini name="error_reporting" value="-1" />
<server name="APP_ENV" value="test" force="true" />
<server name="SHELL_VERBOSITY" value="-1" />
<server name="SYMFONY_PHPUNIT_REMOVE" value="" />
- <server name="SYMFONY_PHPUNIT_VERSION" value="7.5" />
+ <server name="SYMFONY_PHPUNIT_VERSION" value="8.5" />
</php>
<testsuites>
@@ -31,4 +30,11 @@
<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
</listeners>
+
+ <!-- Run `composer require symfony/panther` before enabling this extension -->
+ <!--
+ <extensions>
+ <extension class="Symfony\Component\Panther\ServerExtension" />
+ </extensions>
+ -->
</phpunit> 5.1 vs 5.3diff --git a/symfony/phpunit-bridge/5.1/bin/phpunit b/symfony/phpunit-bridge/5.3/bin/phpunit
index 4d1ed05..51cc5b5 100755
--- a/symfony/phpunit-bridge/5.1/bin/phpunit
+++ b/symfony/phpunit-bridge/5.3/bin/phpunit
@@ -1,13 +1,25 @@
#!/usr/bin/env php
<?php
-if (!file_exists(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php')) {
- echo "Unable to find the `simple-phpunit.php` script in `vendor/symfony/phpunit-bridge/bin/`.\n";
- exit(1);
+if (!ini_get('date.timezone')) {
+ ini_set('date.timezone', 'UTC');
}
-if (false === getenv('SYMFONY_PHPUNIT_DIR')) {
- putenv('SYMFONY_PHPUNIT_DIR='.__DIR__.'/.phpunit');
-}
+if (is_file(dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit')) {
+ if (class_exists(PHPUnit\TextUI\Command::class)) {
+ // PHPUnit < 9.x
+ define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__).'/vendor/autoload.php');
+ require PHPUNIT_COMPOSER_INSTALL;
+ PHPUnit\TextUI\Command::main();
+ } else {
+ // PHPUnit >= 10.0
+ require dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit';
+ }
+} else {
+ if (!is_file(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php')) {
+ echo "Unable to find the `simple-phpunit.php` script in `vendor/symfony/phpunit-bridge/bin/`.\n";
+ exit(1);
+ }
-require dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php';
+ require dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php';
+}
diff --git a/symfony/phpunit-bridge/5.1/manifest.json b/symfony/phpunit-bridge/5.3/manifest.json
index a2ed0cb..4fb292b 100644
--- a/symfony/phpunit-bridge/5.1/manifest.json
+++ b/symfony/phpunit-bridge/5.3/manifest.json
@@ -6,7 +6,6 @@
"tests/": "tests/"
},
"gitignore": [
- ".phpunit",
".phpunit.result.cache",
"/phpunit.xml"
],
diff --git a/symfony/phpunit-bridge/5.1/phpunit.xml.dist b/symfony/phpunit-bridge/5.3/phpunit.xml.dist
index 0bd20c8..af3f147 100644
--- a/symfony/phpunit-bridge/5.1/phpunit.xml.dist
+++ b/symfony/phpunit-bridge/5.3/phpunit.xml.dist
@@ -2,17 +2,19 @@
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="bin/.phpunit/phpunit.xsd"
+ xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="tests/bootstrap.php"
+ convertDeprecationsToExceptions="false"
>
<php>
+ <ini name="display_errors" value="1" />
<ini name="error_reporting" value="-1" />
<server name="APP_ENV" value="test" force="true" />
<server name="SHELL_VERBOSITY" value="-1" />
<server name="SYMFONY_PHPUNIT_REMOVE" value="" />
- <server name="SYMFONY_PHPUNIT_VERSION" value="8.5" />
+ <server name="SYMFONY_PHPUNIT_VERSION" value="9.5" />
</php>
<testsuites>
@@ -21,11 +23,11 @@
</testsuite>
</testsuites>
- <filter>
- <whitelist processUncoveredFilesFromWhitelist="true">
+ <coverage processUncoveredFiles="true">
+ <include>
<directory suffix=".php">src</directory>
- </whitelist>
- </filter>
+ </include>
+ </coverage>
<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
diff --git a/symfony/phpunit-bridge/5.1/post-install.txt b/symfony/phpunit-bridge/5.3/post-install.txt
index 2db39ab..e9da2a6 100644
--- a/symfony/phpunit-bridge/5.1/post-install.txt
+++ b/symfony/phpunit-bridge/5.3/post-install.txt
@@ -1,2 +1,3 @@
* Write test cases in the tests/ folder
- * Run php bin/phpunit
+ * Use MakerBundle's make:test command as a shortcut!
+ * Run the tests with php bin/phpunit |
c91939c
to
03b3867
Compare
0a604cd
to
f8300d6
Compare
PHPUnit\TextUI\Command::main(); | ||
} else { | ||
// PHPUnit >= 10.0 | ||
require dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the bridge is not compatible with phpunit 10.
I'd suggest removing that part for now at least
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering about a 3rd option :).
Is there a reason why we called PHPUnit\TextUI\Command::main()
for PHPUnit 9.5 vs requiring the executable? Could this new code be used in ALL cases?
the bridge is not compatible with phpunit 10.
I understand this... but since you CAN easily install phpunit-bridge
and PHPUnit 10, if there is a straightforward way to get this file working today, why wait until tomorrow to do it? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the bridge is not compatible with phpunit 10.
I would argue that at all times the phpunit-bridge
should preventively declare a conflict with future major versions of PHPunit until tested/adapted, it already declares some:
"conflict": {
"phpunit/phpunit": "<7.5|9.1.2"
},
I'd suggest adding |>=11
once v10 support is implemented (won't make any difference now as Composer will just install the older version not declaring the conflict).
Right now running symfony new test
followed by composer req symfony/phpunit-bridge phpunit/phpunit
on a new project will create a broken project.
@nicolas-grekas @weaverryan @curry684 I'm joining late, and uncalled, but... I'm pretty sure now something has already changed related to PHPUnit 10.x (at least in regards to Symfony 5.4 and 6.2, unsure about 6.3 for the moment...) Should this still remain open, or should it be closed? I'm wondering because of XML validation and deprecation errors with PhpUnit 10.0.19 and Symfony 6.3.1, for now... |
phpunit.xml.dist
for when a usercomposer require phpunit/phpunit
.bin/phpunit
to run PHPUnit 10 (\PHPUnit\TextUI\Command
classes areinternal
/ have been removed)