Second part of refactoring; should be runnable again, yet not thoroughly tested

This commit is contained in:
Tobias Hößl 2012-08-11 08:07:19 +00:00
parent b8234a1cb8
commit 6186153f68
88 changed files with 2135 additions and 1186 deletions

View file

@ -1,5 +1,7 @@
<?php
use Sabre\VObject;
class Sabre_CalDAV_CalendarQueryVAlarmTest extends PHPUnit_Framework_TestCase {
/**
@ -8,16 +10,16 @@ class Sabre_CalDAV_CalendarQueryVAlarmTest extends PHPUnit_Framework_TestCase {
*/
function testValarm() {
$vevent = Sabre_VObject_Component::create('VEVENT');
$vevent = VObject\Component::create('VEVENT');
$vevent->RRULE = 'FREQ=MONTHLY';
$vevent->DTSTART = '20120101T120000Z';
$vevent->UID = 'bla';
$valarm = Sabre_VObject_Component::create('VALARM');
$valarm = VObject\Component::create('VALARM');
$valarm->TRIGGER = '-P15D';
$vevent->add($valarm);
$vcalendar = Sabre_VObject_Component::create('VCALENDAR');
$vcalendar = VObject\Component::create('VCALENDAR');
$vcalendar->add($vevent);
$filter = array(
@ -52,16 +54,16 @@ class Sabre_CalDAV_CalendarQueryVAlarmTest extends PHPUnit_Framework_TestCase {
// A limited recurrence rule, should return false
$vevent = Sabre_VObject_Component::create('VEVENT');
$vevent = VObject\Component::create('VEVENT');
$vevent->RRULE = 'FREQ=MONTHLY;COUNT=1';
$vevent->DTSTART = '20120101T120000Z';
$vevent->UID = 'bla';
$valarm = Sabre_VObject_Component::create('VALARM');
$valarm = VObject\Component::create('VALARM');
$valarm->TRIGGER = '-P15D';
$vevent->add($valarm);
$vcalendar = Sabre_VObject_Component::create('VCALENDAR');
$vcalendar = VObject\Component::create('VCALENDAR');
$vcalendar->add($vevent);
$this->assertFalse($validator->validate($vcalendar, $filter));
@ -69,15 +71,15 @@ class Sabre_CalDAV_CalendarQueryVAlarmTest extends PHPUnit_Framework_TestCase {
function testAlarmWayBefore() {
$vevent = Sabre_VObject_Component::create('VEVENT');
$vevent = VObject\Component::create('VEVENT');
$vevent->DTSTART = '20120101T120000Z';
$vevent->UID = 'bla';
$valarm = Sabre_VObject_Component::create('VALARM');
$valarm = VObject\Component::create('VALARM');
$valarm->TRIGGER = '-P2W1D';
$vevent->add($valarm);
$vcalendar = Sabre_VObject_Component::create('VCALENDAR');
$vcalendar = VObject\Component::create('VCALENDAR');
$vcalendar->add($vevent);
$filter = array(

View file

@ -1,5 +1,7 @@
<?php
use Sabre\VObject;
class Sabre_CalDAV_CalendarQueryValidatorTest extends PHPUnit_Framework_TestCase {
/**
@ -19,7 +21,7 @@ class Sabre_CalDAV_CalendarQueryValidatorTest extends PHPUnit_Framework_TestCase
'time-range' => null,
);
$vObject = Sabre_VObject_Reader::read($icalObject);
$vObject = VObject\Reader::read($icalObject);
switch($outcome) {
case 0 :
@ -31,7 +33,7 @@ class Sabre_CalDAV_CalendarQueryValidatorTest extends PHPUnit_Framework_TestCase
case -1 :
try {
$validator->validate($vObject, $filters);
} catch (Sabre_DAV_Exception $e) {
} catch (Exception $e) {
// Success
}
break;

View file

@ -1,5 +1,7 @@
<?php
use Sabre\VObject;
/**
* This unittests is created to find out why recurring events have wrong DTSTART value
*
@ -83,13 +85,13 @@ END:VCALENDAR
);
$body = str_replace('&#13;','',$body);
$vObject = Sabre_VObject_Reader::read($body);
$vObject = VObject\Reader::read($body);
// check if DTSTARTs and DTENDs are correct
foreach ($vObject->VEVENT as $vevent) {
/** @var $vevent Sabre_VObject_Component_VEvent */
/** @var $vevent Sabre\VObject\Component_VEvent */
foreach ($vevent->children as $child) {
/** @var $child Sabre_VObject_Property */
/** @var $child Sabre\VObject\Property */
if ($child->name == 'DTSTART') {
// DTSTART has to be one of three valid values

View file

@ -1,5 +1,7 @@
<?php
use Sabre\VObject;
/**
* This unittests is created to find out why recurring events have wrong DTSTART value
*
@ -75,15 +77,15 @@ END:VCALENDAR
);
$body = str_replace('&#13;','',$body);
$vObject = Sabre_VObject_Reader::read($body);
$vObject = VObject\Reader::read($body);
$this->assertEquals(2, count($vObject->VEVENT));
// check if DTSTARTs and DTENDs are correct
foreach ($vObject->VEVENT as $vevent) {
/** @var $vevent Sabre_VObject_Component_VEvent */
/** @var $vevent Sabre\VObject\Component\VEvent */
foreach ($vevent->children as $child) {
/** @var $child Sabre_VObject_Property */
/** @var $child Sabre\VObject\Property */
if ($child->name == 'DTSTART') {
// DTSTART has to be one of two valid values

View file

@ -1,5 +1,7 @@
<?php
use Sabre\VObject;
/**
* This unittests is created to find out why certain events show up twice.
*
@ -85,7 +87,7 @@ END:VCALENDAR
);
$body = str_replace('&#13;','',$body);
$vObject = Sabre_VObject_Reader::read($body);
$vObject = VObject\Reader::read($body);
// We only expect 3 events
$this->assertEquals(3, count($vObject->VEVENT),'We got 6 events instead of 3. Output: ' . $body);

View file

@ -1,5 +1,7 @@
<?php
use Sabre\VObject;
/**
* This unittest is created to check if queries for time-range include the start timestamp or not
*
@ -82,7 +84,7 @@ END:VCALENDAR
);
$body = str_replace('&#13;','',$body);
$vObject = Sabre_VObject_Reader::read($body);
$vObject = VObject\Reader::read($body);
// We expect 1 event
$this->assertEquals(1, count($vObject->VEVENT), 'We got 0 events instead of 1. Output: ' . $body);

View file

@ -1,5 +1,7 @@
<?php
use Sabre\VObject;
require_once 'Sabre/CalDAV/TestUtil.php';
require_once 'Sabre/DAV/Auth/MockBackend.php';
require_once 'Sabre/HTTP/ResponseMock.php';
@ -49,7 +51,7 @@ class Sabre_CalDAV_ICSExportPluginTest extends PHPUnit_Framework_TestCase {
'Content-Type' => 'text/calendar',
), $s->httpResponse->headers);
$obj = Sabre_VObject_Reader::read($s->httpResponse->body);
$obj = VObject\Reader::read($s->httpResponse->body);
$this->assertEquals(5,count($obj->children()));
$this->assertEquals(1,count($obj->VERSION));
@ -98,7 +100,7 @@ class Sabre_CalDAV_ICSExportPluginTest extends PHPUnit_Framework_TestCase {
'Content-Type' => 'text/calendar',
), $s->httpResponse->headers);
$obj = Sabre_VObject_Reader::read($s->httpResponse->body);
$obj = VObject\Reader::read($s->httpResponse->body);
$this->assertEquals(5,count($obj->children()));
$this->assertEquals(1,count($obj->VERSION));
@ -211,7 +213,7 @@ class Sabre_CalDAV_ICSExportPluginTest extends PHPUnit_Framework_TestCase {
'Content-Type' => 'text/calendar',
), $s->httpResponse->headers);
$obj = Sabre_VObject_Reader::read($s->httpResponse->body);
$obj = VObject\Reader::read($s->httpResponse->body);
$this->assertEquals(5,count($obj->children()));
$this->assertEquals(1,count($obj->VERSION));

View file

@ -1,5 +1,7 @@
<?php
use Sabre\VObject;
class Sabre_CalDAV_Issue166Test extends PHPUnit_Framework_TestCase {
function testFlaw() {
@ -51,7 +53,7 @@ HI;
'is-not-defined' => false,
'time-range' => null,
);
$input = Sabre_VObject_Reader::read($input);
$input = VObject\Reader::read($input);
$this->assertTrue($validator->validate($input,$filters));
}

View file

@ -1,5 +1,7 @@
<?php
use Sabre\VObject;
class Sabre_CalDAV_Issue172Test extends PHPUnit_Framework_TestCase {
// DateTimeZone() native name: America/Los_Angeles (GMT-8 in January)
@ -30,7 +32,7 @@ HI;
),
'prop-filters' => array(),
);
$input = Sabre_VObject_Reader::read($input);
$input = VObject\Reader::read($input);
$this->assertTrue($validator->validate($input,$filters));
}
@ -77,7 +79,7 @@ HI;
),
'prop-filters' => array(),
);
$input = Sabre_VObject_Reader::read($input);
$input = VObject\Reader::read($input);
$this->assertTrue($validator->validate($input,$filters));
}
@ -125,7 +127,7 @@ HI;
),
'prop-filters' => array(),
);
$input = Sabre_VObject_Reader::read($input);
$input = VObject\Reader::read($input);
$this->assertTrue($validator->validate($input,$filters));
}
}

View file

@ -1,5 +1,7 @@
<?php
use Sabre\VObject;
/**
* This unittest is created to find out why an overwritten DAILY event has wrong DTSTART, DTEND, SUMMARY and RECURRENCEID
*
@ -88,7 +90,7 @@ END:VCALENDAR
);
$body = str_replace('&#13;','',$body);
$vObject = Sabre_VObject_Reader::read($body);
$vObject = VObject\Reader::read($body);
$this->assertEquals(2, count($vObject->VEVENT));
@ -113,10 +115,10 @@ END:VCALENDAR
$matching = false;
foreach ($vObject->VEVENT as $vevent) {
/** @var $vevent Sabre_VObject_Component_VEvent */
/** @var $vevent Sabre\VObject\Component\VEvent */
foreach ($vevent->children as $child) {
/** @var $child Sabre_VObject_Property */
/** @var $child Sabre\VObject\Property */
if (isset($expectedEvent[$child->name])) {
if ($expectedEvent[$child->name] != $child->value) {

View file

@ -1,5 +1,7 @@
<?php
use Sabre\VObject;
/**
* This unittest is created to check if a VALARM TRIGGER of PT0S is supported
*
@ -86,7 +88,7 @@ END:VCALENDAR
);
$body = str_replace('&#13;','',$body);
$vObject = Sabre_VObject_Reader::read($body);
$vObject = VObject\Reader::read($body);
$this->assertEquals(1, count($vObject->VEVENT));

View file

@ -0,0 +1,75 @@
<?php
/**
* This unittest is created to check if the time-range filter is working correctly with all-day-events
*
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
* @author Evert Pot (http://www.rooftopsolutions.nl/)
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
*/
class Sabre_CalDAV_Issue228Test extends Sabre_DAVServerTest {
protected $setupCalDAV = true;
protected $caldavCalendars = array(
array(
'id' => 1,
'name' => 'Calendar',
'principaluri' => 'principals/user1',
'uri' => 'calendar1',
)
);
protected $caldavCalendarObjects = array(
1 => array(
'event.ics' => array(
'calendardata' => 'BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
UID:20120730T113415CEST-6804EGphkd@xxxxxx.de
DTSTAMP:20120730T093415Z
DTSTART;VALUE=DATE:20120729
DTEND;VALUE=DATE:20120730
SUMMARY:sunday event
TRANSP:TRANSPARENT
END:VEVENT
END:VCALENDAR
',
),
),
);
function testIssue228() {
$request = new Sabre_HTTP_Request(array(
'REQUEST_METHOD' => 'REPORT',
'HTTP_CONTENT_TYPE' => 'application/xml',
'REQUEST_URI' => '/calendars/user1/calendar1',
'HTTP_DEPTH' => '1',
));
$request->setBody('<?xml version="1.0" encoding="utf-8" ?>
<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
<D:prop>
<C:calendar-data>
<C:expand start="20120730T095609Z"
end="20120813T095609Z"/>
</C:calendar-data>
<D:getetag/>
</D:prop>
<C:filter>
<C:comp-filter name="VCALENDAR">
<C:comp-filter name="VEVENT">
<C:time-range start="20120730T095609Z" end="20120813T095609Z"/>
</C:comp-filter>
</C:comp-filter>
</C:filter>
</C:calendar-query>');
$response = $this->request($request);
// We must check if absolutely nothing was returned from this query.
$this->assertFalse(strpos($response->body, 'BEGIN:VCALENDAR'));
}
}