ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
SubscriptionTest.php
Go to the documentation of this file.
1 <?php
2 
4 
7 
9 
10  protected $backend;
11 
12  function getSub($override = []) {
13 
14  $caldavBackend = new \Sabre\CalDAV\Backend\MockSubscriptionSupport([], []);
15 
16  $info = [
17  '{http://calendarserver.org/ns/}source' => new Href('http://example.org/src', false),
18  'lastmodified' => date('2013-04-06 11:40:00'), // tomorrow is my birthday!
19  '{DAV:}displayname' => 'displayname',
20  ];
21 
22 
23  $id = $caldavBackend->createSubscription('principals/user1', 'uri', array_merge($info, $override));
24  $subInfo = $caldavBackend->getSubscriptionsForUser('principals/user1');
25 
26  $this->assertEquals(1, count($subInfo));
27  $subscription = new Subscription($caldavBackend, $subInfo[0]);
28 
29  $this->backend = $caldavBackend;
30  return $subscription;
31 
32  }
33 
34  function testValues() {
35 
36  $sub = $this->getSub();
37 
38  $this->assertEquals('uri', $sub->getName());
39  $this->assertEquals(date('2013-04-06 11:40:00'), $sub->getLastModified());
40  $this->assertEquals([], $sub->getChildren());
41 
42  $this->assertEquals(
43  [
44  '{DAV:}displayname' => 'displayname',
45  '{http://calendarserver.org/ns/}source' => new Href('http://example.org/src', false),
46  ],
47  $sub->getProperties(['{DAV:}displayname', '{http://calendarserver.org/ns/}source'])
48  );
49 
50  $this->assertEquals('principals/user1', $sub->getOwner());
51  $this->assertNull($sub->getGroup());
52 
53  $acl = [
54  [
55  'privilege' => '{DAV:}all',
56  'principal' => 'principals/user1',
57  'protected' => true,
58  ],
59  [
60  'privilege' => '{DAV:}all',
61  'principal' => 'principals/user1/calendar-proxy-write',
62  'protected' => true,
63  ],
64  [
65  'privilege' => '{DAV:}read',
66  'principal' => 'principals/user1/calendar-proxy-read',
67  'protected' => true,
68  ]
69  ];
70  $this->assertEquals($acl, $sub->getACL());
71 
72  $this->assertNull($sub->getSupportedPrivilegeSet());
73 
74  }
75 
76  function testValues2() {
77 
78  $sub = $this->getSub([
79  'lastmodified' => null,
80  ]);
81 
82  $this->assertEquals(null, $sub->getLastModified());
83 
84  }
85 
89  function testSetACL() {
90 
91  $sub = $this->getSub();
92  $sub->setACL([]);
93 
94  }
95 
96  function testDelete() {
97 
98  $sub = $this->getSub();
99  $sub->delete();
100 
101  $this->assertEquals([], $this->backend->getSubscriptionsForUser('principals1/user1'));
102 
103  }
104 
105  function testUpdateProperties() {
106 
107  $sub = $this->getSub();
108  $propPatch = new PropPatch([
109  '{DAV:}displayname' => 'foo',
110  ]);
111  $sub->propPatch($propPatch);
112  $this->assertTrue($propPatch->commit());
113 
114  $this->assertEquals(
115  'foo',
116  $this->backend->getSubscriptionsForUser('principals/user1')[0]['{DAV:}displayname']
117  );
118 
119  }
120 
124  function testBadConstruct() {
125 
126  $caldavBackend = new \Sabre\CalDAV\Backend\MockSubscriptionSupport([], []);
127  new Subscription($caldavBackend, []);
128 
129  }
130 
131 }
This class represents a set of properties that are going to be updated.
Definition: PropPatch.php:20
if(!array_key_exists('StateId', $_REQUEST)) $id
Href property.
Definition: Href.php:26
$caldavBackend
$info
Definition: index.php:5