1<?php 2 3namespace Sabre\CalDAV\Xml\Request; 4 5use Sabre\DAV\Xml\XmlTest; 6 7class ShareTest extends XmlTest { 8 9 protected $elementMap = [ 10 '{http://calendarserver.org/ns/}share' => 'Sabre\\CalDAV\\Xml\\Request\\Share', 11 ]; 12 13 function testDeserialize() { 14 15 $xml = <<<XML 16<?xml version="1.0" encoding="utf-8" ?> 17 <CS:share xmlns:D="DAV:" 18 xmlns:CS="http://calendarserver.org/ns/"> 19 <CS:set> 20 <D:href>mailto:eric@example.com</D:href> 21 <CS:common-name>Eric York</CS:common-name> 22 <CS:summary>Shared workspace</CS:summary> 23 <CS:read-write /> 24 </CS:set> 25 <CS:remove> 26 <D:href>mailto:foo@bar</D:href> 27 </CS:remove> 28 </CS:share> 29XML; 30 31 $result = $this->parse($xml); 32 $share = new Share( 33 [ 34 [ 35 'href' => 'mailto:eric@example.com', 36 'commonName' => 'Eric York', 37 'summary' => 'Shared workspace', 38 'readOnly' => false, 39 ] 40 ], 41 [ 42 'mailto:foo@bar', 43 ] 44 ); 45 46 $this->assertEquals( 47 $share, 48 $result['value'] 49 ); 50 51 } 52 53 function testDeserializeMininal() { 54 55 $xml = <<<XML 56<?xml version="1.0" encoding="utf-8" ?> 57 <CS:share xmlns:D="DAV:" 58 xmlns:CS="http://calendarserver.org/ns/"> 59 <CS:set> 60 <D:href>mailto:eric@example.com</D:href> 61 <CS:read /> 62 </CS:set> 63 </CS:share> 64XML; 65 66 $result = $this->parse($xml); 67 $share = new Share( 68 [ 69 [ 70 'href' => 'mailto:eric@example.com', 71 'commonName' => null, 72 'summary' => null, 73 'readOnly' => true, 74 ] 75 ], 76 [] 77 ); 78 79 $this->assertEquals( 80 $share, 81 $result['value'] 82 ); 83 84 } 85 86} 87