public function testGivesATimeAFewSecondsInThePast() { $original = $this->getMock('Onebip\\UTCClock'); $clock = new DelayedUTCClock($original, 10); $original->expects($this->once())->method('current')->will($this->returnValue(UTCDateTime::fromTimestamp(10000018))); $this->assertEquals(UTCDateTime::fromTimestamp(10000008), $clock->current()); }
public function testStubbedTimeCanBeReset() { $time = UTCDateTime::box('2015-02-01 10:00'); $this->innerClock->expects($this->any())->method('current')->will($this->returnValue($time)); $this->clock->setCurrent(UTCDateTime::box('1985-05-21 08:40')); $this->clock->reset(); $this->assertEquals($time, $this->clock->current()); }
public function testItCanGiveTheMaximumRange() { $this->assertEquals(UTCDateTimeRange::fromIncludedToIncluded(UTCDateTime::minimum(), UTCDateTime::maximum()), UTCDateTimeRange::fromMinimumToMaximum()); }
public function diff(UTCDateTime $another) { return $this->toDateTime()->diff($another->toDateTime()); }
public static function fromMinimumToMaximum() { return self::fromIncludedToIncluded(UTCDateTime::minimum(), UTCDateTime::maximum()); }
public function current() { return UTCDateTime::fromMicrotime(microtime()); }
public function testItCanBeJsonEncoded() { $iso = '2016-01-01T10:00:42.123456+0000'; $this->assertEquals("\"{$iso}\"", json_encode(UTCDateTime::box($iso))); }