ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\CalDAV\CalendarObjectTest Class Reference
+ Inheritance diagram for Sabre\CalDAV\CalendarObjectTest:
+ Collaboration diagram for Sabre\CalDAV\CalendarObjectTest:

Public Member Functions

 setup ()
 
 teardown ()
 
 testSetup ()
 
 testInvalidArg1 ()
 InvalidArgumentException More...
 
 testInvalidArg2 ()
 InvalidArgumentException More...
 
 testPut ()
 testSetup More...
 
 testPutStream ()
 testSetup More...
 
 testDelete ()
 testSetup More...
 
 testGetLastModified ()
 testSetup More...
 
 testGetSize ()
 testSetup More...
 
 testGetOwner ()
 
 testGetGroup ()
 
 testGetACL ()
 
 testDefaultACL ()
 
 testSetACL ()
 
 testGet ()
 
 testGetRefetch ()
 
 testGetEtag1 ()
 
 testGetEtag2 ()
 
 testGetSupportedPrivilegesSet ()
 
 testGetSize1 ()
 
 testGetSize2 ()
 

Protected Attributes

 $backend
 
 $calendar
 
 $principalBackend
 

Detailed Description

Definition at line 7 of file CalendarObjectTest.php.

Member Function Documentation

◆ setup()

Sabre\CalDAV\CalendarObjectTest::setup ( )

Definition at line 19 of file CalendarObjectTest.php.

References Sabre\CalDAV\TestUtil\getBackend().

19  {
20 
21  $this->backend = TestUtil::getBackend();
22 
23  $calendars = $this->backend->getCalendarsForUser('principals/user1');
24  $this->assertEquals(2, count($calendars));
25  $this->calendar = new Calendar($this->backend, $calendars[0]);
26 
27  }
static getBackend()
Definition: TestUtil.php:7
+ Here is the call graph for this function:

◆ teardown()

Sabre\CalDAV\CalendarObjectTest::teardown ( )

Definition at line 29 of file CalendarObjectTest.php.

29  {
30 
31  unset($this->calendar);
32  unset($this->backend);
33 
34  }

◆ testDefaultACL()

Sabre\CalDAV\CalendarObjectTest::testDefaultACL ( )

Definition at line 210 of file CalendarObjectTest.php.

References Sabre\CalDAV\CalendarObjectTest\$backend.

210  {
211 
212  $backend = new Backend\Mock([], []);
213  $calendarObject = new CalendarObject($backend, ['principaluri' => 'principals/user1'], ['calendarid' => 1, 'uri' => 'foo']);
214  $expected = [
215  [
216  'privilege' => '{DAV:}all',
217  'principal' => 'principals/user1',
218  'protected' => true,
219  ],
220  [
221  'privilege' => '{DAV:}all',
222  'principal' => 'principals/user1/calendar-proxy-write',
223  'protected' => true,
224  ],
225  [
226  'privilege' => '{DAV:}read',
227  'principal' => 'principals/user1/calendar-proxy-read',
228  'protected' => true,
229  ],
230  ];
231  $this->assertEquals($expected, $calendarObject->getACL());
232 
233 
234  }

◆ testDelete()

Sabre\CalDAV\CalendarObjectTest::testDelete ( )

testSetup

Definition at line 109 of file CalendarObjectTest.php.

109  {
110 
111  $children = $this->calendar->getChildren();
112  $this->assertTrue($children[0] instanceof CalendarObject);
113 
114  $obj = $children[0];
115  $obj->delete();
116 
117  $children2 = $this->calendar->getChildren();
118  $this->assertEquals(count($children) - 1, count($children2));
119 
120  }

◆ testGet()

Sabre\CalDAV\CalendarObjectTest::testGet ( )

Definition at line 249 of file CalendarObjectTest.php.

249  {
250 
251  $children = $this->calendar->getChildren();
252  $this->assertTrue($children[0] instanceof CalendarObject);
253 
254  $obj = $children[0];
255 
256  $expected = "BEGIN:VCALENDAR
257 VERSION:2.0
258 PRODID:-//Apple Inc.//iCal 4.0.1//EN
259 CALSCALE:GREGORIAN
260 BEGIN:VTIMEZONE
261 TZID:Asia/Seoul
262 BEGIN:DAYLIGHT
263 TZOFFSETFROM:+0900
264 RRULE:FREQ=YEARLY;UNTIL=19880507T150000Z;BYMONTH=5;BYDAY=2SU
265 DTSTART:19870510T000000
266 TZNAME:GMT+09:00
267 TZOFFSETTO:+1000
268 END:DAYLIGHT
269 BEGIN:STANDARD
270 TZOFFSETFROM:+1000
271 DTSTART:19881009T000000
272 TZNAME:GMT+09:00
273 TZOFFSETTO:+0900
274 END:STANDARD
275 END:VTIMEZONE
276 BEGIN:VEVENT
277 CREATED:20100225T154229Z
278 UID:39A6B5ED-DD51-4AFE-A683-C35EE3749627
279 TRANSP:TRANSPARENT
280 SUMMARY:Something here
281 DTSTAMP:20100228T130202Z
282 DTSTART;TZID=Asia/Seoul:20100223T060000
283 DTEND;TZID=Asia/Seoul:20100223T070000
284 ATTENDEE;PARTSTAT=NEEDS-ACTION:mailto:lisa@example.com
285 SEQUENCE:2
286 END:VEVENT
287 END:VCALENDAR";
288 
289 
290 
291  $this->assertEquals($expected, $obj->get());
292 
293  }

◆ testGetACL()

Sabre\CalDAV\CalendarObjectTest::testGetACL ( )

Definition at line 172 of file CalendarObjectTest.php.

172  {
173 
174  $expected = [
175  [
176  'privilege' => '{DAV:}read',
177  'principal' => 'principals/user1',
178  'protected' => true,
179  ],
180  [
181  'privilege' => '{DAV:}read',
182  'principal' => 'principals/user1/calendar-proxy-write',
183  'protected' => true,
184  ],
185  [
186  'privilege' => '{DAV:}read',
187  'principal' => 'principals/user1/calendar-proxy-read',
188  'protected' => true,
189  ],
190  [
191  'privilege' => '{DAV:}write',
192  'principal' => 'principals/user1',
193  'protected' => true,
194  ],
195  [
196  'privilege' => '{DAV:}write',
197  'principal' => 'principals/user1/calendar-proxy-write',
198  'protected' => true,
199  ],
200  ];
201 
202  $children = $this->calendar->getChildren();
203  $this->assertTrue($children[0] instanceof CalendarObject);
204 
205  $obj = $children[0];
206  $this->assertEquals($expected, $obj->getACL());
207 
208  }

◆ testGetEtag1()

Sabre\CalDAV\CalendarObjectTest::testGetEtag1 ( )

Definition at line 311 of file CalendarObjectTest.php.

References Sabre\CalDAV\CalendarObjectTest\$backend.

311  {
312 
313  $objectInfo = [
314  'calendardata' => 'foo',
315  'uri' => 'foo',
316  'etag' => 'bar',
317  'calendarid' => 1
318  ];
319 
320  $backend = new Backend\Mock([], []);
321  $obj = new CalendarObject($backend, [], $objectInfo);
322 
323  $this->assertEquals('bar', $obj->getETag());
324 
325  }

◆ testGetEtag2()

Sabre\CalDAV\CalendarObjectTest::testGetEtag2 ( )

Definition at line 327 of file CalendarObjectTest.php.

References Sabre\CalDAV\CalendarObjectTest\$backend.

327  {
328 
329  $objectInfo = [
330  'calendardata' => 'foo',
331  'uri' => 'foo',
332  'calendarid' => 1
333  ];
334 
335  $backend = new Backend\Mock([], []);
336  $obj = new CalendarObject($backend, [], $objectInfo);
337 
338  $this->assertEquals('"' . md5('foo') . '"', $obj->getETag());
339 
340  }

◆ testGetGroup()

Sabre\CalDAV\CalendarObjectTest::testGetGroup ( )

Definition at line 162 of file CalendarObjectTest.php.

162  {
163 
164  $children = $this->calendar->getChildren();
165  $this->assertTrue($children[0] instanceof CalendarObject);
166 
167  $obj = $children[0];
168  $this->assertNull($obj->getGroup());
169 
170  }

◆ testGetLastModified()

Sabre\CalDAV\CalendarObjectTest::testGetLastModified ( )

testSetup

Definition at line 125 of file CalendarObjectTest.php.

125  {
126 
127  $children = $this->calendar->getChildren();
128  $this->assertTrue($children[0] instanceof CalendarObject);
129 
130  $obj = $children[0];
131 
132  $lastMod = $obj->getLastModified();
133  $this->assertTrue(is_int($lastMod) || ctype_digit($lastMod) || is_null($lastMod));
134 
135  }

◆ testGetOwner()

Sabre\CalDAV\CalendarObjectTest::testGetOwner ( )

Definition at line 152 of file CalendarObjectTest.php.

152  {
153 
154  $children = $this->calendar->getChildren();
155  $this->assertTrue($children[0] instanceof CalendarObject);
156 
157  $obj = $children[0];
158  $this->assertEquals('principals/user1', $obj->getOwner());
159 
160  }

◆ testGetRefetch()

Sabre\CalDAV\CalendarObjectTest::testGetRefetch ( )

Definition at line 295 of file CalendarObjectTest.php.

References Sabre\CalDAV\CalendarObjectTest\$backend.

295  {
296 
297  $backend = new Backend\Mock([], [
298  1 => [
299  'foo' => [
300  'calendardata' => 'foo',
301  'uri' => 'foo'
302  ],
303  ]
304  ]);
305  $obj = new CalendarObject($backend, ['id' => 1], ['uri' => 'foo']);
306 
307  $this->assertEquals('foo', $obj->get());
308 
309  }

◆ testGetSize()

Sabre\CalDAV\CalendarObjectTest::testGetSize ( )

testSetup

Definition at line 140 of file CalendarObjectTest.php.

References $size.

140  {
141 
142  $children = $this->calendar->getChildren();
143  $this->assertTrue($children[0] instanceof CalendarObject);
144 
145  $obj = $children[0];
146 
147  $size = $obj->getSize();
148  $this->assertInternalType('int', $size);
149 
150  }
$size
Definition: RandomTest.php:84

◆ testGetSize1()

Sabre\CalDAV\CalendarObjectTest::testGetSize1 ( )

Definition at line 356 of file CalendarObjectTest.php.

References Sabre\CalDAV\CalendarObjectTest\$backend.

356  {
357 
358  $objectInfo = [
359  'calendardata' => 'foo',
360  'uri' => 'foo',
361  'calendarid' => 1
362  ];
363 
364  $backend = new Backend\Mock([], []);
365  $obj = new CalendarObject($backend, [], $objectInfo);
366  $this->assertEquals(3, $obj->getSize());
367 
368  }

◆ testGetSize2()

Sabre\CalDAV\CalendarObjectTest::testGetSize2 ( )

Definition at line 370 of file CalendarObjectTest.php.

References Sabre\CalDAV\CalendarObjectTest\$backend.

370  {
371 
372  $objectInfo = [
373  'uri' => 'foo',
374  'calendarid' => 1,
375  'size' => 4,
376  ];
377 
378  $backend = new Backend\Mock([], []);
379  $obj = new CalendarObject($backend, [], $objectInfo);
380  $this->assertEquals(4, $obj->getSize());
381 
382  }

◆ testGetSupportedPrivilegesSet()

Sabre\CalDAV\CalendarObjectTest::testGetSupportedPrivilegesSet ( )

Definition at line 342 of file CalendarObjectTest.php.

References Sabre\CalDAV\CalendarObjectTest\$backend.

342  {
343 
344  $objectInfo = [
345  'calendardata' => 'foo',
346  'uri' => 'foo',
347  'calendarid' => 1
348  ];
349 
350  $backend = new Backend\Mock([], []);
351  $obj = new CalendarObject($backend, [], $objectInfo);
352  $this->assertNull($obj->getSupportedPrivilegeSet());
353 
354  }

◆ testInvalidArg1()

Sabre\CalDAV\CalendarObjectTest::testInvalidArg1 ( )

InvalidArgumentException

Definition at line 51 of file CalendarObjectTest.php.

51  {
52 
53  $obj = new CalendarObject(
54  new Backend\Mock([], []),
55  [],
56  []
57  );
58 
59  }

◆ testInvalidArg2()

Sabre\CalDAV\CalendarObjectTest::testInvalidArg2 ( )

InvalidArgumentException

Definition at line 64 of file CalendarObjectTest.php.

64  {
65 
66  $obj = new CalendarObject(
67  new Backend\Mock([], []),
68  [],
69  ['calendarid' => '1']
70  );
71 
72  }

◆ testPut()

Sabre\CalDAV\CalendarObjectTest::testPut ( )

testSetup

Definition at line 77 of file CalendarObjectTest.php.

References Sabre\CalDAV\TestUtil\getTestCalendarData().

77  {
78 
79  $children = $this->calendar->getChildren();
80  $this->assertTrue($children[0] instanceof CalendarObject);
81  $newData = TestUtil::getTestCalendarData();
82 
83  $children[0]->put($newData);
84  $this->assertEquals($newData, $children[0]->get());
85 
86  }
static getTestCalendarData($type=1)
Definition: TestUtil.php:35
+ Here is the call graph for this function:

◆ testPutStream()

Sabre\CalDAV\CalendarObjectTest::testPutStream ( )

testSetup

Definition at line 91 of file CalendarObjectTest.php.

References GuzzleHttp\Psr7\$stream, and Sabre\CalDAV\TestUtil\getTestCalendarData().

91  {
92 
93  $children = $this->calendar->getChildren();
94  $this->assertTrue($children[0] instanceof CalendarObject);
95  $newData = TestUtil::getTestCalendarData();
96 
97  $stream = fopen('php://temp', 'r+');
98  fwrite($stream, $newData);
99  rewind($stream);
100  $children[0]->put($stream);
101  $this->assertEquals($newData, $children[0]->get());
102 
103  }
static getTestCalendarData($type=1)
Definition: TestUtil.php:35
$stream
PHP stream implementation.
+ Here is the call graph for this function:

◆ testSetACL()

Sabre\CalDAV\CalendarObjectTest::testSetACL ( )

Definition at line 239 of file CalendarObjectTest.php.

239  {
240 
241  $children = $this->calendar->getChildren();
242  $this->assertTrue($children[0] instanceof CalendarObject);
243 
244  $obj = $children[0];
245  $obj->setACL([]);
246 
247  }

◆ testSetup()

Sabre\CalDAV\CalendarObjectTest::testSetup ( )

Definition at line 36 of file CalendarObjectTest.php.

36  {
37 
38  $children = $this->calendar->getChildren();
39  $this->assertTrue($children[0] instanceof CalendarObject);
40 
41  $this->assertInternalType('string', $children[0]->getName());
42  $this->assertInternalType('string', $children[0]->get());
43  $this->assertInternalType('string', $children[0]->getETag());
44  $this->assertEquals('text/calendar; charset=utf-8', $children[0]->getContentType());
45 
46  }

Field Documentation

◆ $backend

◆ $calendar

Sabre\CalDAV\CalendarObjectTest::$calendar
protected

Definition at line 16 of file CalendarObjectTest.php.

◆ $principalBackend

Sabre\CalDAV\CalendarObjectTest::$principalBackend
protected

Definition at line 17 of file CalendarObjectTest.php.


The documentation for this class was generated from the following file: