function setup() { if (!SABRE_HASSQLITE) { $this->markTestSkipped('SQLite driver is not available'); } $this->backend = TestUtil::getBackend(); $this->usercalendars = new CalendarHome($this->backend, ['uri' => 'principals/user1']); }
function setup() { if (!SABRE_HASSQLITE) { $this->markTestSkipped('SQLite driver is not available'); } $this->backend = TestUtil::getBackend(); $calendars = $this->backend->getCalendarsForUser('principals/user1'); $this->assertEquals(2, count($calendars)); $this->calendar = new Calendar($this->backend, $calendars[0]); }
function setup() { $this->backend = TestUtil::getBackend(); $this->usercalendars = new CalendarHome($this->backend, ['uri' => 'principals/user1']); }
function testNegotiateDefault() { $cbackend = TestUtil::getBackend(); $pbackend = new DAVACL\PrincipalBackend\Mock(); $props = array('uri' => 'UUID-123467', 'principaluri' => 'admin', 'id' => 1); $tree = array(new Calendar($cbackend, $props), new DAVACL\PrincipalCollection($pbackend)); $p = new ICSExportPlugin(); $s = new DAV\Server($tree); $s->sapi = new HTTP\SapiMock(); $s->addPlugin($p); $s->addPlugin(new Plugin()); $h = HTTP\Sapi::createFromServerArray(['REQUEST_URI' => '/UUID-123467?export', 'REQUEST_METHOD' => 'GET', 'HTTP_ACCEPT' => 'text/plain']); $s->httpRequest = $h; $s->httpResponse = new HTTP\ResponseMock(); $s->exec(); $this->assertEquals(200, $s->httpResponse->status, 'Invalid status received. Response body: ' . $s->httpResponse->body); $this->assertEquals('text/calendar', $s->httpResponse->getHeader('Content-Type')); }
function testACLIntegrationNotBlocked() { if (!SABRE_HASSQLITE) { $this->markTestSkipped('SQLite driver is not available'); } $cbackend = TestUtil::getBackend(); $pbackend = new DAVACL\PrincipalBackend\Mock(); $props = array('uri' => 'UUID-123467', 'principaluri' => 'admin', 'id' => 1); $tree = array(new Calendar($cbackend, $props), new DAVACL\PrincipalCollection($pbackend)); $p = new ICSExportPlugin(); $s = new DAV\Server($tree); $s->addPlugin($p); $s->addPlugin(new Plugin()); $s->addPlugin(new DAVACL\Plugin()); $s->addPlugin(new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock(), 'SabreDAV')); // Forcing login $s->getPlugin('acl')->adminPrincipals = array('principals/admin'); $h = new HTTP\Request(array('QUERY_STRING' => 'export', 'REQUEST_URI' => '/UUID-123467', 'REQUEST_METHOD' => 'GET')); $s->httpRequest = $h; $s->httpResponse = new HTTP\ResponseMock(); $s->exec(); $this->assertEquals('HTTP/1.1 200 OK', $s->httpResponse->status, 'Invalid status received. Response body: ' . $s->httpResponse->body); $this->assertEquals(array('Content-Type' => 'text/calendar'), $s->httpResponse->headers); $obj = VObject\Reader::read($s->httpResponse->body); $this->assertEquals(5, count($obj->children())); $this->assertEquals(1, count($obj->VERSION)); $this->assertEquals(1, count($obj->CALSCALE)); $this->assertEquals(1, count($obj->PRODID)); $this->assertEquals(1, count($obj->VTIMEZONE)); $this->assertEquals(1, count($obj->VEVENT)); }
function testFilterComponentBadComponent() { $cbackend = TestUtil::getBackend(); $pbackend = new DAVACL\PrincipalBackend\Mock(); $props = ['uri' => 'UUID-123467', 'principaluri' => 'admin', 'id' => 1]; // add a todo to the calendar (see /tests/Sabre/TestUtil) $cbackend->createCalendarObject(1, 'UUID-3456', TestUtil::getTestTODO()); $tree = [new Calendar($cbackend, $props), new DAVACL\PrincipalCollection($pbackend)]; $p = new ICSExportPlugin(); $s = new DAV\Server($tree); $s->sapi = new HTTP\SapiMock(); $s->addPlugin($p); $s->addPlugin(new Plugin()); $h = HTTP\Sapi::createFromServerArray(['REQUEST_URI' => '/UUID-123467?export&componentType=VVOODOO', 'REQUEST_METHOD' => 'GET']); $s->httpRequest = $h; $s->httpResponse = new HTTP\ResponseMock(); $s->exec(); $this->assertEquals(400, $s->httpResponse->status, 'Invalid status received. Response body: ' . $s->httpResponse->body); }