1<?php 2 3namespace Sabre\CalDAV\Schedule; 4use Sabre\CalDAV; 5use Sabre\DAV; 6 7class OutboxTest extends \PHPUnit_Framework_TestCase { 8 9 function testSetup() { 10 11 $outbox = new Outbox('principals/user1'); 12 $this->assertEquals('outbox', $outbox->getName()); 13 $this->assertEquals(array(), $outbox->getChildren()); 14 $this->assertEquals('principals/user1', $outbox->getOwner()); 15 $this->assertEquals(null, $outbox->getGroup()); 16 17 $this->assertEquals(array( 18 array( 19 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-query-freebusy', 20 'principal' => 'principals/user1', 21 'protected' => true, 22 ), 23 24 array( 25 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-post-vevent', 26 'principal' => 'principals/user1', 27 'protected' => true, 28 ), 29 array( 30 'privilege' => '{DAV:}read', 31 'principal' => 'principals/user1', 32 'protected' => true, 33 ), 34 array( 35 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-query-freebusy', 36 'principal' => 'principals/user1/calendar-proxy-write', 37 'protected' => true, 38 ), 39 array( 40 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-post-vevent', 41 'principal' => 'principals/user1/calendar-proxy-write', 42 'protected' => true, 43 ), 44 array( 45 'privilege' => '{DAV:}read', 46 'principal' => 'principals/user1/calendar-proxy-read', 47 'protected' => true, 48 ), 49 array( 50 'privilege' => '{DAV:}read', 51 'principal' => 'principals/user1/calendar-proxy-write', 52 'protected' => true, 53 ), 54 ), $outbox->getACL()); 55 56 $ok = false; 57 try { 58 $outbox->setACL(array()); 59 } catch (DAV\Exception\MethodNotAllowed $e) { 60 $ok = true; 61 } 62 if (!$ok) { 63 $this->fail('Exception was not emitted'); 64 } 65 66 } 67 68 function testGetSupportedPrivilegeSet() { 69 70 $outbox = new Outbox('principals/user1'); 71 $r = $outbox->getSupportedPrivilegeSet(); 72 73 $ok = 0; 74 foreach($r['aggregates'] as $priv) { 75 76 if ($priv['privilege'] == '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-query-freebusy') { 77 $ok++; 78 } 79 if ($priv['privilege'] == '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-post-vevent') { 80 $ok++; 81 } 82 } 83 84 $this->assertEquals(2, $ok, "We're missing one or more privileges"); 85 86 } 87 88 89} 90