ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
CalendarHomeSubscriptionsTest.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\CalDAV;
4 
6 
8 
9  protected $backend;
10 
11  function getInstance() {
12 
13  $props = [
14  '{DAV:}displayname' => 'baz',
15  '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/test.ics'),
16  ];
17  $principal = [
18  'uri' => 'principals/user1'
19  ];
20  $this->backend = new Backend\MockSubscriptionSupport([], []);
21  $this->backend->createSubscription('principals/user1', 'uri', $props);
22 
23  return new CalendarHome($this->backend, $principal);
24 
25  }
26 
27  function testSimple() {
28 
29  $instance = $this->getInstance();
30  $this->assertEquals('user1', $instance->getName());
31 
32  }
33 
34  function testGetChildren() {
35 
36  $instance = $this->getInstance();
37  $children = $instance->getChildren();
38  $this->assertEquals(1, count($children));
39  foreach ($children as $child) {
40  if ($child instanceof Subscriptions\Subscription) {
41  return;
42  }
43  }
44  $this->fail('There were no subscription nodes in the calendar home');
45 
46  }
47 
49 
50  $instance = $this->getInstance();
51  $rt = ['{DAV:}collection', '{http://calendarserver.org/ns/}subscribed'];
52 
53  $props = [
54  '{DAV:}displayname' => 'baz',
55  '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/test2.ics'),
56  ];
57  $instance->createExtendedCollection('sub2', new MkCol($rt, $props));
58 
59  $children = $instance->getChildren();
60  $this->assertEquals(2, count($children));
61 
62  }
63 
68 
69  $principal = [
70  'uri' => 'principals/user1'
71  ];
72  $backend = new Backend\Mock([], []);
73  $uC = new CalendarHome($backend, $principal);
74 
75  $rt = ['{DAV:}collection', '{http://calendarserver.org/ns/}subscribed'];
76 
77  $props = [
78  '{DAV:}displayname' => 'baz',
79  '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/test2.ics'),
80  ];
81  $uC->createExtendedCollection('sub2', new MkCol($rt, $props));
82 
83  }
84 
85 }
The CalendarHome represents a node that is usually in a users&#39; calendar-homeset.
This class represents a MKCOL operation.
Definition: MkCol.php:23
This is a mock CalDAV backend that supports subscriptions.