| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- <?php
- namespace Sabre\CalDAV;
- use Sabre\DAVACL;
- class SharedCalendarTest extends \PHPUnit_Framework_TestCase {
- protected $backend;
- function getInstance(array $props = null) {
- if (is_null($props)) {
- $props = array(
- 'id' => 1,
- '{http://calendarserver.org/ns/}shared-url' => 'calendars/owner/original',
- '{http://sabredav.org/ns}owner-principal' => 'principals/owner',
- '{http://sabredav.org/ns}read-only' => false,
- 'principaluri' => 'principals/sharee',
- );
- }
- $this->backend = new Backend\MockSharing(
- array($props),
- array(),
- array()
- );
- $this->backend->updateShares(1, array(
- array(
- 'href' => 'mailto:removeme@example.org',
- 'commonName' => 'To be removed',
- 'readOnly' => true,
- ),
- ), array());
- return new SharedCalendar($this->backend, $props);
- }
- function testGetSharedUrl() {
- $this->assertEquals('calendars/owner/original', $this->getInstance()->getSharedUrl());
- }
- function testGetShares() {
- $this->assertEquals(array(array(
- 'href' => 'mailto:removeme@example.org',
- 'commonName' => 'To be removed',
- 'readOnly' => true,
- 'status' => SharingPlugin::STATUS_NORESPONSE,
- )), $this->getInstance()->getShares());
- }
- function testGetOwner() {
- $this->assertEquals('principals/owner', $this->getInstance()->getOwner());
- }
- function testGetACL() {
- $expected = array(
- array(
- 'privilege' => '{DAV:}read',
- 'principal' => 'principals/owner',
- 'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}read',
- 'principal' => 'principals/owner/calendar-proxy-write',
- 'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}read',
- 'principal' => 'principals/owner/calendar-proxy-read',
- 'protected' => true,
- ),
- array(
- 'privilege' => '{' . Plugin::NS_CALDAV . '}read-free-busy',
- 'principal' => '{DAV:}authenticated',
- 'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}write',
- 'principal' => 'principals/owner',
- 'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}write',
- 'principal' => 'principals/owner/calendar-proxy-write',
- 'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}read',
- 'principal' => 'principals/sharee',
- 'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}write',
- 'principal' => 'principals/sharee',
- 'protected' => true,
- ),
- );
- $this->assertEquals($expected, $this->getInstance()->getACL());
- }
- function testGetChildACL() {
- $expected = array(
- array(
- 'privilege' => '{DAV:}read',
- 'principal' => 'principals/owner',
- 'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}read',
- 'principal' => 'principals/owner/calendar-proxy-write',
- 'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}read',
- 'principal' => 'principals/owner/calendar-proxy-read',
- 'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}write',
- 'principal' => 'principals/owner',
- 'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}write',
- 'principal' => 'principals/owner/calendar-proxy-write',
- 'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}read',
- 'principal' => 'principals/sharee',
- 'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}write',
- 'principal' => 'principals/sharee',
- 'protected' => true,
- ),
- );
- $this->assertEquals($expected, $this->getInstance()->getChildACL());
- }
- function testGetChildACLReadOnly() {
- $expected = array(
- array(
- 'privilege' => '{DAV:}read',
- 'principal' => 'principals/owner',
- 'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}read',
- 'principal' => 'principals/owner/calendar-proxy-write',
- 'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}read',
- 'principal' => 'principals/owner/calendar-proxy-read',
- 'protected' => true,
- ),
- array(
- 'privilege' => '{DAV:}read',
- 'principal' => 'principals/sharee',
- 'protected' => true,
- ),
- );
- $props = array(
- 'id' => 1,
- '{http://calendarserver.org/ns/}shared-url' => 'calendars/owner/original',
- '{http://sabredav.org/ns}owner-principal' => 'principals/owner',
- '{http://sabredav.org/ns}read-only' => true,
- 'principaluri' => 'principals/sharee',
- );
- $this->assertEquals($expected, $this->getInstance($props)->getChildACL());
- }
- /**
- * @expectedException InvalidArgumentException
- */
- public function testCreateInstanceMissingArg() {
- $this->getInstance(array(
- 'id' => 1,
- '{http://calendarserver.org/ns/}shared-url' => 'calendars/owner/original',
- '{http://sabredav.org/ns}read-only' => false,
- 'principaluri' => 'principals/sharee',
- ));
- }
- }
|