OrVersionConstraintGroupTest.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /*
  3. * This file is part of PharIo\Version.
  4. *
  5. * (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace PharIo\Version;
  11. use PHPUnit\Framework\TestCase;
  12. /**
  13. * @covers \PharIo\Version\OrVersionConstraintGroup
  14. */
  15. class OrVersionConstraintGroupTest extends TestCase {
  16. public function testReturnsTrueIfOneConstraintReturnsFalse() {
  17. $firstConstraint = $this->createMock(VersionConstraint::class);
  18. $secondConstraint = $this->createMock(VersionConstraint::class);
  19. $firstConstraint->expects($this->once())
  20. ->method('complies')
  21. ->will($this->returnValue(false));
  22. $secondConstraint->expects($this->once())
  23. ->method('complies')
  24. ->will($this->returnValue(true));
  25. $group = new OrVersionConstraintGroup('foo', [$firstConstraint, $secondConstraint]);
  26. $this->assertTrue($group->complies(new Version('1.0.0')));
  27. }
  28. public function testReturnsTrueIfAllConstraintsReturnsTrue() {
  29. $firstConstraint = $this->createMock(VersionConstraint::class);
  30. $secondConstraint = $this->createMock(VersionConstraint::class);
  31. $firstConstraint->expects($this->once())
  32. ->method('complies')
  33. ->will($this->returnValue(true));
  34. $group = new OrVersionConstraintGroup('foo', [$firstConstraint, $secondConstraint]);
  35. $this->assertTrue($group->complies(new Version('1.0.0')));
  36. }
  37. public function testReturnsFalseIfAllConstraintsReturnsFalse() {
  38. $firstConstraint = $this->createMock(VersionConstraint::class);
  39. $secondConstraint = $this->createMock(VersionConstraint::class);
  40. $firstConstraint->expects($this->once())
  41. ->method('complies')
  42. ->will($this->returnValue(false));
  43. $secondConstraint->expects($this->once())
  44. ->method('complies')
  45. ->will($this->returnValue(false));
  46. $group = new OrVersionConstraintGroup('foo', [$firstConstraint, $secondConstraint]);
  47. $this->assertFalse($group->complies(new Version('1.0.0')));
  48. }
  49. }