暂无描述

ExactVersionConstraintTest.php 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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\ExactVersionConstraint
  14. */
  15. class ExactVersionConstraintTest extends TestCase {
  16. public function compliantVersionProvider() {
  17. return [
  18. ['1.0.2', new Version('1.0.2')],
  19. ['4.8.9', new Version('4.8.9')],
  20. ['4.8', new Version('4.8')],
  21. ];
  22. }
  23. public function nonCompliantVersionProvider() {
  24. return [
  25. ['1.0.2', new Version('1.0.3')],
  26. ['4.8.9', new Version('4.7.9')],
  27. ['4.8', new Version('4.8.5')],
  28. ];
  29. }
  30. /**
  31. * @dataProvider compliantVersionProvider
  32. *
  33. * @param string $constraintValue
  34. * @param Version $version
  35. */
  36. public function testReturnsTrueForCompliantVersion($constraintValue, Version $version) {
  37. $constraint = new ExactVersionConstraint($constraintValue);
  38. $this->assertTrue($constraint->complies($version));
  39. }
  40. /**
  41. * @dataProvider nonCompliantVersionProvider
  42. *
  43. * @param string $constraintValue
  44. * @param Version $version
  45. */
  46. public function testReturnsFalseForNonCompliantVersion($constraintValue, Version $version) {
  47. $constraint = new ExactVersionConstraint($constraintValue);
  48. $this->assertFalse($constraint->complies($version));
  49. }
  50. }