ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
LastModifiedTest.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\DAV\Xml\Property;
4 
5 use DateTime;
6 use DateTimeZone;
8 
9 class LastModifiedTest extends XmlTest {
10 
11  function testSerializeDateTime() {
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>
20 XML;
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>
36 XML;
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>
47 XML;
48 
49  $elementMap = ['{DAV:}getlastmodified' => 'Sabre\DAV\Xml\Property\GetLastModified'];
50  $result = $this->parse($input, $elementMap);
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
parse($xml, array $elementMap=[])
Definition: XmlTest.php:26
This property represents the {DAV:}getlastmodified property.