Skip to content

Commit

Permalink
Replace MockBuilder by the createPartialMock method
Browse files Browse the repository at this point in the history
This resolves the following error when running the test suite using PHPUnit 10:

    Call to undefined method PHPUnit\Framework\MockObject\MockBuilder::setMethods()
  • Loading branch information
Aad Mathijssen committed Aug 22, 2024
1 parent f47a90e commit 2a52e3c
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions tests/Constraint/ConstraintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -400,9 +393,7 @@ public function testInverseMatchingOtherConstraints()
;
}

// @phpstan-ignore-next-line
$this->assertTrue($constraint->matches($multiConstraint));

Check failure on line 396 in tests/Constraint/ConstraintTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4)

Parameter #1 $provider of method Composer\Semver\Constraint\Constraint::matches() expects Composer\Semver\Constraint\ConstraintInterface, PHPUnit\Framework\MockObject\MockObject given.
// @phpstan-ignore-next-line
$this->assertTrue($constraint->matches($matchAllConstraint));

Check failure on line 397 in tests/Constraint/ConstraintTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4)

Parameter #1 $provider of method Composer\Semver\Constraint\Constraint::matches() expects Composer\Semver\Constraint\ConstraintInterface, PHPUnit\Framework\MockObject\MockObject given.
}

Expand Down

0 comments on commit 2a52e3c

Please sign in to comment.