]> git.mxchange.org Git - friendica-addons.git/blob - dav/SabreDAV/tests/Sabre/CalDAV/Principal/UserTest.php
Merge branch 'master' of git://github.com/friendica/friendica-addons
[friendica-addons.git] / dav / SabreDAV / tests / Sabre / CalDAV / Principal / UserTest.php
1 <?php
2
3 class Sabre_CalDAV_Principal_UserTest extends PHPUnit_Framework_TestCase {
4
5     function getInstance() {
6
7         $backend = new Sabre_DAVACL_MockPrincipalBackend();
8         $backend->addPrincipal(array(
9             'uri' => 'principals/user/calendar-proxy-read',
10         ));
11         $backend->addPrincipal(array(
12             'uri' => 'principals/user/calendar-proxy-write',
13         ));
14         $backend->addPrincipal(array(
15             'uri' => 'principals/user/random',
16         ));
17         return new Sabre_CalDAV_Principal_User($backend, array(
18             'uri' => 'principals/user',
19         ));
20
21     }
22
23     /**
24      * @expectedException Sabre_DAV_Exception_Forbidden
25      */
26     function testCreateFile() {
27
28         $u = $this->getInstance();
29         $u->createFile('test');
30
31     }
32
33     /**
34      * @expectedException Sabre_DAV_Exception_Forbidden
35      */
36     function testCreateDirectory() {
37
38         $u = $this->getInstance();
39         $u->createDirectory('test');
40
41     }
42
43     function testGetChildProxyRead() {
44
45         $u = $this->getInstance();
46         $child = $u->getChild('calendar-proxy-read');
47         $this->assertInstanceOf('Sabre_CalDAV_Principal_ProxyRead', $child);
48
49     }
50
51     function testGetChildProxyWrite() {
52
53         $u = $this->getInstance();
54         $child = $u->getChild('calendar-proxy-write');
55         $this->assertInstanceOf('Sabre_CalDAV_Principal_ProxyWrite', $child);
56
57     }
58
59     /**
60      * @expectedException Sabre_DAV_Exception_NotFound
61      */
62     function testGetChildNotFound() {
63
64         $u = $this->getInstance();
65         $child = $u->getChild('foo');
66
67     }
68
69     /**
70      * @expectedException Sabre_DAV_Exception_NotFound
71      */
72     function testGetChildNotFound2() {
73
74         $u = $this->getInstance();
75         $child = $u->getChild('random');
76
77     }
78
79     function testGetChildren() {
80
81         $u = $this->getInstance();
82         $children = $u->getChildren();
83         $this->assertEquals(2, count($children));
84         $this->assertInstanceOf('Sabre_CalDAV_Principal_ProxyRead', $children[0]);
85         $this->assertInstanceOf('Sabre_CalDAV_Principal_ProxyWrite', $children[1]);
86
87     }
88
89     function testChildExist() {
90
91         $u = $this->getInstance();
92         $this->assertTrue($u->childExists('calendar-proxy-read'));
93         $this->assertTrue($u->childExists('calendar-proxy-write'));
94         $this->assertFalse($u->childExists('foo'));
95
96     }
97
98     function testGetACL() {
99
100         $expected = array(
101             array(
102                 'privilege' => '{DAV:}read',
103                 'principal' => 'principals/user',
104                 'protected' => true,
105             ),
106             array(
107                 'privilege' => '{DAV:}read',
108                 'principal' => 'principals/user/calendar-proxy-read',
109                 'protected' => true,
110             ),
111             array(
112                 'privilege' => '{DAV:}read',
113                 'principal' => 'principals/user/calendar-proxy-write',
114                 'protected' => true,
115             ),
116         );
117
118         $u = $this->getInstance();
119         $this->assertEquals($expected, $u->getACL());
120
121     }
122
123 }