From 2a52e3c3f156611d6e4f418933804cfa0851664f Mon Sep 17 00:00:00 2001 From: Aad Mathijssen Date: Mon, 15 Jul 2024 14:52:13 +0200 Subject: [PATCH] Replace MockBuilder by the createPartialMock method This resolves the following error when running the test suite using PHPUnit 10: Call to undefined method PHPUnit\Framework\MockObject\MockBuilder::setMethods() --- tests/Constraint/ConstraintTest.php | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/tests/Constraint/ConstraintTest.php b/tests/Constraint/ConstraintTest.php index b289ea24..1e599133 100644 --- a/tests/Constraint/ConstraintTest.php +++ b/tests/Constraint/ConstraintTest.php @@ -378,18 +378,11 @@ public function testInverseMatchingOtherConstraints() { $constraint = new Constraint('>', '1.0.0'); - $multiConstraint = $this - ->getMockBuilder('Composer\Semver\Constraint\MultiConstraint') - ->disableOriginalConstructor() - ->setMethods(array('matches')) - ->getMock() - ; - - $matchAllConstraint = $this - ->getMockBuilder('Composer\Semver\Constraint\MatchAllConstraint') - ->setMethods(array('matches')) - ->getMock() - ; + $multiConstraint = + $this->createPartialMock('Composer\Semver\Constraint\MultiConstraint', array('matches')); + + $matchAllConstraint = + $this->createPartialMock('Composer\Semver\Constraint\MatchAllConstraint', array('matches')); foreach (array($multiConstraint, $matchAllConstraint) as $mock) { $mock @@ -400,9 +393,7 @@ public function testInverseMatchingOtherConstraints() ; } - // @phpstan-ignore-next-line $this->assertTrue($constraint->matches($multiConstraint)); - // @phpstan-ignore-next-line $this->assertTrue($constraint->matches($matchAllConstraint)); }