Page MenuHomePhabricator

LastModifiedTest.php
No OneTemporary

LastModifiedTest.php

<?php
namespace Sabre\DAV\Xml\Property;
use Sabre\DAV\Xml\XmlTest;
use DateTime;
use DateTimeZone;
class LastModifiedTest extends XmlTest {
function testSerializeDateTime() {
$dt = new DateTime('2015-03-24 11:47:00', new DateTimeZone('America/Vancouver'));
$val = ['{DAV:}getlastmodified' => new GetLastModified($dt)];
$result = $this->write($val);
$expected = <<<XML
<?xml version="1.0"?>
<d:getlastmodified xmlns:d="DAV:">Tue, 24 Mar 2015 18:47:00 GMT</d:getlastmodified>
XML;
$this->assertXmlStringEqualsXmlString($expected, $result);
}
function testSerializeTimeStamp() {
$dt = new DateTime('2015-03-24 11:47:00', new DateTimeZone('America/Vancouver'));
$dt = $dt->getTimeStamp();
$val = ['{DAV:}getlastmodified' => new GetLastModified($dt)];
$result = $this->write($val);
$expected = <<<XML
<?xml version="1.0"?>
<d:getlastmodified xmlns:d="DAV:">Tue, 24 Mar 2015 18:47:00 GMT</d:getlastmodified>
XML;
$this->assertXmlStringEqualsXmlString($expected, $result);
}
function testDeserialize() {
$input = <<<XML
<?xml version="1.0"?>
<d:getlastmodified xmlns:d="DAV:">Tue, 24 Mar 2015 18:47:00 GMT</d:getlastmodified>
XML;
$elementMap = ['{DAV:}getlastmodified' => 'Sabre\DAV\Xml\Property\GetLastModified'];
$result = $this->parse($input, $elementMap);
$this->assertEquals(
new DateTime('2015-03-24 18:47:00', new DateTimeZone('UTC')),
$result['value']->getTime()
);
}
}

File Metadata

Mime Type
text/x-php
Expires
Dec 20 2024, 5:44 AM (4 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
914438
Default Alt Text
LastModifiedTest.php (1 KB)

Event Timeline