コード例 #1
0
ファイル: DateTest.php プロジェクト: giorgiosironi/eris
 public function testDefaultValuesForTheInterval()
 {
     $this->forAll(Generator\date())->then(function (DateTime $date) {
         $this->assertGreaterThanOrEqual("1970", $date->format('Y'));
         $this->assertLessThanOrEqual("2038", $date->format('Y'));
     });
 }
コード例 #2
0
 public function testDoesNotPerformTheCheckTooManyTimes()
 {
     $this->forAll(Generator\date(), Generator\choose(10, 30), Generator\seq(Generator\choose(1, 60)))->then(function ($startingDate, $period, $deltas) {
         $clock = new SettableClock($startingDate);
         $check = PeriodicalCheck::every($period, $clock);
         $this->counter = 0;
         $check->onFire(function () {
             $this->counter++;
         });
         $check->__invoke();
         foreach ($deltas as $delta) {
             $clock->advance($delta);
             $check->__invoke();
         }
         $totalInterval = array_sum($deltas);
         $maximumNumberOfCalls = ceil($totalInterval / $period);
         $actualNumberOfCallsExcludingTheFirst = $this->counter - 1;
         $this->assertLessThanOrEqual($maximumNumberOfCalls, $actualNumberOfCallsExcludingTheFirst);
     });
 }
コード例 #3
0
 public function testStartOfMonthWillGiveTheFirstDay()
 {
     $this->forAll(Generator\date(new DateTime('1980-01-01'), new DateTime('2020-12-31')))->then(function (DateTime $date) {
         $date->setTimeZone(new DateTimeZone('UTC'));
         $prefix = $date->format('Y-m');
         $this->assertEquals($prefix . '-01T00:00:00.000+0000', UTCDateTime::box($date)->startOfMonth()->toIso8601WithMilliseconds());
     });
 }