From: =?utf-8?q?David_Pr=C3=A9vot?= <taffit@debian.org>
Date: Wed, 12 Feb 2025 21:42:46 +0100
Subject: Compatibility with recent PHPUnit (12)

---
 tests/ComparatorTest.php                     |  8 ++++++++
 tests/Constraint/ConstraintTest.php          |  8 ++++++++
 tests/Constraint/MatchAllConstraintTest.php  |  2 ++
 tests/Constraint/MatchNoneConstraintTest.php |  2 ++
 tests/Constraint/MultiConstraintTest.php     |  6 ++++++
 tests/IntervalsTest.php                      |  3 +++
 tests/SemverTest.php                         |  4 ++++
 tests/SubsetsTest.php                        |  3 +++
 tests/VersionParserTest.php                  | 29 ++++++++++++++++++++++------
 9 files changed, 59 insertions(+), 6 deletions(-)

diff --git a/tests/ComparatorTest.php b/tests/ComparatorTest.php
index ee3240c..1701176 100644
--- a/tests/ComparatorTest.php
+++ b/tests/ComparatorTest.php
@@ -11,6 +11,7 @@
 
 namespace Composer\Semver;
 
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 use Composer\Semver\Constraint\Constraint;
 
@@ -29,6 +30,7 @@ class ComparatorTest extends TestCase
      * @param string $version2
      * @param bool   $expected
      */
+    #[DataProvider('greaterThanProvider')]
     public function testGreaterThan($version1, $version2, $expected)
     {
         $this->assertEquals($expected, Comparator::greaterThan($version1, $version2));
@@ -44,6 +46,7 @@ class ComparatorTest extends TestCase
      * @param string $version2
      * @param bool   $expected
      */
+    #[DataProvider('greaterThanOrEqualToProvider')]
     public function testGreaterThanOrEqualTo($version1, $version2, $expected)
     {
         $this->assertEquals($expected, Comparator::greaterThanOrEqualTo($version1, $version2));
@@ -59,6 +62,7 @@ class ComparatorTest extends TestCase
      * @param string $version2
      * @param bool   $expected
      */
+    #[DataProvider('lessThanProvider')]
     public function testLessThan($version1, $version2, $expected)
     {
         $this->assertEquals($expected, Comparator::lessThan($version1, $version2));
@@ -74,6 +78,7 @@ class ComparatorTest extends TestCase
      * @param string $version2
      * @param bool   $expected
      */
+    #[DataProvider('lessThanOrEqualToProvider')]
     public function testLessThanOrEqualTo($version1, $version2, $expected)
     {
         $this->assertEquals($expected, Comparator::lessThanOrEqualTo($version1, $version2));
@@ -89,6 +94,7 @@ class ComparatorTest extends TestCase
      * @param string $version2
      * @param bool   $expected
      */
+    #[DataProvider('equalToProvider')]
     public function testEqualTo($version1, $version2, $expected)
     {
         $this->assertEquals($expected, Comparator::equalTo($version1, $version2));
@@ -104,6 +110,7 @@ class ComparatorTest extends TestCase
      * @param string $version2
      * @param bool   $expected
      */
+    #[DataProvider('notEqualToProvider')]
     public function testNotEqualTo($version1, $version2, $expected)
     {
         $this->assertEquals($expected, Comparator::notEqualTo($version1, $version2));
@@ -120,6 +127,7 @@ class ComparatorTest extends TestCase
      *
      * @phpstan-param Constraint::STR_OP_* $operator
      */
+    #[DataProvider('compareProvider')]
     public function testCompare($version1, $operator, $version2, $expected)
     {
         $this->assertEquals($expected, Comparator::compare($version1, $operator, $version2));
diff --git a/tests/Constraint/ConstraintTest.php b/tests/Constraint/ConstraintTest.php
index d515d5b..831be7b 100644
--- a/tests/Constraint/ConstraintTest.php
+++ b/tests/Constraint/ConstraintTest.php
@@ -13,6 +13,8 @@ namespace Composer\Semver\Constraint;
 
 use Exception;
 use LogicException;
+use PHPUnit\Framework\Attributes\Before;
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 use Composer\Semver\Intervals;
 
@@ -31,6 +33,7 @@ class ConstraintTest extends TestCase
      * @before
      * @return void
      */
+    #[Before()]
     public function setUpTestCase()
     {
         $this->constraint = new Constraint('==', '1');
@@ -175,6 +178,7 @@ class ConstraintTest extends TestCase
      * @param Constraint::STR_OP_* $provideOperator
      * @param string $provideVersion
      */
+    #[DataProvider('successfulVersionMatches')]
     public function testVersionMatchSucceeds($requireOperator, $requireVersion, $provideOperator, $provideVersion)
     {
         $versionRequire = new Constraint($requireOperator, $requireVersion);
@@ -352,6 +356,7 @@ class ConstraintTest extends TestCase
      * @param Constraint::STR_OP_* $provideOperator
      * @param string $provideVersion
      */
+    #[DataProvider('failingVersionMatches')]
     public function testVersionMatchFails($requireOperator, $requireVersion, $provideOperator, $provideVersion)
     {
         $versionRequire = new Constraint($requireOperator, $requireVersion);
@@ -430,6 +435,7 @@ class ConstraintTest extends TestCase
      * @param Constraint::STR_OP_* $operator
      * @param class-string<Exception> $expected
      */
+    #[DataProvider('invalidOperators')]
     public function testInvalidOperators($version, $operator, $expected)
     {
         $this->doExpectException($expected);
@@ -457,6 +463,7 @@ class ConstraintTest extends TestCase
      * @param Bound  $expectedLower
      * @param Bound  $expectedUpper
      */
+    #[DataProvider('bounds')]
     public function testBounds($operator, $normalizedVersion, Bound $expectedLower, Bound $expectedUpper)
     {
         $constraint = new Constraint($operator, $normalizedVersion);
@@ -514,6 +521,7 @@ class ConstraintTest extends TestCase
      * @param Constraint::STR_OP_* $provideOperator
      * @param string $provideVersion
      */
+    #[DataProvider('matrix')]
     public function testCompile($requireOperator, $requireVersion, $provideOperator, $provideVersion)
     {
         $require = new Constraint($requireOperator, $requireVersion);
diff --git a/tests/Constraint/MatchAllConstraintTest.php b/tests/Constraint/MatchAllConstraintTest.php
index ad4152e..54967d5 100644
--- a/tests/Constraint/MatchAllConstraintTest.php
+++ b/tests/Constraint/MatchAllConstraintTest.php
@@ -11,6 +11,7 @@
 
 namespace Composer\Semver\Constraint;
 
+use PHPUnit\Framework\Attributes\Before;
 use PHPUnit\Framework\TestCase;
 
 class MatchAllConstraintTest extends TestCase
@@ -28,6 +29,7 @@ class MatchAllConstraintTest extends TestCase
      * @before
      * @return void
      */
+    #[Before()]
     public function setUpTestCase()
     {
         $this->versionProvide = new Constraint('==', '1.1');
diff --git a/tests/Constraint/MatchNoneConstraintTest.php b/tests/Constraint/MatchNoneConstraintTest.php
index 801d2af..e9f2289 100644
--- a/tests/Constraint/MatchNoneConstraintTest.php
+++ b/tests/Constraint/MatchNoneConstraintTest.php
@@ -11,6 +11,7 @@
 
 namespace Composer\Semver\Constraint;
 
+use PHPUnit\Framework\Attributes\Before;
 use PHPUnit\Framework\TestCase;
 
 class MatchNoneConstraintTest extends TestCase
@@ -24,6 +25,7 @@ class MatchNoneConstraintTest extends TestCase
      * @before
      * @return void
      */
+    #[Before()]
     public function setUpTestCase()
     {
         $this->matchNoneConstraint = new MatchNoneConstraint();
diff --git a/tests/Constraint/MultiConstraintTest.php b/tests/Constraint/MultiConstraintTest.php
index f8e8684..385a8a6 100644
--- a/tests/Constraint/MultiConstraintTest.php
+++ b/tests/Constraint/MultiConstraintTest.php
@@ -12,6 +12,8 @@
 namespace Composer\Semver\Constraint;
 
 use Composer\Semver\VersionParser;
+use PHPUnit\Framework\Attributes\Before;
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 use Composer\Semver\Intervals;
 
@@ -30,6 +32,7 @@ class MultiConstraintTest extends TestCase
      * @before
      * @return void
      */
+    #[Before()]
     public function setUpTestCase()
     {
         $this->versionRequireStart = new Constraint('>', '1.0');
@@ -147,6 +150,7 @@ class MultiConstraintTest extends TestCase
      * @param Bound $expectedLower
      * @param Bound $expectedUpper
      */
+    #[DataProvider('bounds')]
     public function testBounds(array $constraints, $conjunctive, Bound $expectedLower, Bound $expectedUpper)
     {
         $constraint = new MultiConstraint($constraints, $conjunctive);
@@ -218,6 +222,7 @@ class MultiConstraintTest extends TestCase
      * @param Bound  $expectedLower
      * @param Bound  $expectedUpper
      */
+    #[DataProvider('boundsIntegration')]
     public function testBoundsIntegrationWithVersionParser($constraints, Bound $expectedLower, Bound $expectedUpper)
     {
         $versionParser = new VersionParser();
@@ -313,6 +318,7 @@ class MultiConstraintTest extends TestCase
      *
      * @param string $constraints
      */
+    #[DataProvider('multiConstraintOptimizations')]
     public function testMultiConstraintOptimizations($constraints, ConstraintInterface $expectedConstraint)
     {
         // We're using the version parser here because that uses MultiConstraint::create() internally and
diff --git a/tests/IntervalsTest.php b/tests/IntervalsTest.php
index 457d8e3..19ced5c 100644
--- a/tests/IntervalsTest.php
+++ b/tests/IntervalsTest.php
@@ -11,6 +11,7 @@
 
 namespace Composer\Semver;
 
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 use Composer\Semver\Constraint\ConstraintInterface;
 use Composer\Semver\Constraint\MultiConstraint;
@@ -32,6 +33,7 @@ class IntervalsTest extends TestCase
      * @param array<string> $toCompact
      * @param bool $conjunctive
      */
+    #[DataProvider('compactProvider')]
     public function testCompactConstraint($expected, $toCompact, $conjunctive)
     {
         $parser = new VersionParser;
@@ -197,6 +199,7 @@ class IntervalsTest extends TestCase
      * @param array<mixed>|self::INTERVAL_* $expected
      * @param string $constraint
      */
+    #[DataProvider('intervalsProvider')]
     public function testGetIntervals($expected, $constraint)
     {
         if (is_string($constraint)) {
diff --git a/tests/SemverTest.php b/tests/SemverTest.php
index 3bbb30f..e0d318c 100644
--- a/tests/SemverTest.php
+++ b/tests/SemverTest.php
@@ -11,6 +11,7 @@
 
 namespace Composer\Semver;
 
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 
 /**
@@ -26,6 +27,7 @@ class SemverTest extends TestCase
      * @param string $version
      * @param string $constraint
      */
+    #[DataProvider('satisfiesProvider')]
     public function testSatisfies($expected, $version, $constraint)
     {
         $this->assertEquals($expected, Semver::satisfies($version, $constraint));
@@ -39,6 +41,7 @@ class SemverTest extends TestCase
      * @param array<string> $versions
      * @param array<string> $expected
      */
+    #[DataProvider('satisfiedByProvider')]
     public function testSatisfiedBy($constraint, $versions, $expected)
     {
         $this->assertEquals($expected, Semver::satisfiedBy($versions, $constraint));
@@ -54,6 +57,7 @@ class SemverTest extends TestCase
      * @param array<string> $sorted
      * @param array<string> $rsorted
      */
+    #[DataProvider('sortProvider')]
     public function testSort(array $versions, array $sorted, array $rsorted)
     {
         $this->assertEquals($sorted, Semver::sort($versions));
diff --git a/tests/SubsetsTest.php b/tests/SubsetsTest.php
index 72f8d74..46c4348 100644
--- a/tests/SubsetsTest.php
+++ b/tests/SubsetsTest.php
@@ -11,6 +11,7 @@
 
 namespace Composer\Semver;
 
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 use Composer\Semver\Constraint\MatchNoneConstraint;
 use Composer\Semver\Constraint\MatchAllConstraint;
@@ -22,6 +23,7 @@ class SubsetsTest extends TestCase
      * @param string $aStr
      * @param string $bStr
      */
+    #[DataProvider('subsets')]
     public function testIsSubsetOf($aStr, $bStr)
     {
         $versionParser = new VersionParser;
@@ -89,6 +91,7 @@ class SubsetsTest extends TestCase
      * @param string $aStr
      * @param string $bStr
      */
+    #[DataProvider('notSubsets')]
     public function testIsNotSubsetOf($aStr, $bStr)
     {
         $versionParser = new VersionParser;
diff --git a/tests/VersionParserTest.php b/tests/VersionParserTest.php
index 9eedac3..fe5ad7a 100644
--- a/tests/VersionParserTest.php
+++ b/tests/VersionParserTest.php
@@ -16,6 +16,7 @@ use Composer\Semver\Constraint\MultiConstraint;
 use Composer\Semver\Constraint\Constraint;
 use Exception;
 use LogicException;
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 
 class VersionParserTest extends TestCase
@@ -25,6 +26,7 @@ class VersionParserTest extends TestCase
      * @param string $input
      * @param string $expected
      */
+    #[DataProvider('numericAliasVersions')]
     public function testParseNumericAliasPrefix($input, $expected)
     {
         $parser = new VersionParser();
@@ -54,6 +56,7 @@ class VersionParserTest extends TestCase
      * @param string $input
      * @param string $expected
      */
+    #[DataProvider('successfulNormalizedVersions')]
     public function testNormalizeSucceeds($input, $expected)
     {
         $parser = new VersionParser();
@@ -149,6 +152,7 @@ class VersionParserTest extends TestCase
      * @dataProvider failingNormalizedVersions
      * @param string $input
      */
+    #[DataProvider('failingNormalizedVersions')]
     public function testNormalizeFails($input)
     {
         $this->doExpectException('UnexpectedValueException');
@@ -182,12 +186,12 @@ class VersionParserTest extends TestCase
             'constraint' => array('~1'),
             'constraint/2' => array('^1'),
             'constraint/3' => array('1.*'),
-            'date versions with 4 bits' => array('20100102.0.3.4', '20100102.0.3.4'),
-            'date versions with 4 bits/earliest year' => array('100000.0.0.0', '100000.0.0.0'),
-            'invalid CalVer (as MAJOR) versions/YYYYMMD' => array('2023013.0.0', '2023013.0.0'),
-            'invalid CalVer (as MAJOR) versions/YYYYMMDDh' => array('202301311.0.0', '202301311.0.0'),
-            'invalid CalVer (as MAJOR) versions/YYYYMMDDhhm' => array('20230131000.0.0', '20230131000.0.0'),
-            'invalid CalVer (as MAJOR) versions/YYYYMMDDhhmmX' => array('2023013100000.0.0', '2023013100000.0.0'),
+            'date versions with 4 bits' => array('20100102.0.3.4'), #, '20100102.0.3.4'),
+            'date versions with 4 bits/earliest year' => array('100000.0.0.0'), #, '100000.0.0.0'),
+            'invalid CalVer (as MAJOR) versions/YYYYMMD' => array('2023013.0.0'), #, '2023013.0.0'),
+            'invalid CalVer (as MAJOR) versions/YYYYMMDDh' => array('202301311.0.0'), #, '202301311.0.0'),
+            'invalid CalVer (as MAJOR) versions/YYYYMMDDhhm' => array('20230131000.0.0'), #, '20230131000.0.0'),
+            'invalid CalVer (as MAJOR) versions/YYYYMMDDhhmmX' => array('2023013100000.0.0'), #, '2023013100000.0.0'),
         );
     }
 
@@ -195,6 +199,7 @@ class VersionParserTest extends TestCase
      * @dataProvider failingNormalizedVersionsWithBadAlias
      * @param string $fullInput
      */
+    #[DataProvider('failingNormalizedVersionsWithBadAlias')]
     public function testNormalizeFailsAndReportsAliasIssue($fullInput)
     {
         if (!preg_match('{^([^,\s#]+)(?:#[^ ]+)? +as +([^,\s]+)$}', $fullInput, $match)) {
@@ -227,6 +232,7 @@ class VersionParserTest extends TestCase
      * @dataProvider failingNormalizedVersionsWithBadAliasee
      * @param string $fullInput
      */
+    #[DataProvider('failingNormalizedVersionsWithBadAliasee')]
     public function testNormalizeFailsAndReportsAliaseeIssue($fullInput)
     {
         if (!preg_match('{^([^,\s#]+)(?:#[^ ]+)? +as +([^,\s]+)$}', $fullInput, $match)) {
@@ -260,6 +266,7 @@ class VersionParserTest extends TestCase
      * @param string $input
      * @param string $expected
      */
+    #[DataProvider('successfulNormalizedBranches')]
     public function testNormalizeBranch($input, $expected)
     {
         $parser = new VersionParser();
@@ -329,6 +336,7 @@ class VersionParserTest extends TestCase
      * @param string     $input
      * @param Constraint $expected
      */
+    #[DataProvider('simpleConstraints')]
     public function testParseConstraintsSimple($input, $expected)
     {
         $parser = new VersionParser();
@@ -383,6 +391,7 @@ class VersionParserTest extends TestCase
      * @param Constraint|null $min
      * @param Constraint      $max
      */
+    #[DataProvider('wildcardConstraints')]
     public function testParseConstraintsWildcard($input, $min, $max)
     {
         $parser = new VersionParser();
@@ -425,6 +434,7 @@ class VersionParserTest extends TestCase
      * @param Constraint|null $min
      * @param Constraint      $max
      */
+    #[DataProvider('tildeConstraints')]
     public function testParseTildeWildcard($input, $min, $max)
     {
         $parser = new VersionParser();
@@ -472,6 +482,7 @@ class VersionParserTest extends TestCase
      * @param Constraint|null $min
      * @param Constraint      $max
      */
+    #[DataProvider('caretConstraints')]
     public function testParseCaretWildcard($input, $min, $max)
     {
         $parser = new VersionParser();
@@ -522,6 +533,7 @@ class VersionParserTest extends TestCase
      * @param Constraint|null $min
      * @param Constraint      $max
      */
+    #[DataProvider('hyphenConstraints')]
     public function testParseHyphen($input, $min, $max)
     {
         $parser = new VersionParser();
@@ -562,6 +574,7 @@ class VersionParserTest extends TestCase
      * @param string $constraint
      * @param string $expected
      */
+    #[DataProvider('constraintProvider')]
     public function testParseConstraints($constraint, $expected)
     {
         $parser = new VersionParser();
@@ -611,6 +624,7 @@ class VersionParserTest extends TestCase
      * @dataProvider multiConstraintProvider
      * @param string $constraint
      */
+    #[DataProvider('multiConstraintProvider')]
     public function testParseConstraintsMulti($constraint)
     {
         $parser = new VersionParser();
@@ -661,6 +675,7 @@ class VersionParserTest extends TestCase
      *
      * @param string $constraint
      */
+    #[DataProvider('multiConstraintProvider2')]
     public function testParseConstraintsMultiDisjunctiveHasPrioOverConjuctive($constraint)
     {
         $parser = new VersionParser();
@@ -720,6 +735,7 @@ class VersionParserTest extends TestCase
      *
      * @param string $input
      */
+    #[DataProvider('failingConstraints')]
     public function testParseConstraintsFails($input)
     {
         $this->doExpectException('UnexpectedValueException');
@@ -781,6 +797,7 @@ class VersionParserTest extends TestCase
      * @param string $expected
      * @param string $version
      */
+    #[DataProvider('stabilityProvider')]
     public function testParseStability($expected, $version)
     {
         $this->assertSame($expected, VersionParser::parseStability($version));
