Skip to content
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

Add Recipe for PHPUnit 10 #1239

Conversation

alexander-schranz
Copy link
Contributor

@alexander-schranz alexander-schranz commented Sep 11, 2023

Q A
License MIT
Doc issue/PR symfony/symfony-docs#...

This will add a recipe for PHPUnit 10:

Following changes:

@symfony-recipes-bot symfony-recipes-bot enabled auto-merge (squash) September 11, 2023 23:09
@github-actions
Copy link

github-actions bot commented Sep 11, 2023

Thanks for the PR 😍

How to test these changes in your application

  1. Define the SYMFONY_ENDPOINT environment variable:

    # On Unix-like (BSD, Linux and macOS)
    export SYMFONY_ENDPOINT=https://raw.githubusercontent.com/symfony/recipes/flex/pull-1239/index.json
    # On Windows
    SET SYMFONY_ENDPOINT=https://raw.githubusercontent.com/symfony/recipes/flex/pull-1239/index.json
  2. Install the package(s) related to this recipe:

    composer req symfony/flex
    composer req 'phpunit/phpunit:^10.0' 'symfony/panther:^1.0'
  3. Don't forget to unset the SYMFONY_ENDPOINT environment variable when done:

    # On Unix-like (BSD, Linux and macOS)
    unset SYMFONY_ENDPOINT
    # On Windows
    SET SYMFONY_ENDPOINT=

Diff between recipe versions

In order to help with the review stage, I'm in charge of computing the diff between the various versions of patched recipes.
I'm going keep this comment up to date with any updates of the attached patch.

phpunit/phpunit

4.7 vs 9.3
diff --git a/phpunit/phpunit/4.7/phpunit.xml.dist b/phpunit/phpunit/9.3/phpunit.xml.dist
index db2b29d..23ea5cf 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 9.6
diff --git a/phpunit/phpunit/9.3/phpunit.xml.dist b/phpunit/phpunit/9.6/phpunit.xml.dist
index 23ea5cf..6c4bfed 100644
--- a/phpunit/phpunit/9.3/phpunit.xml.dist
+++ b/phpunit/phpunit/9.6/phpunit.xml.dist
@@ -33,8 +33,6 @@
         <listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
     </listeners>
 
-    <!-- Uncomment when adding extensions
     <extensions>
     </extensions>
-    -->
 </phpunit>
9.6 vs 10.0
diff --git a/phpunit/phpunit/9.6/.env.test b/phpunit/phpunit/10.0/.env.test
index 9e7162f..24a43c0 100644
--- a/phpunit/phpunit/9.6/.env.test
+++ b/phpunit/phpunit/10.0/.env.test
@@ -2,5 +2,3 @@
 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/phpunit/phpunit/9.6/manifest.json b/phpunit/phpunit/10.0/manifest.json
index 8af7b3b..a35670a 100644
--- a/phpunit/phpunit/9.6/manifest.json
+++ b/phpunit/phpunit/10.0/manifest.json
@@ -1,11 +1,11 @@
 {
     "copy-from-recipe": {
         ".env.test": ".env.test",
-        "phpunit.xml.dist": "phpunit.xml.dist",
+        "phpunit.dist.xml": "phpunit.dist.xml",
         "tests/": "tests/"
     },
     "gitignore": [
         "/phpunit.xml",
-        ".phpunit.result.cache"
+        "/.phpunit.cache/"
     ]
 }
diff --git a/phpunit/phpunit/9.6/phpunit.xml.dist b/phpunit/phpunit/10.0/phpunit.dist.xml
similarity index 72%
rename from phpunit/phpunit/9.6/phpunit.xml.dist
rename to phpunit/phpunit/10.0/phpunit.dist.xml
index 6c4bfed..580108c 100644
--- a/phpunit/phpunit/9.6/phpunit.xml.dist
+++ b/phpunit/phpunit/10.0/phpunit.dist.xml
@@ -6,7 +6,7 @@
          backupGlobals="false"
          colors="true"
          bootstrap="tests/bootstrap.php"
-         convertDeprecationsToExceptions="false"
+         cacheDirectory=".phpunit.cache"
 >
     <php>
         <ini name="display_errors" value="1" />
@@ -14,7 +14,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.5" />
     </php>
 
     <testsuites>
@@ -23,15 +23,11 @@
         </testsuite>
     </testsuites>
 
-    <coverage processUncoveredFiles="true">
+    <source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
         <include>
-            <directory suffix=".php">src</directory>
+            <directory>src</directory>
         </include>
-    </coverage>
-
-    <listeners>
-        <listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
-    </listeners>
+    </source>
 
     <extensions>
     </extensions>

auto-merge was automatically disabled September 11, 2023 23:10

Head branch was pushed to by a user without write access

@alexander-schranz alexander-schranz force-pushed the feature/add-phpunit-10-support branch from 3a804c4 to e470d73 Compare September 11, 2023 23:10
@symfony-recipes-bot symfony-recipes-bot enabled auto-merge (squash) September 11, 2023 23:10
auto-merge was automatically disabled September 11, 2023 23:12

Head branch was pushed to by a user without write access

@alexander-schranz alexander-schranz force-pushed the feature/add-phpunit-10-support branch from e470d73 to 8530d29 Compare September 11, 2023 23:12
@symfony-recipes-bot symfony-recipes-bot enabled auto-merge (squash) September 11, 2023 23:13
@@ -19,6 +19,20 @@
"content": " <extension class=\"Symfony\\Component\\Panther\\ServerExtension\" />",
"position": "after_target",
"target": "<extensions>",
"warn_if_missing": false
Copy link
Contributor Author

@alexander-schranz alexander-schranz Sep 11, 2023

Choose a reason for hiding this comment

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

by renaming the phpunit.xml.dist to phpunit.dist.xml we also have the advantages that this recipe is compatible so with phpunit 9 recipe and phpunit 10 recipe

},
{
"file": "phpunit.dist.xml",
"content": " <bootstrap class=\"Symfony\\Component\\Panther\\ServerExtension\" />",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Panther alreadys supports PHPUnit 10: symfony/panther#589

@OskarStark OskarStark disabled auto-merge October 7, 2023 10:07
derrabus
derrabus previously approved these changes Nov 5, 2023
@alexander-schranz
Copy link
Contributor Author

Anything I need to tackle here?

auto-merge was automatically disabled December 15, 2023 08:10

Head branch was pushed to by a user without write access

@symfony-recipes-bot symfony-recipes-bot enabled auto-merge (squash) December 15, 2023 08:10

require dirname(__DIR__).'/vendor/autoload.php';

if (file_exists(dirname(__DIR__).'/config/bootstrap.php')) {
Copy link

Choose a reason for hiding this comment

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

I think this is an unnecessary check

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@a1812 it is required to be compatible with Symfony 4.4 because also there people can update there recipes to latest version: https://github.com/symfony/recipes/blob/main/symfony/console/4.4/config/bootstrap.php

Copy link
Member

Choose a reason for hiding this comment

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

Symfony 4.4 is not maintained anymore now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can remove it still it will make projects on 4.4 fail if the call recipes update command.

@b-durand
Copy link

Hello, what are the conditions for validating this request? New Symfony projects don't have a valid default configuration.

@aivus
Copy link
Contributor

aivus commented Mar 5, 2025

@alexander-schranz can you please rebase the changes to the latest main, so GitHub Actions will run the build.

auto-merge was automatically disabled March 5, 2025 18:08

Head branch was pushed to by a user without write access

@alexander-schranz alexander-schranz force-pushed the feature/add-phpunit-10-support branch from 8a8f244 to b24a3c9 Compare March 5, 2025 18:08
@symfony-recipes-bot symfony-recipes-bot enabled auto-merge (squash) March 5, 2025 18:08
auto-merge was automatically disabled March 5, 2025 18:10

Head branch was pushed to by a user without write access

@symfony-recipes-bot symfony-recipes-bot enabled auto-merge (squash) March 5, 2025 18:10
@aivus
Copy link
Contributor

aivus commented Mar 5, 2025

Looks like the CI errors are expected

@mtarld @chalasr any chance to make it merged?

chalasr
chalasr previously approved these changes Mar 5, 2025
auto-merge was automatically disabled March 6, 2025 16:55

Head branch was pushed to by a user without write access

@symfony-recipes-bot symfony-recipes-bot enabled auto-merge (squash) March 6, 2025 16:55
@symfony-recipes-bot symfony-recipes-bot merged commit 12d560b into symfony:main Mar 7, 2025
2 of 4 checks passed
@alexander-schranz alexander-schranz deleted the feature/add-phpunit-10-support branch March 7, 2025 08:37
# define your env variables for the test env here
KERNEL_CLASS='App\Kernel'
APP_SECRET='$ecretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=999999
Copy link
Member

Choose a reason for hiding this comment

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

SYMFONY_DEPRECATIONS_HELPER does not make sense for PHPUnit 10+ as we want to use the PHPUnit native deprecation system, which is not configured by the env variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would appreciate to use native where possible, which I think should as I did understand Sebastian now be for all features Symfony provided in the past via the bridge?

So maybe we should also remove this part:

        <server name="SYMFONY_PHPUNIT_REMOVE" value="" />
        <server name="SYMFONY_PHPUNIT_VERSION" value="10.5" />

And should we remove the phpunit-bridge from the test-pack:

https://github.com/symfony/test-pack/blob/v1.1.0/composer.json#L10

</testsuite>
</testsuites>

<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
Copy link
Member

Choose a reason for hiding this comment

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

this does not configure the deprecation reporting in a way matching the reporting convention used in symfony/deprecation-contracts. See https://github.com/symfony/demo/pull/1549/files#diff-e35810879ec42bdd81797b3ccb72f6de28a8b4a0e3bfdba43183e133e866b892R25-R37 for the necessary configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet