ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
SharedCalendarTest.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\CalDAV;
4 
7 
9 
10  protected $backend;
11 
12  function getInstance(array $props = null) {
13 
14  if (is_null($props)) {
15  $props = [
16  'id' => 1,
17  '{http://calendarserver.org/ns/}shared-url' => 'calendars/owner/original',
18  '{http://sabredav.org/ns}owner-principal' => 'principals/owner',
19  '{http://sabredav.org/ns}read-only' => false,
20  'share-access' => Sharing\Plugin::ACCESS_READWRITE,
21  'principaluri' => 'principals/sharee',
22  ];
23  }
24 
25  $this->backend = new Backend\MockSharing(
26  [$props],
27  [],
28  []
29  );
30 
31  $sharee = new Sharee();
32  $sharee->href = 'mailto:removeme@example.org';
33  $sharee->properties['{DAV:}displayname'] = 'To be removed';
34  $sharee->access = Sharing\Plugin::ACCESS_READ;
35  $this->backend->updateInvites(1, [$sharee]);
36 
37  return new SharedCalendar($this->backend, $props);
38 
39  }
40 
41  function testGetInvites() {
42 
43  $sharee = new Sharee();
44  $sharee->href = 'mailto:removeme@example.org';
45  $sharee->properties['{DAV:}displayname'] = 'To be removed';
46  $sharee->access = Sharing\Plugin::ACCESS_READ;
47  $sharee->inviteStatus = Sharing\Plugin::INVITE_NORESPONSE;
48 
49  $this->assertEquals(
50  [$sharee],
51  $this->getInstance()->getInvites()
52  );
53 
54  }
55 
56  function testGetOwner() {
57  $this->assertEquals('principals/sharee', $this->getInstance()->getOwner());
58  }
59 
60  function testGetACL() {
61 
62  $expected = [
63  [
64  'privilege' => '{DAV:}write',
65  'principal' => 'principals/sharee',
66  'protected' => true,
67  ],
68  [
69  'privilege' => '{DAV:}write',
70  'principal' => 'principals/sharee/calendar-proxy-write',
71  'protected' => true,
72  ],
73  [
74  'privilege' => '{DAV:}write-properties',
75  'principal' => 'principals/sharee',
76  'protected' => true,
77  ],
78  [
79  'privilege' => '{DAV:}write-properties',
80  'principal' => 'principals/sharee/calendar-proxy-write',
81  'protected' => true,
82  ],
83  [
84  'privilege' => '{DAV:}read',
85  'principal' => 'principals/sharee',
86  'protected' => true,
87  ],
88  [
89  'privilege' => '{DAV:}read',
90  'principal' => 'principals/sharee/calendar-proxy-read',
91  'protected' => true,
92  ],
93  [
94  'privilege' => '{DAV:}read',
95  'principal' => 'principals/sharee/calendar-proxy-write',
96  'protected' => true,
97  ],
98  [
99  'privilege' => '{' . Plugin::NS_CALDAV . '}read-free-busy',
100  'principal' => '{DAV:}authenticated',
101  'protected' => true,
102  ],
103  ];
104 
105  $this->assertEquals($expected, $this->getInstance()->getACL());
106 
107  }
108 
109  function testGetChildACL() {
110 
111  $expected = [
112  [
113  'privilege' => '{DAV:}write',
114  'principal' => 'principals/sharee',
115  'protected' => true,
116  ],
117  [
118  'privilege' => '{DAV:}write',
119  'principal' => 'principals/sharee/calendar-proxy-write',
120  'protected' => true,
121  ],
122  [
123  'privilege' => '{DAV:}read',
124  'principal' => 'principals/sharee',
125  'protected' => true,
126  ],
127  [
128  'privilege' => '{DAV:}read',
129  'principal' => 'principals/sharee/calendar-proxy-write',
130  'protected' => true,
131  ],
132  [
133  'privilege' => '{DAV:}read',
134  'principal' => 'principals/sharee/calendar-proxy-read',
135  'protected' => true,
136  ],
137 
138  ];
139 
140  $this->assertEquals($expected, $this->getInstance()->getChildACL());
141 
142  }
143 
144  function testUpdateInvites() {
145 
146  $instance = $this->getInstance();
147  $newSharees = [
148  new Sharee(),
149  new Sharee()
150  ];
151  $newSharees[0]->href = 'mailto:test@example.org';
152  $newSharees[0]->properties['{DAV:}displayname'] = 'Foo Bar';
153  $newSharees[0]->comment = 'Booh';
154  $newSharees[0]->access = Sharing\Plugin::ACCESS_READWRITE;
155 
156  $newSharees[1]->href = 'mailto:removeme@example.org';
157  $newSharees[1]->access = Sharing\Plugin::ACCESS_NOACCESS;
158 
159  $instance->updateInvites($newSharees);
160 
161  $expected = [
162  clone $newSharees[0]
163  ];
164  $expected[0]->inviteStatus = Sharing\Plugin::INVITE_NORESPONSE;
165  $this->assertEquals($expected, $instance->getInvites());
166 
167  }
168 
169  function testPublish() {
170 
171  $instance = $this->getInstance();
172  $this->assertNull($instance->setPublishStatus(true));
173  $this->assertNull($instance->setPublishStatus(false));
174 
175  }
176 }
This class represents the {DAV:}sharee element.
Definition: Sharee.php:21
This object represents a CalDAV calendar that is shared by a different user.
const NS_CALDAV
This is the official CalDAV namespace.
Definition: Plugin.php:33