Няма описание

OrVersionConstraintGroupTest.php 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. }