@@ -377,33 +377,29 @@ public function testVersionMatchFails($requireOperator, $requireVersion, $provid
377
377
public function testInverseMatchingOtherConstraints ()
378
378
{
379
379
$ constraint = new Constraint ('> ' , '1.0.0 ' );
380
+ $ otherConstraintClasses = array (
381
+ 'Composer\Semver\Constraint\MultiConstraint ' ,
382
+ 'Composer\Semver\Constraint\MatchAllConstraint '
383
+ );
380
384
381
- $ multiConstraint = $ this
382
- ->getMockBuilder ('Composer\Semver\Constraint\MultiConstraint ' )
383
- ->disableOriginalConstructor ()
384
- ->setMethods (array ('matches ' ))
385
- ->getMock ()
386
- ;
387
-
388
- $ matchAllConstraint = $ this
389
- ->getMockBuilder ('Composer\Semver\Constraint\MatchAllConstraint ' )
390
- ->setMethods (array ('matches ' ))
391
- ->getMock ()
392
- ;
393
-
394
- foreach (array ($ multiConstraint , $ matchAllConstraint ) as $ mock ) {
395
- $ mock
385
+ foreach ($ otherConstraintClasses as $ otherConstraintClass ) {
386
+ $ otherConstraintMockBuilder = $ this ->getMockBuilder ($ otherConstraintClass );
387
+ $ otherConstraintMockBuilder ->disableOriginalConstructor ();
388
+ if (method_exists ($ otherConstraintMockBuilder , 'onlyMethods ' )) {
389
+ $ otherConstraintMockBuilder ->onlyMethods (array ('matches ' ));
390
+ } elseif (method_exists ($ otherConstraintMockBuilder , 'setMethods ' )) {
391
+ $ otherConstraintMockBuilder ->setMethods (array ('matches ' ));
392
+ }
393
+ $ otherConstraintMock = $ otherConstraintMockBuilder ->getMock ();
394
+ $ otherConstraintMock
396
395
->expects ($ this ->once ())
397
396
->method ('matches ' )
398
397
->with ($ constraint )
399
398
->willReturn (true )
400
399
;
400
+ // @phpstan-ignore-next-line
401
+ $ this ->assertTrue ($ constraint ->matches ($ otherConstraintMock ));
401
402
}
402
-
403
- // @phpstan-ignore-next-line
404
- $ this ->assertTrue ($ constraint ->matches ($ multiConstraint ));
405
- // @phpstan-ignore-next-line
406
- $ this ->assertTrue ($ constraint ->matches ($ matchAllConstraint ));
407
403
}
408
404
409
405
public function testComparableBranches ()
0 commit comments