ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
LastModifiedTest.php
Go to the documentation of this file.
1<?php
2
4
5use DateTime;
6use DateTimeZone;
8
9class LastModifiedTest extends XmlTest {
10
12
13 $dt = new DateTime('2015-03-24 11:47:00', new DateTimeZone('America/Vancouver'));
14 $val = ['{DAV:}getlastmodified' => new GetLastModified($dt)];
15
16 $result = $this->write($val);
17 $expected = <<<XML
18<?xml version="1.0"?>
19<d:getlastmodified xmlns:d="DAV:">Tue, 24 Mar 2015 18:47:00 GMT</d:getlastmodified>
20XML;
21
22 $this->assertXmlStringEqualsXmlString($expected, $result);
23
24 }
25
27
28 $dt = new DateTime('2015-03-24 11:47:00', new DateTimeZone('America/Vancouver'));
29 $dt = $dt->getTimeStamp();
30 $val = ['{DAV:}getlastmodified' => new GetLastModified($dt)];
31
32 $result = $this->write($val);
33 $expected = <<<XML
34<?xml version="1.0"?>
35<d:getlastmodified xmlns:d="DAV:">Tue, 24 Mar 2015 18:47:00 GMT</d:getlastmodified>
36XML;
37
38 $this->assertXmlStringEqualsXmlString($expected, $result);
39
40 }
41
42 function testDeserialize() {
43
44 $input = <<<XML
45<?xml version="1.0"?>
46<d:getlastmodified xmlns:d="DAV:">Tue, 24 Mar 2015 18:47:00 GMT</d:getlastmodified>
47XML;
48
49 $elementMap = ['{DAV:}getlastmodified' => 'Sabre\DAV\Xml\Property\GetLastModified'];
51
52 $this->assertEquals(
53 new DateTime('2015-03-24 18:47:00', new DateTimeZone('UTC')),
54 $result['value']->getTime()
55 );
56
57 }
58
59}
$result
getTime()
Definition: MetaLoader.php:492
An exception for terminatinating execution or to throw for unit testing.
This property represents the {DAV:}getlastmodified property.
parse($xml, array $elementMap=[])
Definition: XmlTest.php:26