3 require_once 'Sabre/CalDAV/TestUtil.php';
4 require_once 'Sabre/DAVACL/MockPrincipalBackend.php';
7 * @covers Sabre_CalDAV_UserCalendars
9 class Sabre_CalDAV_UserCalendarsTest extends PHPUnit_Framework_TestCase {
12 * @var Sabre_CalDAV_UserCalendars
14 protected $usercalendars;
16 * @var Sabre_CalDAV_Backend_PDO
19 protected $principalBackend;
23 if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available');
24 $this->backend = Sabre_CalDAV_TestUtil::getBackend();
25 $this->principalBackend = new Sabre_DAVACL_MockPrincipalBackend('realm');
26 $this->usercalendars = new Sabre_CalDAV_UserCalendars($this->principalBackend, $this->backend, 'principals/user1');
30 function testSimple() {
32 $this->assertEquals('user1',$this->usercalendars->getName());
37 * @expectedException Sabre_DAV_Exception_NotFound
40 function testGetChildNotFound() {
42 $this->usercalendars->getChild('randomname');
46 function testChildExists() {
48 $this->assertFalse($this->usercalendars->childExists('foo'));
49 $this->assertTrue($this->usercalendars->childExists('UUID-123467'));
53 function testGetOwner() {
55 $this->assertEquals('principals/user1', $this->usercalendars->getOwner());
59 function testGetGroup() {
61 $this->assertNull($this->usercalendars->getGroup());
65 function testGetACL() {
69 'privilege' => '{DAV:}read',
70 'principal' => 'principals/user1',
74 'privilege' => '{DAV:}write',
75 'principal' => 'principals/user1',
79 'privilege' => '{DAV:}read',
80 'principal' => 'principals/user1/calendar-proxy-write',
84 'privilege' => '{DAV:}write',
85 'principal' => 'principals/user1/calendar-proxy-write',
89 'privilege' => '{DAV:}read',
90 'principal' => 'principals/user1/calendar-proxy-read',
94 $this->assertEquals($expected, $this->usercalendars->getACL());
99 * @expectedException Sabre_DAV_Exception_MethodNotAllowed
101 function testSetACL() {
103 $this->usercalendars->setACL(array());
108 * @expectedException Sabre_DAV_Exception_Forbidden
109 * @depends testSimple
111 function testSetName() {
113 $this->usercalendars->setName('bla');
118 * @expectedException Sabre_DAV_Exception_Forbidden
119 * @depends testSimple
121 function testDelete() {
123 $this->usercalendars->delete();
128 * @depends testSimple
130 function testGetLastModified() {
132 $this->assertNull($this->usercalendars->getLastModified());
137 * @expectedException Sabre_DAV_Exception_MethodNotAllowed
138 * @depends testSimple
140 function testCreateFile() {
142 $this->usercalendars->createFile('bla');
148 * @expectedException Sabre_DAV_Exception_MethodNotAllowed
149 * @depends testSimple
151 function testCreateDirectory() {
153 $this->usercalendars->createDirectory('bla');
158 * @depends testSimple
160 function testCreateExtendedCollection() {
162 $result = $this->usercalendars->createExtendedCollection('newcalendar', array('{DAV:}collection', '{urn:ietf:params:xml:ns:caldav}calendar'), array());
163 $this->assertNull($result);
164 $cals = $this->backend->getCalendarsForUser('principals/user1');
165 $this->assertEquals(3,count($cals));
170 * @expectedException Sabre_DAV_Exception_InvalidResourceType
171 * @depends testSimple
173 function testCreateExtendedCollectionBadResourceType() {
175 $this->usercalendars->createExtendedCollection('newcalendar', array('{DAV:}collection','{DAV:}blabla'), array());
179 function testGetSupportedPrivilegesSet() {
181 $this->assertNull($this->usercalendars->getSupportedPrivilegeSet());