Exemplo n.º 1
0
 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());
 }
Exemplo n.º 2
0
 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());
 }
Exemplo n.º 3
0
 public function testItCanGiveTheMaximumRange()
 {
     $this->assertEquals(UTCDateTimeRange::fromIncludedToIncluded(UTCDateTime::minimum(), UTCDateTime::maximum()), UTCDateTimeRange::fromMinimumToMaximum());
 }
Exemplo n.º 4
0
 public function diff(UTCDateTime $another)
 {
     return $this->toDateTime()->diff($another->toDateTime());
 }
Exemplo n.º 5
0
 public static function fromMinimumToMaximum()
 {
     return self::fromIncludedToIncluded(UTCDateTime::minimum(), UTCDateTime::maximum());
 }
Exemplo n.º 6
0
 public function current()
 {
     return UTCDateTime::fromMicrotime(microtime());
 }
Exemplo n.º 7
0
 public function testItCanBeJsonEncoded()
 {
     $iso = '2016-01-01T10:00:42.123456+0000';
     $this->assertEquals("\"{$iso}\"", json_encode(UTCDateTime::box($iso)));
 }