ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
UserTest.php
Go to the documentation of this file.
1<?php
2
4
6
8
9 function getInstance() {
10
11 $backend = new DAVACL\PrincipalBackend\Mock();
12 $backend->addPrincipal([
13 'uri' => 'principals/user/calendar-proxy-read',
14 ]);
15 $backend->addPrincipal([
16 'uri' => 'principals/user/calendar-proxy-write',
17 ]);
18 $backend->addPrincipal([
19 'uri' => 'principals/user/random',
20 ]);
21 return new User($backend, [
22 'uri' => 'principals/user',
23 ]);
24
25 }
26
30 function testCreateFile() {
31
32 $u = $this->getInstance();
33 $u->createFile('test');
34
35 }
36
41
42 $u = $this->getInstance();
43 $u->createDirectory('test');
44
45 }
46
48
49 $u = $this->getInstance();
50 $child = $u->getChild('calendar-proxy-read');
51 $this->assertInstanceOf('Sabre\\CalDAV\\Principal\\ProxyRead', $child);
52
53 }
54
56
57 $u = $this->getInstance();
58 $child = $u->getChild('calendar-proxy-write');
59 $this->assertInstanceOf('Sabre\\CalDAV\\Principal\\ProxyWrite', $child);
60
61 }
62
67
68 $u = $this->getInstance();
69 $child = $u->getChild('foo');
70
71 }
72
77
78 $u = $this->getInstance();
79 $child = $u->getChild('random');
80
81 }
82
83 function testGetChildren() {
84
85 $u = $this->getInstance();
86 $children = $u->getChildren();
87 $this->assertEquals(2, count($children));
88 $this->assertInstanceOf('Sabre\\CalDAV\\Principal\\ProxyRead', $children[0]);
89 $this->assertInstanceOf('Sabre\\CalDAV\\Principal\\ProxyWrite', $children[1]);
90
91 }
92
93 function testChildExist() {
94
95 $u = $this->getInstance();
96 $this->assertTrue($u->childExists('calendar-proxy-read'));
97 $this->assertTrue($u->childExists('calendar-proxy-write'));
98 $this->assertFalse($u->childExists('foo'));
99
100 }
101
102 function testGetACL() {
103
104 $expected = [
105 [
106 'privilege' => '{DAV:}all',
107 'principal' => '{DAV:}owner',
108 'protected' => true,
109 ],
110 [
111 'privilege' => '{DAV:}read',
112 'principal' => 'principals/user/calendar-proxy-read',
113 'protected' => true,
114 ],
115 [
116 'privilege' => '{DAV:}read',
117 'principal' => 'principals/user/calendar-proxy-write',
118 'protected' => true,
119 ],
120 ];
121
122 $u = $this->getInstance();
123 $this->assertEquals($expected, $u->getACL());
124
125 }
126
127}
An exception for terminatinating execution or to throw for unit testing.
testCreateFile()
@expectedException Sabre\DAV\Exception\Forbidden
Definition: UserTest.php:30
testCreateDirectory()
@expectedException Sabre\DAV\Exception\Forbidden
Definition: UserTest.php:40
testGetChildNotFound2()
@expectedException Sabre\DAV\Exception\NotFound
Definition: UserTest.php:76
testGetChildNotFound()
@expectedException Sabre\DAV\Exception\NotFound
Definition: UserTest.php:66
CalDAV principal.
Definition: User.php:19