Created
June 14, 2015 12:17
-
-
Save giorgiosironi/4721aba8f1949cc3c938 to your computer and use it in GitHub Desktop.
Property-based testing fromZeroBasedDayOfYear()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$this->forAll( | |
Generator\int(2000, 2020), | |
Generator\int(0, 364), | |
Generator\int(0, 364) | |
) | |
->then(function($year, $dayOfYear, $anotherDayOfYear) { | |
$day = fromZeroBasedDayOfYear($year, $dayOfYear); | |
$anotherDay = fromZeroBasedDayOfYear($year, $anotherDayOfYear); | |
$this->assertEquals( | |
abs($dayOfYear - $anotherDayOfYear) * 86400, | |
abs($day->getTimestamp() - $anotherDay->getTimestamp()), | |
"Days of the year $year: $dayOfYear, $anotherDayOfYear" . PHP_EOL | |
. "{$day->format(DateTime::ISO8601)}, {$anotherDay->format(DateTime::ISO8601)}" | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment