ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ShareAccessTest.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\DAV\Xml\Property;
4 
7 
8 class ShareAccessTest extends XmlTest {
9 
10  function testSerialize() {
11 
12  $data = ['{DAV:}root' => [
13  [
14  'name' => '{DAV:}share-access',
15  'value' => new ShareAccess(Plugin::ACCESS_READ),
16  ],
17  [
18  'name' => '{DAV:}share-access',
19  'value' => new ShareAccess(Plugin::ACCESS_READWRITE),
20  ],
21  [
22  'name' => '{DAV:}share-access',
23  'value' => new ShareAccess(Plugin::ACCESS_NOTSHARED),
24  ],
25  [
26  'name' => '{DAV:}share-access',
27  'value' => new ShareAccess(Plugin::ACCESS_NOACCESS),
28  ],
29  [
30  'name' => '{DAV:}share-access',
32  ],
33 
34  ]];
35 
36  $xml = $this->write($data);
37 
38  $expected = <<<XML
39 <?xml version="1.0"?>
40 <d:root xmlns:d="DAV:">
41  <d:share-access><d:read /></d:share-access>
42  <d:share-access><d:read-write /></d:share-access>
43  <d:share-access><d:not-shared /></d:share-access>
44  <d:share-access><d:no-access /></d:share-access>
45  <d:share-access><d:shared-owner /></d:share-access>
46 </d:root>
47 XML;
48 
49  $this->assertXmlStringEqualsXmlString($expected, $xml);
50 
51  }
52 
53  function testDeserialize() {
54 
55  $input = <<<XML
56 <?xml version="1.0"?>
57 <d:root xmlns:d="DAV:">
58  <d:share-access><d:read /></d:share-access>
59  <d:share-access><d:read-write /></d:share-access>
60  <d:share-access><d:not-shared /></d:share-access>
61  <d:share-access><d:no-access /></d:share-access>
62  <d:share-access><d:shared-owner /></d:share-access>
63 </d:root>
64 XML;
65 
66  $data = [
67  [
68  'name' => '{DAV:}share-access',
69  'value' => new ShareAccess(Plugin::ACCESS_READ),
70  'attributes' => [],
71  ],
72  [
73  'name' => '{DAV:}share-access',
74  'value' => new ShareAccess(Plugin::ACCESS_READWRITE),
75  'attributes' => [],
76  ],
77  [
78  'name' => '{DAV:}share-access',
79  'value' => new ShareAccess(Plugin::ACCESS_NOTSHARED),
80  'attributes' => [],
81  ],
82  [
83  'name' => '{DAV:}share-access',
84  'value' => new ShareAccess(Plugin::ACCESS_NOACCESS),
85  'attributes' => [],
86  ],
87  [
88  'name' => '{DAV:}share-access',
90  'attributes' => [],
91  ],
92 
93  ];
94 
95  $this->assertParsedValue(
96  $data,
97  $input,
98  ['{DAV:}share-access' => ShareAccess::class]
99  );
100 
101  }
102 
107 
108  $input = <<<XML
109 <?xml version="1.0"?>
110 <d:root xmlns:d="DAV:">
111  <d:share-access><d:foo /></d:share-access>
112 </d:root>
113 XML;
114 
115  $this->parse(
116  $input,
117  ['{DAV:}share-access' => ShareAccess::class]
118  );
119 
120  }
121 }
assertParsedValue($expected, $xml, array $elementMap=[])
Definition: XmlTest.php:35
parse($xml, array $elementMap=[])
Definition: XmlTest.php:26
This class represents the {DAV:}share-access property.
Definition: ShareAccess.php:25
$data
Definition: bench.php:6