3 class Sabre_CalDAV_Principal_UserTest extends PHPUnit_Framework_TestCase {
5 function getInstance() {
7 $backend = new Sabre_DAVACL_MockPrincipalBackend();
8 $backend->addPrincipal(array(
9 'uri' => 'principals/user/calendar-proxy-read',
11 $backend->addPrincipal(array(
12 'uri' => 'principals/user/calendar-proxy-write',
14 $backend->addPrincipal(array(
15 'uri' => 'principals/user/random',
17 return new Sabre_CalDAV_Principal_User($backend, array(
18 'uri' => 'principals/user',
24 * @expectedException Sabre_DAV_Exception_Forbidden
26 function testCreateFile() {
28 $u = $this->getInstance();
29 $u->createFile('test');
34 * @expectedException Sabre_DAV_Exception_Forbidden
36 function testCreateDirectory() {
38 $u = $this->getInstance();
39 $u->createDirectory('test');
43 function testGetChildProxyRead() {
45 $u = $this->getInstance();
46 $child = $u->getChild('calendar-proxy-read');
47 $this->assertInstanceOf('Sabre_CalDAV_Principal_ProxyRead', $child);
51 function testGetChildProxyWrite() {
53 $u = $this->getInstance();
54 $child = $u->getChild('calendar-proxy-write');
55 $this->assertInstanceOf('Sabre_CalDAV_Principal_ProxyWrite', $child);
60 * @expectedException Sabre_DAV_Exception_NotFound
62 function testGetChildNotFound() {
64 $u = $this->getInstance();
65 $child = $u->getChild('foo');
70 * @expectedException Sabre_DAV_Exception_NotFound
72 function testGetChildNotFound2() {
74 $u = $this->getInstance();
75 $child = $u->getChild('random');
79 function testGetChildren() {
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]);
89 function testChildExist() {
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'));
98 function testGetACL() {
102 'privilege' => '{DAV:}read',
103 'principal' => 'principals/user',
107 'privilege' => '{DAV:}read',
108 'principal' => 'principals/user/calendar-proxy-read',
112 'privilege' => '{DAV:}read',
113 'principal' => 'principals/user/calendar-proxy-write',
118 $u = $this->getInstance();
119 $this->assertEquals($expected, $u->getACL());