/** * is $a in between $b and $c, such that $b < $a < $c is true? * * @param VersionNumber $a the version number to test * @param VersionNumber $b the minimum boundary * @param VersionNumber $c the maximum boundary * @return boolean * TRUE if $b < $a < $c * FALSE otherwise */ public static function calculate(VersionNumber $a, VersionNumber $b, VersionNumber $c) { // we turn this into two tests: // // $a has to be >= $b, and // $a has to be < $c $res = GreaterThanOrEqualTo::calculate($a, $b); if (!$res) { return false; } // is $c within our upper boundary? $res = LessThan::calculate($a, $c); if (!$res) { return false; } // finally, a special case // avoid installing an unstable version of the upper boundary return !PreReleaseOf::calculate($a, $c); }
/** * @dataProvider provideIsLessThanDataset * @covers ::calculate */ public function testCanCallStatically($a, $b, $expectedResult) { // ---------------------------------------------------------------- // setup your test $aVer = ParseSemanticVersion::from($a); $bVer = ParseSemanticVersion::from($b); // ---------------------------------------------------------------- // perform the change $actualResult = LessThan::calculate($aVer, $bVer); // ---------------------------------------------------------------- // test the results $this->assertEquals($expectedResult, $actualResult); }