Example #1
0
 function setup()
 {
     $this->caldavBackend = new Sabre_CalDAV_Backend_Mock(array(array('id' => 1, 'uri' => 'UUID-123467', 'principaluri' => 'principals/user1', '{DAV:}displayname' => 'user1 calendar', '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar description', '{http://apple.com/ns/ical/}calendar-order' => '1', '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Sabre_CalDAV_Property_SupportedCalendarComponentSet(array('VEVENT', 'VTODO'))), array('id' => 2, 'uri' => 'UUID-123468', 'principaluri' => 'principals/user1', '{DAV:}displayname' => 'user1 calendar2', '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar description', '{http://apple.com/ns/ical/}calendar-order' => '1', '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Sabre_CalDAV_Property_SupportedCalendarComponentSet(array('VEVENT', 'VTODO')))), array(1 => array('UUID-2345' => array('calendardata' => Sabre_CalDAV_TestUtil::getTestCalendarData()))));
     $principalBackend = new Sabre_DAVACL_MockPrincipalBackend();
     $principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-read', array('principals/user1'));
     $principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-write', array('principals/user1'));
     $principalBackend->addPrincipal(array('uri' => 'principals/admin/calendar-proxy-read'));
     $principalBackend->addPrincipal(array('uri' => 'principals/admin/calendar-proxy-write'));
     $calendars = new Sabre_CalDAV_CalendarRootNode($principalBackend, $this->caldavBackend);
     $principals = new Sabre_CalDAV_Principal_Collection($principalBackend);
     $root = new Sabre_DAV_SimpleCollection('root');
     $root->addChild($calendars);
     $root->addChild($principals);
     $objectTree = new Sabre_DAV_ObjectTree($root);
     $this->server = new Sabre_DAV_Server($objectTree);
     $this->server->debugExceptions = true;
     $this->server->setBaseUri('/');
     $this->plugin = new Sabre_CalDAV_Plugin();
     $this->server->addPlugin($this->plugin);
     // Adding ACL plugin
     $this->server->addPlugin(new Sabre_DAVACL_Plugin());
     // Adding Auth plugin, and ensuring that we are logged in.
     $authBackend = new Sabre_DAV_Auth_MockBackend();
     $authBackend->defaultUser = '******';
     $authPlugin = new Sabre_DAV_Auth_Plugin($authBackend, 'SabreDAV');
     $this->server->addPlugin($authPlugin);
     $authPlugin->beforeMethod('GET', '/');
     $this->response = new Sabre_HTTP_ResponseMock();
     $this->server->httpResponse = $this->response;
 }
Example #2
0
 /**
  * @depends testSetup
  */
 function testPut()
 {
     $children = $this->calendar->getChildren();
     $this->assertTrue($children[0] instanceof Sabre_CalDAV_CalendarObject);
     $newData = Sabre_CalDAV_TestUtil::getTestCalendarData();
     $children[0]->put($newData);
     $this->assertEquals($newData, $children[0]->get());
 }
 /**
  * @depends testSetup
  */
 function testPutStream()
 {
     $children = $this->calendar->getChildren();
     $this->assertTrue($children[0] instanceof Sabre_CalDAV_CalendarObject);
     $newData = Sabre_CalDAV_TestUtil::getTestCalendarData();
     $stream = fopen('php://temp', 'r+');
     fwrite($stream, $newData);
     rewind($stream);
     $children[0]->put($stream);
     $this->assertEquals($newData, $children[0]->get());
 }
Example #4
0
 function testCreateFile()
 {
     $file = fopen('php://memory', 'r+');
     fwrite($file, Sabre_CalDAV_TestUtil::getTestCalendarData());
     rewind($file);
     $this->calendar->createFile('hello', $file);
     $file = $this->calendar->getChild('hello');
     $this->assertTrue($file instanceof Sabre_CalDAV_CalendarObject);
 }
 function testCreateFileNoSupportedComponents()
 {
     $file = fopen('php://memory', 'r+');
     fwrite($file, Sabre_CalDAV_TestUtil::getTestCalendarData());
     rewind($file);
     $calendar = new Sabre_CalDAV_Calendar($this->principalBackend, $this->backend, $this->calendars[1]);
     $calendar->createFile('hello', $file);
     $file = $calendar->getChild('hello');
     $this->assertTrue($file instanceof Sabre_CalDAV_CalendarObject);
 }
 /**
  * @depends testParamFilter
  */
 function testUndefinedNegation()
 {
     $calendarPlugin = new Sabre_CalDAV_Plugin(Sabre_CalDAV_Util::getBackend());
     $filters = array('/c:iCalendar/c:vcalendar' => array(), '/c:iCalendar/c:vcalendar/c:vtodo' => array(), '/c:iCalendar/c:vcalendar/c:vtodo/c:completed' => array('is-not-defined' => true), '/c:iCalendar/c:vcalendar/c:vtodo/c:status' => array('text-match' => array('collation' => 'i;ascii-casemap', 'negate-condition' => true, 'value' => 'CANCELLED')));
     $this->assertFalse($calendarPlugin->validateFilters(Sabre_CalDAV_TestUtil::getTestCalendarData(), $filters));
     $this->assertTrue($calendarPlugin->validateFilters(Sabre_CalDAV_TestUtil::getTestTodo(), $filters));
 }