Skip to content

[RFC] Add PHPUnit 11 recipe, treat PHPUnitBridge only as a PHPUnit extension #1401

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 4 commits into
base: main
Choose a base branch
from

Conversation

wouterj
Copy link
Member

@wouterj wouterj commented Apr 12, 2025

Q A
License MIT
Doc issue/PR I'll take care of this once we decide the direction for PHPUnit integration

This is a continuation of the effort to move the community towards PHPunit 11's deprecation features, in favor of the Symfony PHPUnit bridge. This is primarily based on what I submitted to the Symfony Demo a while ago: symfony/demo#1549

This PR makes a couple important changes:

  • Add a recipe for PHPUnit 11.1+. This version has a full replacement for the deprecation reporting capabilities of PhpunitBridge.

  • Change the recipe for PhpunitBridge 7.3 to no longer set-up testing (i.e. configure PHPUnit).

    Continueing Starting recommending to run PHPUnit directly #906 from 4 years ago, the only reason you might want to install PhpunitBridge in 7.2 is to use the Clock and DNS mock provided by the new SymfonyExtension for PHPUnit (introduced in 7.2).
    Since 6.2, we have a much better solution for ClockMock: the Clock component. DNS mocking is a very niche feature, unlikely to be commonly used in applications.

    On top of this, keeping the PHPUnit configuration in both the bridge and phpunit recipe creates a conflict: One creates a phpunit.xml.dist for PHPUnit 9, while the other creates a phpunit.dist.xml for PHPUnit 10+. Functionally, this doesn't create an issue as PHPUnit 10+ favors the new file name, but I think we do better to avoid this confusion of double PHPUnit configuration files.

    This recipe change depends on removing PhpunitBridge from the test-pack (Remove symfony/phpunit-bridge from test-pack test-pack#24) for Symfony 7.3.

I'm also open to only doing the 2nd change in Symfony 7.4, where I propose to deprecate the PhpunitBridge's deprecation functionality.

cc @alexander-schranz as you've done great work in this effort as well

@wouterj wouterj changed the title Add PHPUnit 11 recipe, treat PHPUnitBridge only as a PHPUnit extension [RFC] Add PHPUnit 11 recipe, treat PHPUnitBridge only as a PHPUnit extension Apr 12, 2025
@symfony-recipes-bot symfony-recipes-bot enabled auto-merge (squash) April 12, 2025 15:58
Copy link

github-actions bot commented Apr 12, 2025

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-1401/index.json
    # On Windows
    SET SYMFONY_ENDPOINT=https://raw.githubusercontent.com/symfony/recipes/flex/pull-1401/index.json
  2. Install the package(s) related to this recipe:

    composer req symfony/flex
    composer req 'phpunit/phpunit:^11.1' 'symfony/phpunit-bridge:^7.3'
  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>
10.0 vs 11.1
diff --git a/phpunit/phpunit/10.0/.env.test b/phpunit/phpunit/11.1/.env.test
index 24a43c0..64bd111 100644
--- a/phpunit/phpunit/10.0/.env.test
+++ b/phpunit/phpunit/11.1/.env.test
@@ -1,4 +1,3 @@
 # define your env variables for the test env here
 KERNEL_CLASS='App\Kernel'
 APP_SECRET='$ecretf0rt3st'
-SYMFONY_DEPRECATIONS_HELPER=999999
diff --git a/phpunit/phpunit/11.1/bin/phpunit b/phpunit/phpunit/11.1/bin/phpunit
new file mode 100755
index 0000000..692bacc
--- /dev/null
+++ b/phpunit/phpunit/11.1/bin/phpunit
@@ -0,0 +1,23 @@
+#!/usr/bin/env php
+<?php
+
+if (!ini_get('date.timezone')) {
+    ini_set('date.timezone', 'UTC');
+}
+
+if (is_file(dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit')) {
+    if (PHP_VERSION_ID >= 80000) {
+        require dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit';
+    } else {
+        define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__).'/vendor/autoload.php');
+        require PHPUNIT_COMPOSER_INSTALL;
+        PHPUnit\TextUI\Command::main();
+    }
+} 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';
+}
diff --git a/phpunit/phpunit/10.0/manifest.json b/phpunit/phpunit/11.1/manifest.json
index a35670a..bd11ce9 100644
--- a/phpunit/phpunit/10.0/manifest.json
+++ b/phpunit/phpunit/11.1/manifest.json
@@ -2,7 +2,8 @@
     "copy-from-recipe": {
         ".env.test": ".env.test",
         "phpunit.dist.xml": "phpunit.dist.xml",
-        "tests/": "tests/"
+        "tests/": "tests/",
+        "bin/": "bin/"
     },
     "gitignore": [
         "/phpunit.xml",
diff --git a/phpunit/phpunit/10.0/phpunit.dist.xml b/phpunit/phpunit/11.1/phpunit.dist.xml
index 580108c..2e264f5 100644
--- a/phpunit/phpunit/10.0/phpunit.dist.xml
+++ b/phpunit/phpunit/11.1/phpunit.dist.xml
@@ -3,8 +3,10 @@
 <!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
 <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
-         backupGlobals="false"
          colors="true"
+         failOnDeprecation="true"
+         failOnNotice="true"
+         failOnWarning="true"
          bootstrap="tests/bootstrap.php"
          cacheDirectory=".phpunit.cache"
 >
@@ -13,8 +15,6 @@
         <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="10.5" />
     </php>
 
     <testsuites>
@@ -23,10 +23,20 @@
         </testsuite>
     </testsuites>
 
-    <source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
+    <source ignoreSuppressionOfDeprecations="true"
+            ignoreIndirectDeprecations="true"
+            restrictNotices="true"
+            restrictWarnings="true"
+    >
         <include>
             <directory>src</directory>
         </include>
+
+        <deprecationTrigger>
+            <function>trigger_deprecation</function>
+            <method>Doctrine\Deprecations\Deprecation::trigger</method>
+            <method>Doctrine\Deprecations\Deprecation::delegateTriggerToBackend</method>
+        </deprecationTrigger>
     </source>
 
     <extensions>
diff --git a/phpunit/phpunit/11.1/post-install.txt b/phpunit/phpunit/11.1/post-install.txt
new file mode 100644
index 0000000..e9da2a6
--- /dev/null
+++ b/phpunit/phpunit/11.1/post-install.txt
@@ -0,0 +1,3 @@
+  * Write test cases in the tests/ folder
+  * Use MakerBundle's make:test command as a shortcut!
+  * Run the tests with php bin/phpunit
diff --git a/phpunit/phpunit/10.0/tests/bootstrap.php b/phpunit/phpunit/11.1/tests/bootstrap.php
index 8276338..47a5855 100644
--- a/phpunit/phpunit/10.0/tests/bootstrap.php
+++ b/phpunit/phpunit/11.1/tests/bootstrap.php
@@ -7,3 +7,7 @@ require dirname(__DIR__).'/vendor/autoload.php';
 if (method_exists(Dotenv::class, 'bootEnv')) {
     (new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
 }
+
+if ($_SERVER['APP_DEBUG']) {
+    umask(0000);
+}

symfony/phpunit-bridge

3.3 vs 4.1
diff --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.3
diff --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.1
diff --git a/symfony/phpunit-bridge/4.3/phpunit.xml.dist b/symfony/phpunit-bridge/5.1/phpunit.xml.dist
index 5766779..40593c6 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,9 @@
     <listeners>
         <listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
     </listeners>
+
+    <!-- Uncomment when adding extensions
+    <extensions>
+    </extensions>
+    -->
 </phpunit>
5.1 vs 5.3
diff --git a/symfony/phpunit-bridge/5.1/bin/phpunit b/symfony/phpunit-bridge/5.3/bin/phpunit
index 4d1ed05..692bacc 100755
--- a/symfony/phpunit-bridge/5.1/bin/phpunit
+++ b/symfony/phpunit-bridge/5.3/bin/phpunit
@@ -1,13 +1,23 @@
 #!/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 (PHP_VERSION_ID >= 80000) {
+        require dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit';
+    } else {
+        define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__).'/vendor/autoload.php');
+        require PHPUNIT_COMPOSER_INSTALL;
+        PHPUnit\TextUI\Command::main();
+    }
+} 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..724e481 100644
--- a/symfony/phpunit-bridge/5.1/manifest.json
+++ b/symfony/phpunit-bridge/5.3/manifest.json
@@ -6,9 +6,11 @@
         "tests/": "tests/"
     },
     "gitignore": [
-        ".phpunit",
         ".phpunit.result.cache",
         "/phpunit.xml"
     ],
+    "conflict": {
+        "symfony/framework-bundle": "<5.4"
+    },
     "aliases": ["simple-phpunit"]
 }
diff --git a/symfony/phpunit-bridge/5.1/phpunit.xml.dist b/symfony/phpunit-bridge/5.3/phpunit.xml.dist
index 40593c6..23ea5cf 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
diff --git a/symfony/phpunit-bridge/5.1/tests/bootstrap.php b/symfony/phpunit-bridge/5.3/tests/bootstrap.php
index 3181151..47a5855 100644
--- a/symfony/phpunit-bridge/5.1/tests/bootstrap.php
+++ b/symfony/phpunit-bridge/5.3/tests/bootstrap.php
@@ -4,9 +4,7 @@ use Symfony\Component\Dotenv\Dotenv;
 
 require dirname(__DIR__).'/vendor/autoload.php';
 
-if (file_exists(dirname(__DIR__).'/config/bootstrap.php')) {
-    require dirname(__DIR__).'/config/bootstrap.php';
-} elseif (method_exists(Dotenv::class, 'bootEnv')) {
+if (method_exists(Dotenv::class, 'bootEnv')) {
     (new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
 }
 
5.3 vs 6.3
diff --git a/symfony/phpunit-bridge/5.3/manifest.json b/symfony/phpunit-bridge/6.3/manifest.json
index 724e481..485aa5c 100644
--- a/symfony/phpunit-bridge/5.3/manifest.json
+++ b/symfony/phpunit-bridge/6.3/manifest.json
@@ -10,6 +10,7 @@
         "/phpunit.xml"
     ],
     "conflict": {
+        "phpunit/phpunit": "<9.6",
         "symfony/framework-bundle": "<5.4"
     },
     "aliases": ["simple-phpunit"]
diff --git a/symfony/phpunit-bridge/5.3/phpunit.xml.dist b/symfony/phpunit-bridge/6.3/phpunit.xml.dist
index 23ea5cf..c76a655 100644
--- a/symfony/phpunit-bridge/5.3/phpunit.xml.dist
+++ b/symfony/phpunit-bridge/6.3/phpunit.xml.dist
@@ -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="9.6" />
     </php>
 
     <testsuites>
@@ -33,8 +33,6 @@
         <listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
     </listeners>
 
-    <!-- Uncomment when adding extensions
     <extensions>
     </extensions>
-    -->
 </phpunit>
6.3 vs 7.3
diff --git a/symfony/phpunit-bridge/6.3/.env.test b/symfony/phpunit-bridge/6.3/.env.test
deleted file mode 100644
index 9e7162f..0000000
--- a/symfony/phpunit-bridge/6.3/.env.test
+++ /dev/null
@@ -1,6 +0,0 @@
-# define your env variables for the test env here
-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/6.3/bin/phpunit b/symfony/phpunit-bridge/6.3/bin/phpunit
deleted file mode 100755
index 692bacc..0000000
--- a/symfony/phpunit-bridge/6.3/bin/phpunit
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/env php
-<?php
-
-if (!ini_get('date.timezone')) {
-    ini_set('date.timezone', 'UTC');
-}
-
-if (is_file(dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit')) {
-    if (PHP_VERSION_ID >= 80000) {
-        require dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit';
-    } else {
-        define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__).'/vendor/autoload.php');
-        require PHPUNIT_COMPOSER_INSTALL;
-        PHPUnit\TextUI\Command::main();
-    }
-} 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';
-}
diff --git a/symfony/phpunit-bridge/6.3/manifest.json b/symfony/phpunit-bridge/7.3/manifest.json
index 485aa5c..ef144e7 100644
--- a/symfony/phpunit-bridge/6.3/manifest.json
+++ b/symfony/phpunit-bridge/7.3/manifest.json
@@ -1,13 +1,19 @@
 {
-    "copy-from-recipe": {
-        ".env.test": ".env.test",
-        "bin/": "%BIN_DIR%/",
-        "phpunit.xml.dist": "phpunit.xml.dist",
-        "tests/": "tests/"
-    },
-    "gitignore": [
-        ".phpunit.result.cache",
-        "/phpunit.xml"
+    "add-lines": [
+        {
+            "file": "phpunit.xml.dist",
+            "content": "        <listener class=\"Symfony\\Bridge\\PhpUnit\\SymfonyTestsListener\" />",
+            "position": "after_target",
+            "target": "<extensions>",
+            "warn_if_missing": false
+        },
+        {
+            "file": "phpunit.dist.xml",
+            "content": "        <bootstrap class=\"Symfony\\Bridge\\PhpUnit\\SymfonyExtension\">\n            <parameter name=\"clock-mock-namespaces\" value=\"App\" />\n            <parameter name=\"dns-mock-namespaces\" value=\"App\" />\n        </bootstrap>",
+            "position": "after_target",
+            "target": "<extensions>",
+            "warn_if_missing": false
+        }
     ],
     "conflict": {
         "phpunit/phpunit": "<9.6",
diff --git a/symfony/phpunit-bridge/6.3/phpunit.xml.dist b/symfony/phpunit-bridge/6.3/phpunit.xml.dist
deleted file mode 100644
index c76a655..0000000
--- a/symfony/phpunit-bridge/6.3/phpunit.xml.dist
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
-<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         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="9.6" />
-    </php>
-
-    <testsuites>
-        <testsuite name="Project Test Suite">
-            <directory>tests</directory>
-        </testsuite>
-    </testsuites>
-
-    <coverage processUncoveredFiles="true">
-        <include>
-            <directory suffix=".php">src</directory>
-        </include>
-    </coverage>
-
-    <listeners>
-        <listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
-    </listeners>
-
-    <extensions>
-    </extensions>
-</phpunit>
diff --git a/symfony/phpunit-bridge/6.3/post-install.txt b/symfony/phpunit-bridge/6.3/post-install.txt
deleted file mode 100644
index e9da2a6..0000000
--- a/symfony/phpunit-bridge/6.3/post-install.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-  * Write test cases in the tests/ folder
-  * Use MakerBundle's make:test command as a shortcut!
-  * Run the tests with php bin/phpunit
diff --git a/symfony/phpunit-bridge/6.3/tests/bootstrap.php b/symfony/phpunit-bridge/6.3/tests/bootstrap.php
deleted file mode 100644
index 47a5855..0000000
--- a/symfony/phpunit-bridge/6.3/tests/bootstrap.php
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-
-use Symfony\Component\Dotenv\Dotenv;
-
-require dirname(__DIR__).'/vendor/autoload.php';
-
-if (method_exists(Dotenv::class, 'bootEnv')) {
-    (new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
-}
-
-if ($_SERVER['APP_DEBUG']) {
-    umask(0000);
-}

Spomky
Spomky previously approved these changes Apr 12, 2025
@nicolas-grekas
Copy link
Member

There's still sebastianbergmann/phpunit#6165 on the path for best support of deprecation notices. Unfortunately it's going to be shipped with PHPUnit 12, which requires PHP 8.3 minimum.

I'm wondering: does this recipe support PHPUnit 12 also?

@wouterj
Copy link
Member Author

wouterj commented Apr 14, 2025

Oh, good find! PHPUnit 12 is supported with this config (no deprecations or breaking changes).
However, we might want to wait out the progress on that issue to determine if we want make to make this push for 7.3 already. It would be a bit of a regression if PHPUnit does not support autoloading deprecations yet.

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.

4 participants