ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PluginPropertiesTest.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\CalDAV\Schedule;
4 
5 use Sabre\DAV;
6 
8 
9  protected $setupCalDAV = true;
10  protected $setupCalDAVScheduling = true;
11  protected $setupPropertyStorage = true;
12 
13  function setUp() {
14 
15  parent::setUp();
16  $this->caldavBackend->createCalendar(
17  'principals/user1',
18  'default',
19  [
20 
21  ]
22  );
23  $this->principalBackend->addPrincipal([
24  'uri' => 'principals/user1/calendar-proxy-read'
25  ]);
26 
27  }
28 
30 
31  $props = $this->server->getPropertiesForPath('/principals/user1', [
32  '{urn:ietf:params:xml:ns:caldav}schedule-inbox-URL',
33  '{urn:ietf:params:xml:ns:caldav}schedule-outbox-URL',
34  '{urn:ietf:params:xml:ns:caldav}calendar-user-address-set',
35  '{urn:ietf:params:xml:ns:caldav}calendar-user-type',
36  '{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL',
37  ]);
38 
39  $this->assertArrayHasKey(0, $props);
40  $this->assertArrayHasKey(200, $props[0]);
41 
42  $this->assertArrayHasKey('{urn:ietf:params:xml:ns:caldav}schedule-outbox-URL', $props[0][200]);
43  $prop = $props[0][200]['{urn:ietf:params:xml:ns:caldav}schedule-outbox-URL'];
44  $this->assertTrue($prop instanceof DAV\Xml\Property\Href);
45  $this->assertEquals('calendars/user1/outbox/', $prop->getHref());
46 
47  $this->assertArrayHasKey('{urn:ietf:params:xml:ns:caldav}schedule-inbox-URL', $props[0][200]);
48  $prop = $props[0][200]['{urn:ietf:params:xml:ns:caldav}schedule-inbox-URL'];
49  $this->assertTrue($prop instanceof DAV\Xml\Property\Href);
50  $this->assertEquals('calendars/user1/inbox/', $prop->getHref());
51 
52  $this->assertArrayHasKey('{urn:ietf:params:xml:ns:caldav}calendar-user-address-set', $props[0][200]);
53  $prop = $props[0][200]['{urn:ietf:params:xml:ns:caldav}calendar-user-address-set'];
54  $this->assertTrue($prop instanceof DAV\Xml\Property\Href);
55  $this->assertEquals(['mailto:user1.sabredav@sabredav.org', '/principals/user1/'], $prop->getHrefs());
56 
57  $this->assertArrayHasKey('{urn:ietf:params:xml:ns:caldav}calendar-user-type', $props[0][200]);
58  $prop = $props[0][200]['{urn:ietf:params:xml:ns:caldav}calendar-user-type'];
59  $this->assertEquals('INDIVIDUAL', $prop);
60 
61  $this->assertArrayHasKey('{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL', $props[0][200]);
62  $prop = $props[0][200]['{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL'];
63  $this->assertEquals('calendars/user1/default/', $prop->getHref());
64 
65  }
67 
68  $props = $this->server->getPropertiesForPath('principals/user1/calendar-proxy-read', [
69  '{urn:ietf:params:xml:ns:caldav}schedule-inbox-URL',
70  '{urn:ietf:params:xml:ns:caldav}schedule-outbox-URL',
71  '{urn:ietf:params:xml:ns:caldav}calendar-user-address-set',
72  '{urn:ietf:params:xml:ns:caldav}calendar-user-type',
73  '{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL',
74  ]);
75 
76  $this->assertArrayHasKey(0, $props);
77  $this->assertArrayHasKey(200, $props[0]);
78  $this->assertArrayHasKey(404, $props[0]);
79 
80  $this->assertArrayHasKey('{urn:ietf:params:xml:ns:caldav}schedule-outbox-URL', $props[0][404]);
81  $this->assertArrayHasKey('{urn:ietf:params:xml:ns:caldav}schedule-inbox-URL', $props[0][404]);
82 
83  $prop = $props[0][200]['{urn:ietf:params:xml:ns:caldav}calendar-user-address-set'];
84  $this->assertTrue($prop instanceof DAV\Xml\Property\Href);
85  $this->assertEquals(['/principals/user1/calendar-proxy-read/'], $prop->getHrefs());
86 
87  $this->assertArrayHasKey('{urn:ietf:params:xml:ns:caldav}calendar-user-type', $props[0][200]);
88  $prop = $props[0][200]['{urn:ietf:params:xml:ns:caldav}calendar-user-type'];
89  $this->assertEquals('INDIVIDUAL', $prop);
90 
91  $this->assertArrayHasKey('{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL', $props[0][404]);
92 
93  }
94  function testNoDefaultCalendar() {
95 
96  foreach ($this->caldavBackend->getCalendarsForUser('principals/user1') as $calendar) {
97  $this->caldavBackend->deleteCalendar($calendar['id']);
98  }
99  $props = $this->server->getPropertiesForPath('/principals/user1', [
100  '{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL',
101  ]);
102 
103  $this->assertArrayHasKey(0, $props);
104  $this->assertArrayHasKey(404, $props[0]);
105 
106  $this->assertArrayHasKey('{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL', $props[0][404]);
107 
108  }
109 
115 
116  $path = 'calendars/user1/inbox';
117  $oldProp = '{http://calendarserver.org/ns/}calendar-availability';
118  $newProp = '{urn:ietf:params:xml:ns:caldav}calendar-availability';
119  $value1 = 'first value';
120  $value2 = 'second value';
121 
122  // Storing with the old name
123  $this->server->updateProperties($path, [
124  $oldProp => $value1
125  ]);
126 
127  // Retrieving with the new name
128  $this->assertEquals(
129  [$newProp => $value1],
130  $this->server->getProperties($path, [$newProp])
131  );
132 
133  // Storing with the new name
134  $this->server->updateProperties($path, [
135  $newProp => $value2
136  ]);
137 
138  // Retrieving with the old name
139  $this->assertEquals(
140  [$oldProp => $value2],
141  $this->server->getProperties($path, [$oldProp])
142  );
143 
144  }
145 
146 }
$path
Definition: aliased.php:25
testAvailabilityMapping()
There are two properties for availability.
Href property.
Definition: Href.php:26
This class may be used as a basis for other webdav-related unittests.