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()); }
/** * @requires extension mongodb */ public function testToMongoDBQuery() { $range = UTCDateTimeRange::fromIncludedToIncluded(UTCDateTime::box('1985-05-21'), UTCDateTime::box('2015-05-21')); $this->assertEquals(['$gte' => new MongoDB\BSON\UTCDateTime(485481600000), '$lte' => new MongoDB\BSON\UTCDateTime(1432166400000)], $range->toMongoDBQuery()); }
public function testItCanBeJsonEncoded() { $iso = '2016-01-01T10:00:42.123456+0000'; $this->assertEquals("\"{$iso}\"", json_encode(UTCDateTime::box($iso))); }