ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
AddressBookHomeTest.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\CardDAV;
4 
6 
8 
12  protected $s;
13  protected $backend;
14 
15  function setUp() {
16 
17  $this->backend = new Backend\Mock();
18  $this->s = new AddressBookHome(
19  $this->backend,
20  'principals/user1'
21  );
22 
23  }
24 
25  function testGetName() {
26 
27  $this->assertEquals('user1', $this->s->getName());
28 
29  }
30 
34  function testSetName() {
35 
36  $this->s->setName('user2');
37 
38  }
39 
43  function testDelete() {
44 
45  $this->s->delete();
46 
47  }
48 
49  function testGetLastModified() {
50 
51  $this->assertNull($this->s->getLastModified());
52 
53  }
54 
58  function testCreateFile() {
59 
60  $this->s->createFile('bla');
61 
62  }
63 
67  function testCreateDirectory() {
68 
69  $this->s->createDirectory('bla');
70 
71  }
72 
73  function testGetChild() {
74 
75  $child = $this->s->getChild('book1');
76  $this->assertInstanceOf('Sabre\\CardDAV\\AddressBook', $child);
77  $this->assertEquals('book1', $child->getName());
78 
79  }
80 
84  function testGetChild404() {
85 
86  $this->s->getChild('book2');
87 
88  }
89 
90  function testGetChildren() {
91 
92  $children = $this->s->getChildren();
93  $this->assertEquals(2, count($children));
94  $this->assertInstanceOf('Sabre\\CardDAV\\AddressBook', $children[0]);
95  $this->assertEquals('book1', $children[0]->getName());
96 
97  }
98 
100 
101  $resourceType = [
102  '{' . Plugin::NS_CARDDAV . '}addressbook',
103  '{DAV:}collection',
104  ];
105  $this->s->createExtendedCollection('book2', new MkCol($resourceType, ['{DAV:}displayname' => 'a-book 2']));
106 
107  $this->assertEquals([
108  'id' => 'book2',
109  'uri' => 'book2',
110  '{DAV:}displayname' => 'a-book 2',
111  'principaluri' => 'principals/user1',
112  ], $this->backend->addressBooks[2]);
113 
114  }
115 
120 
121  $resourceType = [
122  '{DAV:}collection',
123  ];
124  $this->s->createExtendedCollection('book2', new MkCol($resourceType, ['{DAV:}displayname' => 'a-book 2']));
125 
126  }
127 
128 
129  function testACLMethods() {
130 
131  $this->assertEquals('principals/user1', $this->s->getOwner());
132  $this->assertNull($this->s->getGroup());
133  $this->assertEquals([
134  [
135  'privilege' => '{DAV:}all',
136  'principal' => '{DAV:}owner',
137  'protected' => true,
138  ],
139  ], $this->s->getACL());
140 
141  }
142 
146  function testSetACL() {
147 
148  $this->s->setACL([]);
149 
150  }
151 
153 
154  $this->assertNull(
155  $this->s->getSupportedPrivilegeSet()
156  );
157 
158  }
159 }
AddressBook Home class.
const NS_CARDDAV
xml namespace for CardDAV elements
Definition: Plugin.php:33
This class represents a MKCOL operation.
Definition: MkCol.php:23