AndVersionConstraintGroupTest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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\AndVersionConstraintGroup
  14. */
  15. class AndVersionConstraintGroupTest extends TestCase {
  16. public function testReturnsFalseIfOneConstraintReturnsFalse() {
  17. $firstConstraint = $this->createMock(VersionConstraint::class);
  18. $secondConstraint = $this->createMock(VersionConstraint::class);
  19. $firstConstraint->expects($this->once())
  20. ->method('complies')
  21. ->will($this->returnValue(true));
  22. $secondConstraint->expects($this->once())
  23. ->method('complies')
  24. ->will($this->returnValue(false));
  25. $group = new AndVersionConstraintGroup('foo', [$firstConstraint, $secondConstraint]);
  26. $this->assertFalse($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. $secondConstraint->expects($this->once())
  35. ->method('complies')
  36. ->will($this->returnValue(true));
  37. $group = new AndVersionConstraintGroup('foo', [$firstConstraint, $secondConstraint]);
  38. $this->assertTrue($group->complies(new Version('1.0.0')));
  39. }
  40. }