예제 #1
0
 function setup()
 {
     $this->caldavBackend = new 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 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 Property\SupportedCalendarComponentSet(array('VEVENT', 'VTODO')))), array(1 => array('UUID-2345' => array('calendardata' => TestUtil::getTestCalendarData()))));
     $principalBackend = new DAVACL\PrincipalBackend\Mock();
     $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 CalendarRootNode($principalBackend, $this->caldavBackend);
     $principals = new Principal\Collection($principalBackend);
     $root = new DAV\SimpleCollection('root');
     $root->addChild($calendars);
     $root->addChild($principals);
     $objectTree = new DAV\ObjectTree($root);
     $this->server = new DAV\Server($objectTree);
     $this->server->debugExceptions = true;
     $this->server->setBaseUri('/');
     $this->plugin = new Plugin();
     $this->server->addPlugin($this->plugin);
     // Adding ACL plugin
     $this->server->addPlugin(new DAVACL\Plugin());
     // Adding Auth plugin, and ensuring that we are logged in.
     $authBackend = new DAV\Auth\Backend\Mock();
     $authBackend->defaultUser = '******';
     $authPlugin = new DAV\Auth\Plugin($authBackend, 'SabreDAV');
     $this->server->addPlugin($authPlugin);
     $authPlugin->beforeMethod('GET', '/');
     $this->response = new HTTP\ResponseMock();
     $this->server->httpResponse = $this->response;
 }
예제 #2
0
 /**
  * @depends testSetup
  */
 function testPutStream()
 {
     $children = $this->calendar->getChildren();
     $this->assertTrue($children[0] instanceof CalendarObject);
     $newData = TestUtil::getTestCalendarData();
     $stream = fopen('php://temp', 'r+');
     fwrite($stream, $newData);
     rewind($stream);
     $children[0]->put($stream);
     $this->assertEquals($newData, $children[0]->get());
 }
예제 #3
0
    /**
     * @depends testSupportedReportSetProperty
     * @depends testCalendarMultiGetReport
     */
    function testCalendarQueryReport1Object()
    {
        $body = '<?xml version="1.0"?>' . '<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">' . '<d:prop>' . '  <c:calendar-data>' . '     <c:expand start="20000101T000000Z" end="20101231T235959Z" />' . '  </c:calendar-data>' . '  <d:getetag />' . '</d:prop>' . '<c:filter>' . '  <c:comp-filter name="VCALENDAR">' . '    <c:comp-filter name="VEVENT" />' . '  </c:comp-filter>' . '</c:filter>' . '</c:calendar-query>';
        $request = new HTTP\Request('REPORT', '/calendars/user1/UUID-123467/UUID-2345', ['Depth' => '0']);
        $request->setBody($body);
        $this->server->httpRequest = $request;
        $this->server->exec();
        $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: ' . $this->response->body);
        $expectedIcal = TestUtil::getTestCalendarData();
        $expectedIcal = \Sabre\VObject\Reader::read($expectedIcal);
        $expectedIcal = $expectedIcal->expand(new DateTime('2000-01-01 00:00:00', new DateTimeZone('UTC')), new DateTime('2010-12-31 23:59:59', new DateTimeZone('UTC')));
        $expectedIcal = str_replace("\r\n", "&#xD;\n", $expectedIcal->serialize());
        $expected = <<<XML
<?xml version="1.0"?>
<d:multistatus xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
<d:response>
  <d:href>/calendars/user1/UUID-123467/UUID-2345</d:href>
  <d:propstat>
    <d:prop>
      <cal:calendar-data>{$expectedIcal}</cal:calendar-data>
      <d:getetag>"e207e33c10e5fb9c12cfb35b5d9116e1"</d:getetag>
    </d:prop>
    <d:status>HTTP/1.1 200 OK</d:status>
  </d:propstat>
</d:response>
</d:multistatus>
XML;
        $this->assertXmlStringEqualsXmlString($expected, $this->response->getBodyAsString());
    }
예제 #4
0
 function testCreateFileNoSupportedComponents()
 {
     $file = fopen('php://memory', 'r+');
     fwrite($file, TestUtil::getTestCalendarData());
     rewind($file);
     $calendar = new Calendar($this->backend, $this->calendars[1]);
     $calendar->createFile('hello', $file);
     $file = $calendar->getChild('hello');
     $this->assertTrue($file instanceof CalendarObject);
 }