SpecificMajorVersionConstraintTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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\SpecificMajorVersionConstraint
  14. */
  15. class SpecificMajorVersionConstraintTest extends TestCase {
  16. public function versionProvider() {
  17. return [
  18. // compliant versions
  19. [1, new Version('1.0.2'), true],
  20. [1, new Version('1.0.3'), true],
  21. [1, new Version('1.1.1'), true],
  22. // non-compliant versions
  23. [2, new Version('0.9.9'), false],
  24. [3, new Version('2.2.3'), false],
  25. [3, new Version('2.9.9'), false],
  26. ];
  27. }
  28. /**
  29. * @dataProvider versionProvider
  30. *
  31. * @param int $major
  32. * @param Version $version
  33. * @param bool $expectedResult
  34. */
  35. public function testReturnsTrueForCompliantVersions($major, Version $version, $expectedResult) {
  36. $constraint = new SpecificMajorVersionConstraint('foo', $major);
  37. $this->assertSame($expectedResult, $constraint->complies($version));
  38. }
  39. }