assertEquals($dt->format(DateTime::ATOM), $lastMod->getTime()->format(DateTime::ATOM)); } function testConstructString() { $dt = new DateTime('2010-03-14 16:35', new DateTimeZone('UTC')); $lastMod = new Sabre_DAV_Property_GetLastModified('2010-03-14 16:35'); $this->assertEquals($dt->format(DateTime::ATOM), $lastMod->getTime()->format(DateTime::ATOM)); } function testConstructInt() { $dt = new DateTime('2010-03-14 16:35', new DateTimeZone('UTC')); $lastMod = new Sabre_DAV_Property_GetLastModified((int)$dt->format('U')); $this->assertEquals($dt->format(DateTime::ATOM), $lastMod->getTime()->format(DateTime::ATOM)); } function testSerialize() { $dt = new DateTime('2010-03-14 16:35', new DateTimeZone('UTC')); $lastMod = new Sabre_DAV_Property_GetLastModified($dt); $doc = new DOMDocument(); $root = $doc->createElement('d:getlastmodified'); $root->setAttribute('xmlns:d','DAV:'); $doc->appendChild($root); $objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleCollection('rootdir')); $server = new Sabre_DAV_Server($objectTree); $lastMod->serialize($server, $root); $xml = $doc->saveXML(); $this->assertEquals( ' ' . Sabre_HTTP_Util::toHTTPDate($dt) . ' ', $xml); $ok = false; try { Sabre_DAV_Property_GetLastModified::unserialize(Sabre_DAV_XMLUtil::loadDOMDocument($xml)->firstChild); } catch (Sabre_DAV_Exception $e) { $ok = true; } if (!$ok) $this->markTestFailed('Unserialize should not be supported'); } }