From: William Desportes <williamdes@wdes.fr>
Date: Sun, 13 Apr 2025 14:58:08 +0200
Subject: PHPUnit 10+ compatibility fixes

Origin: vendor
Forwarded: no
---
 src/Phing/Task/Ext/PhpUnit/PHPUnitTask.php               | 7 +++++--
 tests/Phing/Test/Filter/StripPhpCommentsTest.php         | 1 -
 tests/Phing/Test/IntrospectionHelperTest.php             | 1 +
 tests/Phing/Test/Io/WindowsFileSystemTest.php            | 1 +
 tests/Phing/Test/Task/Ext/Analyzer/PhpDependTaskTest.php | 1 +
 tests/Phing/Test/Task/Ext/Analyzer/SonarTaskTest.php     | 1 -
 tests/Phing/Test/Task/Ext/Git/GitArchiveTaskTest.php     | 1 +
 tests/Phing/Test/Task/Ext/Git/GitBaseTest.php            | 1 +
 tests/Phing/Test/Task/Ext/Git/GitBranchTaskTest.php      | 1 +
 tests/Phing/Test/Task/Ext/Git/GitCheckoutTaskTest.php    | 1 +
 tests/Phing/Test/Task/Ext/Git/GitCloneTaskTest.php       | 1 +
 tests/Phing/Test/Task/Ext/Git/GitDescribeTaskTest.php    | 1 +
 tests/Phing/Test/Task/Ext/Git/GitGcTaskTest.php          | 1 +
 tests/Phing/Test/Task/Ext/Git/GitInitTaskTest.php        | 1 +
 tests/Phing/Test/Task/Ext/Git/GitLogTaskTest.php         | 1 +
 tests/Phing/Test/Task/Ext/Git/GitMergeTaskTest.php       | 1 +
 tests/Phing/Test/Task/Ext/Git/GitPullTaskTest.php        | 1 +
 tests/Phing/Test/Task/Ext/Git/GitPushTaskTest.php        | 1 +
 tests/Phing/Test/Task/Ext/Git/GitTagTaskTest.php         | 1 +
 tests/Phing/Test/Task/Optional/CoverageMergeTest.php     | 1 +
 tests/Phing/Test/Task/System/AttribTaskTest.php          | 1 +
 tests/Phing/Test/Task/System/ExecTaskTest.php            | 3 ++-
 tests/Phing/Test/Task/System/SymlinkTaskTest.php         | 1 +
 tests/Phing/Test/Type/Selector/ExecutableTest.php        | 1 +
 tests/Phing/Test/Type/Selector/SymlinkSelectorTest.php   | 1 +
 25 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/src/Phing/Task/Ext/PhpUnit/PHPUnitTask.php b/src/Phing/Task/Ext/PhpUnit/PHPUnitTask.php
index 0abea71..63ceabf 100644
--- a/src/Phing/Task/Ext/PhpUnit/PHPUnitTask.php
+++ b/src/Phing/Task/Ext/PhpUnit/PHPUnitTask.php
@@ -27,6 +27,7 @@ use Phing\Io\LogWriter;
 use Phing\Io\File;
 use Phing\Task;
 use PHPUnit\Framework\TestSuite;
+use PHPUnit\Framework\TestCase;
 use PHPUnit\TextUI\XmlConfiguration\Loader;
 use ReflectionException;
 use ReflectionClass;
@@ -463,7 +464,7 @@ class PHPUnitTask extends Task
         }
 
         $this->loadPHPUnit();
-        $suite = new \PHPUnit\Framework\TestSuite('AllTests');
+        $suite = \PHPUnit\Framework\TestSuite::empty('AllTests');
         $autoloadSave = spl_autoload_functions();
 
         if ($this->bootstrap) {
@@ -700,7 +701,9 @@ class PHPUnitTask extends Task
     protected function appendBatchTestToTestSuite(BatchTest $batchTest, $suite)
     {
         foreach ($batchTest->elements() as $element) {
-            $testClass = new $element();
+            // First argument is the test name
+            $testClass = new $element($element);
+
             if (!($testClass instanceof TestSuite)) {
                 $testClass = new ReflectionClass($element);
             }
diff --git a/tests/Phing/Test/Filter/StripPhpCommentsTest.php b/tests/Phing/Test/Filter/StripPhpCommentsTest.php
index e56f606..42efe2b 100644
--- a/tests/Phing/Test/Filter/StripPhpCommentsTest.php
+++ b/tests/Phing/Test/Filter/StripPhpCommentsTest.php
@@ -49,7 +49,6 @@ class StripPhpCommentsTest extends BuildFileTest
 
     /**
      * @throws IOException
-     * @requires OSFAMILY Windows|Linux
      */
     public function testStripPhpComments(): void
     {
diff --git a/tests/Phing/Test/IntrospectionHelperTest.php b/tests/Phing/Test/IntrospectionHelperTest.php
index fa1c435..a78b594 100644
--- a/tests/Phing/Test/IntrospectionHelperTest.php
+++ b/tests/Phing/Test/IntrospectionHelperTest.php
@@ -111,6 +111,7 @@ class IntrospectionHelperTest extends TestCase
      * @requires PHP >= 8
      * @return void
      */
+    #[\PHPUnit\Framework\Attributes\RequiresPhp('>= 8')]
     public function testUnionTypeOnSetterDoesNotCrashIH(): void
     {
         $clz = eval('return new class {
diff --git a/tests/Phing/Test/Io/WindowsFileSystemTest.php b/tests/Phing/Test/Io/WindowsFileSystemTest.php
index 5257f2d..002be74 100644
--- a/tests/Phing/Test/Io/WindowsFileSystemTest.php
+++ b/tests/Phing/Test/Io/WindowsFileSystemTest.php
@@ -30,6 +30,7 @@ use Phing\Io\WindowsFileSystem;
  *
  * @internal
  */
+#[\PHPUnit\Framework\Attributes\RequiresOperatingSystemFamily('Windows')]
 class WindowsFileSystemTest extends AbstractWinFileSystemTestCase
 {
     protected function createFileSystem(): WindowsFileSystem
diff --git a/tests/Phing/Test/Task/Ext/Analyzer/PhpDependTaskTest.php b/tests/Phing/Test/Task/Ext/Analyzer/PhpDependTaskTest.php
index d088b3e..389fec3 100644
--- a/tests/Phing/Test/Task/Ext/Analyzer/PhpDependTaskTest.php
+++ b/tests/Phing/Test/Task/Ext/Analyzer/PhpDependTaskTest.php
@@ -30,6 +30,7 @@ use Phing\Test\Support\BuildFileTest;
  * @internal
  * @requires PHP < 8.1
  */
+#[\PHPUnit\Framework\Attributes\RequiresPhp('< 8.1')]
 class PhpDependTaskTest extends BuildFileTest
 {
     public function setUp(): void
diff --git a/tests/Phing/Test/Task/Ext/Analyzer/SonarTaskTest.php b/tests/Phing/Test/Task/Ext/Analyzer/SonarTaskTest.php
index ff3039c..a2383ed 100644
--- a/tests/Phing/Test/Task/Ext/Analyzer/SonarTaskTest.php
+++ b/tests/Phing/Test/Task/Ext/Analyzer/SonarTaskTest.php
@@ -27,7 +27,6 @@ use Phing\Test\Support\BuildFileTest;
 /**
  * @author Bernhard Mendl <mail@bernhard-mendl.de>
  *
- * @requires OSFAMILY Windows|Linux
  *
  * @internal
  */
diff --git a/tests/Phing/Test/Task/Ext/Git/GitArchiveTaskTest.php b/tests/Phing/Test/Task/Ext/Git/GitArchiveTaskTest.php
index 256c402..b1a3233 100644
--- a/tests/Phing/Test/Task/Ext/Git/GitArchiveTaskTest.php
+++ b/tests/Phing/Test/Task/Ext/Git/GitArchiveTaskTest.php
@@ -29,6 +29,7 @@ use Phing\Test\Support\BuildFileTest;
  *
  * @internal
  */
+#[\PHPUnit\Framework\Attributes\RequiresOperatingSystemFamily('Linux')]
 class GitArchiveTaskTest extends BuildFileTest
 {
     public function setUp(): void
diff --git a/tests/Phing/Test/Task/Ext/Git/GitBaseTest.php b/tests/Phing/Test/Task/Ext/Git/GitBaseTest.php
index 90dcb4e..e7acee8 100644
--- a/tests/Phing/Test/Task/Ext/Git/GitBaseTest.php
+++ b/tests/Phing/Test/Task/Ext/Git/GitBaseTest.php
@@ -29,6 +29,7 @@ use Phing\Test\Support\BuildFileTest;
  *
  * @internal
  */
+#[\PHPUnit\Framework\Attributes\RequiresOperatingSystemFamily('Linux')]
 class GitBaseTest extends BuildFileTest
 {
     protected $mock;
diff --git a/tests/Phing/Test/Task/Ext/Git/GitBranchTaskTest.php b/tests/Phing/Test/Task/Ext/Git/GitBranchTaskTest.php
index d023ced..b8b1aa6 100644
--- a/tests/Phing/Test/Task/Ext/Git/GitBranchTaskTest.php
+++ b/tests/Phing/Test/Task/Ext/Git/GitBranchTaskTest.php
@@ -28,6 +28,7 @@ use Phing\Test\Support\BuildFileTest;
  *
  * @internal
  */
+#[\PHPUnit\Framework\Attributes\RequiresOperatingSystemFamily('Linux')]
 class GitBranchTaskTest extends BuildFileTest
 {
     public function setUp(): void
diff --git a/tests/Phing/Test/Task/Ext/Git/GitCheckoutTaskTest.php b/tests/Phing/Test/Task/Ext/Git/GitCheckoutTaskTest.php
index 08e996b..321d275 100644
--- a/tests/Phing/Test/Task/Ext/Git/GitCheckoutTaskTest.php
+++ b/tests/Phing/Test/Task/Ext/Git/GitCheckoutTaskTest.php
@@ -28,6 +28,7 @@ use Phing\Test\Support\BuildFileTest;
  *
  * @internal
  */
+#[\PHPUnit\Framework\Attributes\RequiresOperatingSystemFamily('Linux')]
 class GitCheckoutTaskTest extends BuildFileTest
 {
     public function setUp(): void
diff --git a/tests/Phing/Test/Task/Ext/Git/GitCloneTaskTest.php b/tests/Phing/Test/Task/Ext/Git/GitCloneTaskTest.php
index 879b4c8..c0d201b 100644
--- a/tests/Phing/Test/Task/Ext/Git/GitCloneTaskTest.php
+++ b/tests/Phing/Test/Task/Ext/Git/GitCloneTaskTest.php
@@ -28,6 +28,7 @@ use Phing\Test\Support\BuildFileTest;
  *
  * @internal
  */
+#[\PHPUnit\Framework\Attributes\RequiresOperatingSystemFamily('Linux')]
 class GitCloneTaskTest extends BuildFileTest
 {
     public function setUp(): void
diff --git a/tests/Phing/Test/Task/Ext/Git/GitDescribeTaskTest.php b/tests/Phing/Test/Task/Ext/Git/GitDescribeTaskTest.php
index b9f9d2d..2de47c9 100644
--- a/tests/Phing/Test/Task/Ext/Git/GitDescribeTaskTest.php
+++ b/tests/Phing/Test/Task/Ext/Git/GitDescribeTaskTest.php
@@ -27,6 +27,7 @@ use Phing\Test\Support\BuildFileTest;
  *
  * @internal
  */
+#[\PHPUnit\Framework\Attributes\RequiresOperatingSystemFamily('Linux')]
 class GitDescribeTaskTest extends BuildFileTest
 {
     public function setUp(): void
diff --git a/tests/Phing/Test/Task/Ext/Git/GitGcTaskTest.php b/tests/Phing/Test/Task/Ext/Git/GitGcTaskTest.php
index 07ca6c3..9313ae9 100644
--- a/tests/Phing/Test/Task/Ext/Git/GitGcTaskTest.php
+++ b/tests/Phing/Test/Task/Ext/Git/GitGcTaskTest.php
@@ -28,6 +28,7 @@ use Phing\Test\Support\BuildFileTest;
  *
  * @internal
  */
+#[\PHPUnit\Framework\Attributes\RequiresOperatingSystemFamily('Linux')]
 class GitGcTaskTest extends BuildFileTest
 {
     public function setUp(): void
diff --git a/tests/Phing/Test/Task/Ext/Git/GitInitTaskTest.php b/tests/Phing/Test/Task/Ext/Git/GitInitTaskTest.php
index 7727734..930d666 100644
--- a/tests/Phing/Test/Task/Ext/Git/GitInitTaskTest.php
+++ b/tests/Phing/Test/Task/Ext/Git/GitInitTaskTest.php
@@ -28,6 +28,7 @@ use Phing\Test\Support\BuildFileTest;
  *
  * @internal
  */
+#[\PHPUnit\Framework\Attributes\RequiresOperatingSystemFamily('Linux')]
 class GitInitTaskTest extends BuildFileTest
 {
     public function setUp(): void
diff --git a/tests/Phing/Test/Task/Ext/Git/GitLogTaskTest.php b/tests/Phing/Test/Task/Ext/Git/GitLogTaskTest.php
index 888ddae..5590962 100644
--- a/tests/Phing/Test/Task/Ext/Git/GitLogTaskTest.php
+++ b/tests/Phing/Test/Task/Ext/Git/GitLogTaskTest.php
@@ -28,6 +28,7 @@ use Phing\Test\Support\BuildFileTest;
  *
  * @internal
  */
+#[\PHPUnit\Framework\Attributes\RequiresOperatingSystemFamily('Linux')]
 class GitLogTaskTest extends BuildFileTest
 {
     private $testCommits = [
diff --git a/tests/Phing/Test/Task/Ext/Git/GitMergeTaskTest.php b/tests/Phing/Test/Task/Ext/Git/GitMergeTaskTest.php
index ac2d11c..e299c04 100644
--- a/tests/Phing/Test/Task/Ext/Git/GitMergeTaskTest.php
+++ b/tests/Phing/Test/Task/Ext/Git/GitMergeTaskTest.php
@@ -28,6 +28,7 @@ use Phing\Test\Support\BuildFileTest;
  *
  * @internal
  */
+#[\PHPUnit\Framework\Attributes\RequiresOperatingSystemFamily('Linux')]
 class GitMergeTaskTest extends BuildFileTest
 {
     public function setUp(): void
diff --git a/tests/Phing/Test/Task/Ext/Git/GitPullTaskTest.php b/tests/Phing/Test/Task/Ext/Git/GitPullTaskTest.php
index 311f519..feefaf2 100644
--- a/tests/Phing/Test/Task/Ext/Git/GitPullTaskTest.php
+++ b/tests/Phing/Test/Task/Ext/Git/GitPullTaskTest.php
@@ -28,6 +28,7 @@ use Phing\Test\Support\BuildFileTest;
  *
  * @internal
  */
+#[\PHPUnit\Framework\Attributes\RequiresOperatingSystemFamily('Linux')]
 class GitPullTaskTest extends BuildFileTest
 {
     public function setUp(): void
diff --git a/tests/Phing/Test/Task/Ext/Git/GitPushTaskTest.php b/tests/Phing/Test/Task/Ext/Git/GitPushTaskTest.php
index 63ddb75..c302878 100644
--- a/tests/Phing/Test/Task/Ext/Git/GitPushTaskTest.php
+++ b/tests/Phing/Test/Task/Ext/Git/GitPushTaskTest.php
@@ -28,6 +28,7 @@ use Phing\Test\Support\BuildFileTest;
  *
  * @internal
  */
+#[\PHPUnit\Framework\Attributes\RequiresOperatingSystemFamily('Linux')]
 class GitPushTaskTest extends BuildFileTest
 {
     public function setUp(): void
diff --git a/tests/Phing/Test/Task/Ext/Git/GitTagTaskTest.php b/tests/Phing/Test/Task/Ext/Git/GitTagTaskTest.php
index 2bb9742..80d9b3c 100644
--- a/tests/Phing/Test/Task/Ext/Git/GitTagTaskTest.php
+++ b/tests/Phing/Test/Task/Ext/Git/GitTagTaskTest.php
@@ -28,6 +28,7 @@ use Phing\Test\Support\BuildFileTest;
  *
  * @internal
  */
+#[\PHPUnit\Framework\Attributes\RequiresOperatingSystemFamily('Linux')]
 class GitTagTaskTest extends BuildFileTest
 {
     public function setUp(): void
diff --git a/tests/Phing/Test/Task/Optional/CoverageMergeTest.php b/tests/Phing/Test/Task/Optional/CoverageMergeTest.php
index dcda7f0..2f3eaf2 100644
--- a/tests/Phing/Test/Task/Optional/CoverageMergeTest.php
+++ b/tests/Phing/Test/Task/Optional/CoverageMergeTest.php
@@ -28,6 +28,7 @@ use Phing\Test\Support\BuildFileTest;
  *
  * @internal
  */
+#[\PHPUnit\Framework\Attributes\RequiresPhpExtension('xdebug')]
 class CoverageMergeTest extends BuildFileTest
 {
     public function setUp(): void
diff --git a/tests/Phing/Test/Task/System/AttribTaskTest.php b/tests/Phing/Test/Task/System/AttribTaskTest.php
index b60d645..56871d2 100644
--- a/tests/Phing/Test/Task/System/AttribTaskTest.php
+++ b/tests/Phing/Test/Task/System/AttribTaskTest.php
@@ -31,6 +31,7 @@ use Phing\Test\Support\BuildFileTest;
  *
  * @internal
  */
+#[\PHPUnit\Framework\Attributes\RequiresOperatingSystemFamily('Linux')]
 class AttribTaskTest extends BuildFileTest
 {
     public function setUp(): void
diff --git a/tests/Phing/Test/Task/System/ExecTaskTest.php b/tests/Phing/Test/Task/System/ExecTaskTest.php
index 33facf5..2a28931 100644
--- a/tests/Phing/Test/Task/System/ExecTaskTest.php
+++ b/tests/Phing/Test/Task/System/ExecTaskTest.php
@@ -214,8 +214,9 @@ class ExecTaskTest extends BuildFileTest
     }
 
     /**
-     * @requires OS Linux|Darwin
+     * @requires OSFAMILY Linux
      */
+    #[\PHPUnit\Framework\Attributes\RequiresOperatingSystemFamily('Linux')]
     public function testChangeToDir(): void
     {
         $this->executeTarget(__FUNCTION__);
diff --git a/tests/Phing/Test/Task/System/SymlinkTaskTest.php b/tests/Phing/Test/Task/System/SymlinkTaskTest.php
index 4ca09ce..25c2ed8 100644
--- a/tests/Phing/Test/Task/System/SymlinkTaskTest.php
+++ b/tests/Phing/Test/Task/System/SymlinkTaskTest.php
@@ -30,6 +30,7 @@ use Phing\Test\Support\BuildFileTest;
  *
  * @internal
  */
+#[\PHPUnit\Framework\Attributes\RequiresOperatingSystem('Linux')]
 class SymlinkTaskTest extends BuildFileTest
 {
     public function setUp(): void
diff --git a/tests/Phing/Test/Type/Selector/ExecutableTest.php b/tests/Phing/Test/Type/Selector/ExecutableTest.php
index 2c46bc1..2c1010e 100644
--- a/tests/Phing/Test/Type/Selector/ExecutableTest.php
+++ b/tests/Phing/Test/Type/Selector/ExecutableTest.php
@@ -31,6 +31,7 @@ use Phing\Test\Support\BuildFileTest;
  *
  * @internal
  */
+#[\PHPUnit\Framework\Attributes\RequiresOperatingSystem('Linux')]
 class ExecutableTest extends BuildFileTest
 {
     public function setUp(): void
diff --git a/tests/Phing/Test/Type/Selector/SymlinkSelectorTest.php b/tests/Phing/Test/Type/Selector/SymlinkSelectorTest.php
index 319a343..df21d6b 100644
--- a/tests/Phing/Test/Type/Selector/SymlinkSelectorTest.php
+++ b/tests/Phing/Test/Type/Selector/SymlinkSelectorTest.php
@@ -31,6 +31,7 @@ use Phing\Test\Support\BuildFileTest;
  *
  * @internal
  */
+#[\PHPUnit\Framework\Attributes\RequiresOperatingSystem('Linux')]
 class SymlinkSelectorTest extends BuildFileTest
 {
     public function setUp(): void
