/**
  * @covers ::__construct
  */
 public function testCanInstantiate()
 {
     // ----------------------------------------------------------------
     // setup your test
     $operator = new EqualTo();
     $version = ParseSemanticVersion::from("1.0.0");
     $expression = new ComparisonExpression($operator, $version);
     // ----------------------------------------------------------------
     // perform the change
     $obj = new VersionRange([$expression]);
     // ----------------------------------------------------------------
     // test the results
     $this->assertTrue($obj instanceof VersionRange);
 }
 public function provideVersionsToCompare()
 {
     $retval = [];
     foreach (SemanticVersionDatasets::getAlwaysLessThanDataset() as $data) {
         $retval[] = [ParseSemanticVersion::from($data[0]), ParseSemanticVersion::from($data[1]), CompareTwoNumbers::A_IS_LESS];
     }
     foreach (SemanticVersionDatasets::getAlwaysGreaterThanDataset() as $data) {
         $retval[] = [ParseSemanticVersion::from($data[0]), ParseSemanticVersion::from($data[1]), CompareTwoNumbers::A_IS_GREATER];
     }
     foreach (SemanticVersionDatasets::getAlwaysEqualDataset() as $data) {
         $retval[] = [ParseSemanticVersion::from($data[0]), ParseSemanticVersion::from($data[1]), CompareTwoNumbers::BOTH_ARE_EQUAL];
     }
     return $retval;
 }
 /**
  * @dataProvider provideEqualityDataset
  *
  * @covers ::calculate
  */
 public function testCanCallStatically($a, $b, $expectedResult)
 {
     // ----------------------------------------------------------------
     // setup your test
     $aVer = ParseSemanticVersion::from($a);
     $bVer = ParseSemanticVersion::from($b);
     // ----------------------------------------------------------------
     // perform the change
     $actualResult = EqualTo::calculate($aVer, $bVer);
     // ----------------------------------------------------------------
     // test the results
     $this->assertEquals($expectedResult, $actualResult);
 }
 public function provideStrings()
 {
     return [[ParseSemanticVersion::from("1.0"), ParseSemanticVersion::from("1.0.1"), true], [ParseSemanticVersion::from("1.0.1"), ParseSemanticVersion::from("1.0"), true], [new FakeVersionNumber(), ParseSemanticVersion::from("1.0"), false], [ParseSemanticVersion::from("1.0"), new FakeVersionNumber(), false]];
 }
 /**
  * @covers ::calculate
  * @covers ::compareXyz
  * @covers ::getVersionPart
  * @covers ::comparePreRelease
  * @dataProvider provideVersionsToCompare
  */
 public function testCanCallStatically($versionA, $versionB, $expectedResult)
 {
     // ----------------------------------------------------------------
     // setup your test
     $verA = ParseSemanticVersion::from($versionA);
     $verB = ParseSemanticVersion::from($versionB);
     // ----------------------------------------------------------------
     // perform the change
     $actualResult = CompareSemanticVersions::calculate($verA, $verB);
     // ----------------------------------------------------------------
     // test the results
     $this->assertEquals($expectedResult, $actualResult);
 }
 public function provideVersionsToTest()
 {
     return [[ParseSemanticVersion::from("1.0"), CompareSemanticVersions::class], [new HashedVersion("abcdef"), CompareHashedVersions::class]];
 }
 public function provideStrings()
 {
     return [["1.0", ParseSemanticVersion::from("1.0")]];
 }
 /**
  * @covers ::getVersionNumber
  */
 public function testCanGetVersionNumberFromExpression()
 {
     // ----------------------------------------------------------------
     // setup your test
     $operator = new EqualTo();
     $version = ParseSemanticVersion::from("1.0.0");
     $obj = new ComparisonExpression($operator, $version);
     // ----------------------------------------------------------------
     // perform the change
     $actualResult = $obj->getVersionNumber();
     // ----------------------------------------------------------------
     // test the results
     $this->assertSame($version, $actualResult);
 }
 /**
  * @dataProvider provideBadVersionNumbers
  *
  * @covers ::from
  *
  * @expectedException GanbaroDigital\Versions\Exceptions\E4xx_BadVersionString
  */
 public function testRejectsUnparseableVersionStrings($versionString)
 {
     // ----------------------------------------------------------------
     // setup your test
     // ----------------------------------------------------------------
     // perform the change
     ParseSemanticVersion::from($versionString);
 }
 /**
  * @covers ::toArray()
  */
 public function testCanTurnIntoArray()
 {
     // ----------------------------------------------------------------
     // setup your test
     $expectedVersion = ["major" => 1, "minor" => 2, "patchLevel" => 3, "preRelease" => "alpha", "build" => 4];
     $obj = ParseSemanticVersion::from('1.2.3-alpha+4');
     // ----------------------------------------------------------------
     // perform the change
     $actualVersion = $obj->toArray();
     // ----------------------------------------------------------------
     // test the results
     $this->assertEquals($expectedVersion, $actualVersion);
 }
 /**
  * @covers ::__construct
  */
 public function testIsRuntimeException()
 {
     // ----------------------------------------------------------------
     // setup your test
     $lhs = ParseSemanticVersion::from("1.0.0");
     $rhs = new stdClass();
     // ----------------------------------------------------------------
     // perform the change
     $obj = new E4xx_IncompatibleVersionNumbers($lhs, $rhs);
     // ----------------------------------------------------------------
     // test the results
     $this->assertTrue($obj instanceof RuntimeException);
 }
 public function provideValidVersionsForDispatch()
 {
     return [["1.0", ParseSemanticVersion::from("1.0")], [ParseSemanticVersion::from("2.0"), ParseSemanticVersion::from("2.0")]];
 }
 /**
  * return a VersionNumber that represents our upper boundary according
  * to the rules of the ^ operator
  *
  * the return value needs to be used with the < operator, and you will
  * need to do manual filtering out of pre-release versions of the
  * return value
  *
  * @return VersionNumber
  */
 public function getCompatibleUpperBoundary()
 {
     // ^X.Y.Z has an upper boundary of X+1.0
     // ^X.Y has an upper boundary of X+1.0
     $upperBound = $this->getMajor() + 1 . '.0';
     // our return value
     $retval = ParseSemanticVersion::from($upperBound);
     // all done
     return $retval;
 }