3 class Sabre_DAV_Property_GetLastModifiedTest extends PHPUnit_Framework_TestCase {
5 function testConstructDateTime() {
7 $dt = new DateTime('2010-03-14 16:35', new DateTimeZone('UTC'));
8 $lastMod = new Sabre_DAV_Property_GetLastModified($dt);
9 $this->assertEquals($dt->format(DateTime::ATOM), $lastMod->getTime()->format(DateTime::ATOM));
13 function testConstructString() {
15 $dt = new DateTime('2010-03-14 16:35', new DateTimeZone('UTC'));
16 $lastMod = new Sabre_DAV_Property_GetLastModified('2010-03-14 16:35');
17 $this->assertEquals($dt->format(DateTime::ATOM), $lastMod->getTime()->format(DateTime::ATOM));
21 function testConstructInt() {
23 $dt = new DateTime('2010-03-14 16:35', new DateTimeZone('UTC'));
24 $lastMod = new Sabre_DAV_Property_GetLastModified((int)$dt->format('U'));
25 $this->assertEquals($dt->format(DateTime::ATOM), $lastMod->getTime()->format(DateTime::ATOM));
29 function testSerialize() {
31 $dt = new DateTime('2010-03-14 16:35', new DateTimeZone('UTC'));
32 $lastMod = new Sabre_DAV_Property_GetLastModified($dt);
34 $doc = new DOMDocument();
35 $root = $doc->createElement('d:getlastmodified');
36 $root->setAttribute('xmlns:d','DAV:');
38 $doc->appendChild($root);
39 $objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleCollection('rootdir'));
40 $server = new Sabre_DAV_Server($objectTree);
42 $lastMod->serialize($server, $root);
44 $xml = $doc->saveXML();
47 '<?xml version="1.0"?>
48 <d:getlastmodified xmlns:d="DAV:" xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" b:dt="dateTime.rfc1123">' .
49 Sabre_HTTP_Util::toHTTPDate($dt) .
55 Sabre_DAV_Property_GetLastModified::unserialize(Sabre_DAV_XMLUtil::loadDOMDocument($xml)->firstChild);
56 } catch (Sabre_DAV_Exception $e) {
59 if (!$ok) $this->markTestFailed('Unserialize should not be supported');