/** * Returns the prototype of the items type * * A collection has always one property with name item representing the type of all items in the collection. * * @return Prototype */ public static function itemPrototype() { return DateTime::prototype(); }
/** * @test */ public function it_uses_the_toString_method_when_it_is_passed_to_json_encode() { $dateTime1 = DateTime::fromNativeValue(new \DateTime('2014-07-09 20:50:10')); $jsonString = json_encode(array("datetime" => $dateTime1)); $jsonStringCheck = json_encode(array("datetime" => $dateTime1->value()->format(\DateTime::ISO8601))); $this->assertEquals($jsonStringCheck, $jsonString); $decodedJson = json_decode($jsonString, true); $dateTimeDecoded = DateTime::fromJsonDecodedData($decodedJson["datetime"]); $this->assertTrue($dateTime1->sameAs($dateTimeDecoded)); }