Skip to content
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

Prepare tests for PHPUnit 10 #162

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions tests/Constraint/ConstraintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ class ConstraintTest extends TestCase
*/
protected $versionProvide;

protected function setUp()
/**
* @before
* @return void
*/
public function setUpTestCase()
{
$this->constraint = new Constraint('==', '1');
$this->versionProvide = new Constraint('==', 'dev-foo');
Expand Down Expand Up @@ -373,33 +377,29 @@ public function testVersionMatchFails($requireOperator, $requireVersion, $provid
public function testInverseMatchingOtherConstraints()
{
$constraint = new Constraint('>', '1.0.0');
$otherConstraintClasses = array(
'Composer\Semver\Constraint\MultiConstraint',
'Composer\Semver\Constraint\MatchAllConstraint'
);

$multiConstraint = $this
->getMockBuilder('Composer\Semver\Constraint\MultiConstraint')
->disableOriginalConstructor()
->setMethods(array('matches'))
->getMock()
;

$matchAllConstraint = $this
->getMockBuilder('Composer\Semver\Constraint\MatchAllConstraint')
->setMethods(array('matches'))
->getMock()
;

foreach (array($multiConstraint, $matchAllConstraint) as $mock) {
$mock
foreach ($otherConstraintClasses as $otherConstraintClass) {
$otherConstraintMockBuilder = $this->getMockBuilder($otherConstraintClass);
$otherConstraintMockBuilder->disableOriginalConstructor();
if (method_exists($otherConstraintMockBuilder, 'onlyMethods')) {
$otherConstraintMockBuilder->onlyMethods(array('matches'));
} elseif (method_exists($otherConstraintMockBuilder, 'setMethods')) {
$otherConstraintMockBuilder->setMethods(array('matches'));
}
$otherConstraintMock = $otherConstraintMockBuilder->getMock();
$otherConstraintMock
->expects($this->once())
->method('matches')
->with($constraint)
->willReturn(true)
;
// @phpstan-ignore-next-line
$this->assertTrue($constraint->matches($otherConstraintMock));
}

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

public function testComparableBranches()
Expand Down
6 changes: 5 additions & 1 deletion tests/Constraint/MatchAllConstraintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ class MatchAllConstraintTest extends TestCase
*/
protected $matchAllConstraint;

protected function setUp()
/**
* @before
* @return void
*/
public function setUpTestCase()
{
$this->versionProvide = new Constraint('==', '1.1');
$this->matchAllConstraint = new MatchAllConstraint();
Expand Down
6 changes: 5 additions & 1 deletion tests/Constraint/MatchNoneConstraintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ class MatchNoneConstraintTest extends TestCase
*/
protected $matchNoneConstraint;

protected function setUp()
/**
* @before
* @return void
*/
public function setUpTestCase()
{
$this->matchNoneConstraint = new MatchNoneConstraint();
}
Expand Down
6 changes: 5 additions & 1 deletion tests/Constraint/MultiConstraintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ class MultiConstraintTest extends TestCase
*/
protected $versionRequireEnd;

protected function setUp()
/**
* @before
* @return void
*/
public function setUpTestCase()
{
$this->versionRequireStart = new Constraint('>', '1.0');
$this->versionRequireEnd = new Constraint('<', '1.2');
Expand Down
Loading