]> git.mxchange.org Git - friendica-addons.git/blob - dav/SabreDAV/tests/Sabre/CalDAV/Property/SupportedCalendarComponentSetTest.php
52e127c2215b27ff1fcd7491022d9caa06520e90
[friendica-addons.git] / dav / SabreDAV / tests / Sabre / CalDAV / Property / SupportedCalendarComponentSetTest.php
1 <?php
2
3 class Sabre_CalDAV_Property_SupportedCalendarComponentSetTest extends PHPUnit_Framework_TestCase {
4
5     function testSimple() {
6
7         $sccs = new Sabre_CalDAV_Property_SupportedCalendarComponentSet(array('VEVENT'));
8         $this->assertEquals(array('VEVENT'), $sccs->getValue());
9
10     }
11
12     /**
13      * @depends testSimple
14      */
15     function testSerialize() {
16
17         $property = new Sabre_CalDAV_Property_SupportedCalendarComponentSet(array('VEVENT','VJOURNAL'));
18
19         $doc = new DOMDocument();
20         $root = $doc->createElement('d:root');
21         $root->setAttribute('xmlns:d','DAV:');
22         $root->setAttribute('xmlns:cal',Sabre_CalDAV_Plugin::NS_CALDAV);
23
24         $doc->appendChild($root);
25         $objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleCollection('rootdir'));
26         $server = new Sabre_DAV_Server($objectTree);
27
28         $property->serialize($server, $root);
29
30         $xml = $doc->saveXML();
31
32         $this->assertEquals(
33 '<?xml version="1.0"?>
34 <d:root xmlns:d="DAV:" xmlns:cal="' . Sabre_CalDAV_Plugin::NS_CALDAV . '">' .
35 '<cal:comp name="VEVENT"/>' .
36 '<cal:comp name="VJOURNAL"/>' .
37 '</d:root>
38 ', $xml);
39
40     }
41
42     /**
43      * @depends testSimple
44      */
45     function testUnserializer() {
46
47         $xml = '<?xml version="1.0"?>
48 <d:root xmlns:d="DAV:" xmlns:cal="' . Sabre_CalDAV_Plugin::NS_CALDAV . '">' .
49 '<cal:comp name="VEVENT"/>' .
50 '<cal:comp name="VJOURNAL"/>' .
51 '</d:root>';
52
53         $dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml);
54
55         $property = Sabre_CalDAV_Property_SupportedCalendarComponentSet::unserialize($dom->firstChild);
56
57         $this->assertTrue($property instanceof Sabre_CalDAV_Property_SupportedCalendarComponentSet);
58         $this->assertEquals(array(
59             'VEVENT',
60             'VJOURNAL',
61            ),
62            $property->getValue());
63
64     }
65
66 }