diff options
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/CalDAV')
34 files changed, 0 insertions, 7605 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractPDOTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractPDOTest.php deleted file mode 100644 index 9460b8922..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractPDOTest.php +++ /dev/null @@ -1,1397 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV\Backend; - -use Sabre\CalDAV; -use Sabre\DAV; -use Sabre\DAV\PropPatch; -use Sabre\DAV\Xml\Element\Sharee; - -abstract class AbstractPDOTest extends \PHPUnit\Framework\TestCase -{ - use DAV\DbTestHelperTrait; - - protected $pdo; - - public function setup(): void - { - $this->dropTables([ - 'calendarobjects', - 'calendars', - 'calendarinstances', - 'calendarchanges', - 'calendarsubscriptions', - 'schedulingobjects', - ]); - $this->createSchema('calendars'); - - $this->pdo = $this->getDb(); - } - - public function testConstruct() - { - $backend = new PDO($this->pdo); - $this->assertTrue($backend instanceof PDO); - } - - /** - * @depends testConstruct - */ - public function testGetCalendarsForUserNoCalendars() - { - $backend = new PDO($this->pdo); - $calendars = $backend->getCalendarsForUser('principals/user2'); - $this->assertEquals([], $calendars); - } - - /** - * @depends testConstruct - */ - public function testCreateCalendarAndFetch() - { - $backend = new PDO($this->pdo); - $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', [ - '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet(['VEVENT']), - '{DAV:}displayname' => 'Hello!', - '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' => new CalDAV\Xml\Property\ScheduleCalendarTransp('transparent'), - ]); - $calendars = $backend->getCalendarsForUser('principals/user2'); - - $elementCheck = [ - 'uri' => 'somerandomid', - '{DAV:}displayname' => 'Hello!', - '{urn:ietf:params:xml:ns:caldav}calendar-description' => '', - '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' => new CalDAV\Xml\Property\ScheduleCalendarTransp('transparent'), - 'share-access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, - ]; - - $this->assertIsArray($calendars); - $this->assertEquals(1, count($calendars)); - - foreach ($elementCheck as $name => $value) { - $this->assertArrayHasKey($name, $calendars[0]); - $this->assertEquals($value, $calendars[0][$name]); - } - } - - /** - * @depends testConstruct - */ - public function testUpdateCalendarAndFetch() - { - $backend = new PDO($this->pdo); - - //Creating a new calendar - $newId = $backend->createCalendar('principals/user2', 'somerandomid', []); - - $propPatch = new PropPatch([ - '{DAV:}displayname' => 'myCalendar', - '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' => new CalDAV\Xml\Property\ScheduleCalendarTransp('transparent'), - ]); - - // Updating the calendar - $backend->updateCalendar($newId, $propPatch); - $result = $propPatch->commit(); - - // Verifying the result of the update - $this->assertTrue($result); - - // Fetching all calendars from this user - $calendars = $backend->getCalendarsForUser('principals/user2'); - - // Checking if all the information is still correct - $elementCheck = [ - 'id' => $newId, - 'uri' => 'somerandomid', - '{DAV:}displayname' => 'myCalendar', - '{urn:ietf:params:xml:ns:caldav}calendar-description' => '', - '{urn:ietf:params:xml:ns:caldav}calendar-timezone' => '', - '{http://calendarserver.org/ns/}getctag' => 'http://sabre.io/ns/sync/2', - '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' => new CalDAV\Xml\Property\ScheduleCalendarTransp('transparent'), - ]; - - $this->assertIsArray($calendars); - $this->assertEquals(1, count($calendars)); - - foreach ($elementCheck as $name => $value) { - $this->assertArrayHasKey($name, $calendars[0]); - $this->assertEquals($value, $calendars[0][$name]); - } - } - - /** - * @depends testConstruct - */ - public function testUpdateCalendarBadId() - { - $this->expectException('InvalidArgumentException'); - $backend = new PDO($this->pdo); - - //Creating a new calendar - $newId = $backend->createCalendar('principals/user2', 'somerandomid', []); - - $propPatch = new PropPatch([ - '{DAV:}displayname' => 'myCalendar', - '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp' => new CalDAV\Xml\Property\ScheduleCalendarTransp('transparent'), - ]); - - // Updating the calendar - $backend->updateCalendar('raaaa', $propPatch); - } - - /** - * @depends testUpdateCalendarAndFetch - */ - public function testUpdateCalendarUnknownProperty() - { - $backend = new PDO($this->pdo); - - //Creating a new calendar - $newId = $backend->createCalendar('principals/user2', 'somerandomid', []); - - $propPatch = new PropPatch([ - '{DAV:}displayname' => 'myCalendar', - '{DAV:}yourmom' => 'wittycomment', - ]); - - // Updating the calendar - $backend->updateCalendar($newId, $propPatch); - $propPatch->commit(); - - // Verifying the result of the update - $this->assertEquals([ - '{DAV:}yourmom' => 403, - '{DAV:}displayname' => 424, - ], $propPatch->getResult()); - } - - /** - * @depends testCreateCalendarAndFetch - */ - public function testDeleteCalendar() - { - $backend = new PDO($this->pdo); - $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', [ - '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet(['VEVENT']), - '{DAV:}displayname' => 'Hello!', - ]); - - $backend->deleteCalendar($returnedId); - - $calendars = $backend->getCalendarsForUser('principals/user2'); - $this->assertEquals([], $calendars); - } - - /** - * @depends testCreateCalendarAndFetch - */ - public function testDeleteCalendarBadID() - { - $this->expectException('InvalidArgumentException'); - $backend = new PDO($this->pdo); - $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', [ - '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet(['VEVENT']), - '{DAV:}displayname' => 'Hello!', - ]); - - $backend->deleteCalendar('bad-id'); - } - - /** - * @depends testCreateCalendarAndFetch - */ - public function testCreateCalendarIncorrectComponentSet() - { - $this->expectException('Sabre\DAV\Exception'); - $backend = new PDO($this->pdo); - - //Creating a new calendar - $newId = $backend->createCalendar('principals/user2', 'somerandomid', [ - '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => 'blabla', - ]); - } - - public function testCreateCalendarObject() - { - $backend = new PDO($this->pdo); - $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); - - $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"; - - $backend->createCalendarObject($returnedId, 'random-id', $object); - - $result = $this->pdo->query('SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = \'random-id\''); - - $row = $result->fetch(\PDO::FETCH_ASSOC); - if (is_resource($row['calendardata'])) { - $row['calendardata'] = stream_get_contents($row['calendardata']); - } - - $this->assertEquals([ - 'etag' => md5($object), - 'size' => strlen($object), - 'calendardata' => $object, - 'firstoccurence' => strtotime('20120101'), - 'lastoccurence' => strtotime('20120101') + (3600 * 24), - 'componenttype' => 'VEVENT', - ], $row); - } - - public function testGetMultipleObjects() - { - $backend = new PDO($this->pdo); - $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); - - $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"; - - $backend->createCalendarObject($returnedId, 'id-1', $object); - $backend->createCalendarObject($returnedId, 'id-2', $object); - - $check = [ - [ - 'id' => 1, - 'etag' => '"'.md5($object).'"', - 'uri' => 'id-1', - 'size' => strlen($object), - 'calendardata' => $object, - 'lastmodified' => null, - ], - [ - 'id' => 2, - 'etag' => '"'.md5($object).'"', - 'uri' => 'id-2', - 'size' => strlen($object), - 'calendardata' => $object, - 'lastmodified' => null, - ], - ]; - - $result = $backend->getMultipleCalendarObjects($returnedId, ['id-1', 'id-2']); - - foreach ($check as $index => $props) { - foreach ($props as $key => $expected) { - $actual = $result[$index][$key]; - - switch ($key) { - case 'lastmodified': - $this->assertIsInt($actual); - break; - case 'calendardata': - if (is_resource($actual)) { - $actual = stream_get_contents($actual); - } - // no break intentional - default: - $this->assertEquals($expected, $actual); - } - } - } - } - - /** - * @depends testGetMultipleObjects - */ - public function testGetMultipleObjectsBadId() - { - $this->expectException('InvalidArgumentException'); - $backend = new PDO($this->pdo); - $backend->getMultipleCalendarObjects('bad-id', ['foo-bar']); - } - - /** - * @depends testCreateCalendarObject - */ - public function testCreateCalendarObjectNoComponent() - { - $this->expectException('Sabre\DAV\Exception\BadRequest'); - $backend = new PDO($this->pdo); - $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); - - $object = "BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nEND:VTIMEZONE\r\nEND:VCALENDAR\r\n"; - - $backend->createCalendarObject($returnedId, 'random-id', $object); - } - - /** - * @depends testCreateCalendarObject - */ - public function testCreateCalendarObjectDuration() - { - $backend = new PDO($this->pdo); - $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); - - $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nDURATION:P2D\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"; - - $backend->createCalendarObject($returnedId, 'random-id', $object); - - $result = $this->pdo->query('SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = \'random-id\''); - - $row = $result->fetch(\PDO::FETCH_ASSOC); - if (is_resource($row['calendardata'])) { - $row['calendardata'] = stream_get_contents($row['calendardata']); - } - - $this->assertEquals([ - 'etag' => md5($object), - 'size' => strlen($object), - 'calendardata' => $object, - 'firstoccurence' => strtotime('20120101'), - 'lastoccurence' => strtotime('20120101') + (3600 * 48), - 'componenttype' => 'VEVENT', - ], $row); - } - - /** - * @depends testCreateCalendarObject - */ - public function testCreateCalendarObjectBadId() - { - $this->expectException('InvalidArgumentException'); - $backend = new PDO($this->pdo); - $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); - - $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nDURATION:P2D\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"; - - $backend->createCalendarObject('bad-id', 'random-id', $object); - } - - /** - * @depends testCreateCalendarObject - */ - public function testCreateCalendarObjectNoDTEND() - { - $backend = new PDO($this->pdo); - $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); - - $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE-TIME:20120101T100000Z\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"; - - $backend->createCalendarObject($returnedId, 'random-id', $object); - - $result = $this->pdo->query('SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = \'random-id\''); - $row = $result->fetch(\PDO::FETCH_ASSOC); - if (is_resource($row['calendardata'])) { - $row['calendardata'] = stream_get_contents($row['calendardata']); - } - - $this->assertEquals([ - 'etag' => md5($object), - 'size' => strlen($object), - 'calendardata' => $object, - 'firstoccurence' => strtotime('2012-01-01 10:00:00'), - 'lastoccurence' => strtotime('2012-01-01 10:00:00'), - 'componenttype' => 'VEVENT', - ], $row); - } - - /** - * @depends testCreateCalendarObject - */ - public function testCreateCalendarObjectWithDTEND() - { - $backend = new PDO($this->pdo); - $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); - - $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE-TIME:20120101T100000Z\r\nDTEND:20120101T110000Z\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"; - - $backend->createCalendarObject($returnedId, 'random-id', $object); - - $result = $this->pdo->query('SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = \'random-id\''); - $row = $result->fetch(\PDO::FETCH_ASSOC); - if (is_resource($row['calendardata'])) { - $row['calendardata'] = stream_get_contents($row['calendardata']); - } - - $this->assertEquals([ - 'etag' => md5($object), - 'size' => strlen($object), - 'calendardata' => $object, - 'firstoccurence' => strtotime('2012-01-01 10:00:00'), - 'lastoccurence' => strtotime('2012-01-01 11:00:00'), - 'componenttype' => 'VEVENT', - ], $row); - } - - /** - * @depends testCreateCalendarObject - */ - public function testCreateCalendarObjectInfiniteRecurrence() - { - $backend = new PDO($this->pdo); - $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); - - $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE-TIME:20120101T100000Z\r\nRRULE:FREQ=DAILY\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"; - - $backend->createCalendarObject($returnedId, 'random-id', $object); - - $result = $this->pdo->query('SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = \'random-id\''); - $row = $result->fetch(\PDO::FETCH_ASSOC); - if (is_resource($row['calendardata'])) { - $row['calendardata'] = stream_get_contents($row['calendardata']); - } - - $this->assertEquals([ - 'etag' => md5($object), - 'size' => strlen($object), - 'calendardata' => $object, - 'firstoccurence' => strtotime('2012-01-01 10:00:00'), - 'lastoccurence' => strtotime(PDO::MAX_DATE), - 'componenttype' => 'VEVENT', - ], $row); - } - - /** - * @depends testCreateCalendarObject - */ - public function testCreateCalendarObjectEndingRecurrence() - { - $backend = new PDO($this->pdo); - $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); - - $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE-TIME:20120101T100000Z\r\nDTEND;VALUE=DATE-TIME:20120101T110000Z\r\nUID:foo\r\nRRULE:FREQ=DAILY;COUNT=1000\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"; - - $backend->createCalendarObject($returnedId, 'random-id', $object); - - $result = $this->pdo->query('SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = \'random-id\''); - $row = $result->fetch(\PDO::FETCH_ASSOC); - if (is_resource($row['calendardata'])) { - $row['calendardata'] = stream_get_contents($row['calendardata']); - } - - $this->assertEquals([ - 'etag' => md5($object), - 'size' => strlen($object), - 'calendardata' => $object, - 'firstoccurence' => strtotime('2012-01-01 10:00:00'), - 'lastoccurence' => strtotime('2012-01-01 11:00:00') + (3600 * 24 * 999), - 'componenttype' => 'VEVENT', - ], $row); - } - - /** - * @depends testCreateCalendarObject - */ - public function testCreateCalendarObjectTask() - { - $backend = new PDO($this->pdo); - $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); - - $object = "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nDUE;VALUE=DATE-TIME:20120101T100000Z\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"; - - $backend->createCalendarObject($returnedId, 'random-id', $object); - - $result = $this->pdo->query('SELECT etag, size, calendardata, firstoccurence, lastoccurence, componenttype FROM calendarobjects WHERE uri = \'random-id\''); - $row = $result->fetch(\PDO::FETCH_ASSOC); - if (is_resource($row['calendardata'])) { - $row['calendardata'] = stream_get_contents($row['calendardata']); - } - - $this->assertEquals([ - 'etag' => md5($object), - 'size' => strlen($object), - 'calendardata' => $object, - 'firstoccurence' => null, - 'lastoccurence' => null, - 'componenttype' => 'VTODO', - ], $row); - } - - /** - * @depends testCreateCalendarObject - */ - public function testGetCalendarObjects() - { - $backend = new PDO($this->pdo); - $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); - - $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"; - $backend->createCalendarObject($returnedId, 'random-id', $object); - - $data = $backend->getCalendarObjects($returnedId); - - $this->assertEquals(1, count($data)); - $data = $data[0]; - - $this->assertEquals('random-id', $data['uri']); - $this->assertEquals(strlen($object), $data['size']); - } - - /** - * @depends testGetCalendarObjects - */ - public function testGetCalendarObjectsBadId() - { - $this->expectException('InvalidArgumentException'); - $backend = new PDO($this->pdo); - $backend->getCalendarObjects('bad-id'); - } - - /** - * @depends testGetCalendarObjects - */ - public function testGetCalendarObjectBadId() - { - $this->expectException('InvalidArgumentException'); - $backend = new PDO($this->pdo); - $backend->getCalendarObject('bad-id', 'foo-bar'); - } - - /** - * @depends testCreateCalendarObject - */ - public function testGetCalendarObjectByUID() - { - $backend = new PDO($this->pdo); - $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); - - $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:foo\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"; - $backend->createCalendarObject($returnedId, 'random-id', $object); - - $this->assertNull( - $backend->getCalendarObjectByUID('principals/user2', 'bar') - ); - $this->assertEquals( - 'somerandomid/random-id', - $backend->getCalendarObjectByUID('principals/user2', 'foo') - ); - } - - /** - * @depends testCreateCalendarObject - */ - public function testUpdateCalendarObject() - { - $backend = new PDO($this->pdo); - $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); - - $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"; - $object2 = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20130101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"; - $backend->createCalendarObject($returnedId, 'random-id', $object); - $backend->updateCalendarObject($returnedId, 'random-id', $object2); - - $data = $backend->getCalendarObject($returnedId, 'random-id'); - - if (is_resource($data['calendardata'])) { - $data['calendardata'] = stream_get_contents($data['calendardata']); - } - - $this->assertEquals($object2, $data['calendardata']); - $this->assertEquals('random-id', $data['uri']); - } - - /** - * @depends testUpdateCalendarObject - */ - public function testUpdateCalendarObjectBadId() - { - $this->expectException('InvalidArgumentException'); - $backend = new PDO($this->pdo); - $backend->updateCalendarObject('bad-id', 'object-id', 'objectdata'); - } - - /** - * @depends testCreateCalendarObject - */ - public function testDeleteCalendarObject() - { - $backend = new PDO($this->pdo); - $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); - - $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"; - $backend->createCalendarObject($returnedId, 'random-id', $object); - $backend->deleteCalendarObject($returnedId, 'random-id'); - - $data = $backend->getCalendarObject($returnedId, 'random-id'); - $this->assertNull($data); - } - - /** - * @depends testDeleteCalendarObject - */ - public function testDeleteCalendarObjectBadId() - { - $this->expectException('InvalidArgumentException'); - $backend = new PDO($this->pdo); - $returnedId = $backend->createCalendar('principals/user2', 'somerandomid', []); - - $object = "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"; - $backend->createCalendarObject($returnedId, 'random-id', $object); - $backend->deleteCalendarObject('bad-id', 'random-id'); - } - - public function testCalendarQueryNoResult() - { - $abstract = new PDO($this->pdo); - $filters = [ - 'name' => 'VCALENDAR', - 'comp-filters' => [ - [ - 'name' => 'VJOURNAL', - 'comp-filters' => [], - 'prop-filters' => [], - 'is-not-defined' => false, - 'time-range' => null, - ], - ], - 'prop-filters' => [], - 'is-not-defined' => false, - 'time-range' => null, - ]; - - $this->assertEquals([ - ], $abstract->calendarQuery([1, 1], $filters)); - } - - /** - * @depends testCalendarQueryNoResult - */ - public function testCalendarQueryBadId() - { - $this->expectException('InvalidArgumentException'); - $abstract = new PDO($this->pdo); - $filters = [ - 'name' => 'VCALENDAR', - 'comp-filters' => [ - [ - 'name' => 'VJOURNAL', - 'comp-filters' => [], - 'prop-filters' => [], - 'is-not-defined' => false, - 'time-range' => null, - ], - ], - 'prop-filters' => [], - 'is-not-defined' => false, - 'time-range' => null, - ]; - - $abstract->calendarQuery('bad-id', $filters); - } - - public function testCalendarQueryTodo() - { - $backend = new PDO($this->pdo); - $backend->createCalendarObject([1, 1], 'todo', "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); - $backend->createCalendarObject([1, 1], 'event', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); - - $filters = [ - 'name' => 'VCALENDAR', - 'comp-filters' => [ - [ - 'name' => 'VTODO', - 'comp-filters' => [], - 'prop-filters' => [], - 'is-not-defined' => false, - 'time-range' => null, - ], - ], - 'prop-filters' => [], - 'is-not-defined' => false, - 'time-range' => null, - ]; - - $this->assertEquals([ - 'todo', - ], $backend->calendarQuery([1, 1], $filters)); - } - - public function testCalendarQueryTodoNotMatch() - { - $backend = new PDO($this->pdo); - $backend->createCalendarObject([1, 1], 'todo', "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); - $backend->createCalendarObject([1, 1], 'event', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); - - $filters = [ - 'name' => 'VCALENDAR', - 'comp-filters' => [ - [ - 'name' => 'VTODO', - 'comp-filters' => [], - 'prop-filters' => [ - [ - 'name' => 'summary', - 'text-match' => null, - 'time-range' => null, - 'param-filters' => [], - 'is-not-defined' => false, - ], - ], - 'is-not-defined' => false, - 'time-range' => null, - ], - ], - 'prop-filters' => [], - 'is-not-defined' => false, - 'time-range' => null, - ]; - - $this->assertEquals([ - ], $backend->calendarQuery([1, 1], $filters)); - } - - public function testCalendarQueryNoFilter() - { - $backend = new PDO($this->pdo); - $backend->createCalendarObject([1, 1], 'todo', "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); - $backend->createCalendarObject([1, 1], 'event', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); - - $filters = [ - 'name' => 'VCALENDAR', - 'comp-filters' => [], - 'prop-filters' => [], - 'is-not-defined' => false, - 'time-range' => null, - ]; - - $result = $backend->calendarQuery([1, 1], $filters); - $this->assertTrue(in_array('todo', $result)); - $this->assertTrue(in_array('event', $result)); - } - - public function testCalendarQueryTimeRange() - { - $backend = new PDO($this->pdo); - $backend->createCalendarObject([1, 1], 'todo', "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); - $backend->createCalendarObject([1, 1], 'event', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); - $backend->createCalendarObject([1, 1], 'event2', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART;VALUE=DATE:20120103\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); - - $filters = [ - 'name' => 'VCALENDAR', - 'comp-filters' => [ - [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], - 'is-not-defined' => false, - 'time-range' => [ - 'start' => new \DateTime('20120103'), - 'end' => new \DateTime('20120104'), - ], - ], - ], - 'prop-filters' => [], - 'is-not-defined' => false, - 'time-range' => null, - ]; - - $this->assertEquals([ - 'event2', - ], $backend->calendarQuery([1, 1], $filters)); - } - - public function testCalendarQueryTimeRangeNoEnd() - { - $backend = new PDO($this->pdo); - $backend->createCalendarObject([1, 1], 'todo', "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"); - $backend->createCalendarObject([1, 1], 'event', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120101\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); - $backend->createCalendarObject([1, 1], 'event2', "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nDTSTART:20120103\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); - - $filters = [ - 'name' => 'VCALENDAR', - 'comp-filters' => [ - [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], - 'is-not-defined' => false, - 'time-range' => [ - 'start' => new \DateTime('20120102'), - 'end' => null, - ], - ], - ], - 'prop-filters' => [], - 'is-not-defined' => false, - 'time-range' => null, - ]; - - $this->assertEquals([ - 'event2', - ], $backend->calendarQuery([1, 1], $filters)); - } - - public function testGetChanges() - { - $backend = new PDO($this->pdo); - $id = $backend->createCalendar( - 'principals/user1', - 'bla', - [] - ); - $result = $backend->getChangesForCalendar($id, null, 1); - - $this->assertEquals([ - 'syncToken' => 1, - 'modified' => [], - 'deleted' => [], - 'added' => [], - ], $result); - - $currentToken = $result['syncToken']; - - $dummyTodo = "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n"; - - $backend->createCalendarObject($id, 'todo1.ics', $dummyTodo); - $backend->createCalendarObject($id, 'todo2.ics', $dummyTodo); - $backend->createCalendarObject($id, 'todo3.ics', $dummyTodo); - $backend->updateCalendarObject($id, 'todo1.ics', $dummyTodo); - $backend->deleteCalendarObject($id, 'todo2.ics'); - - $result = $backend->getChangesForCalendar($id, $currentToken, 1); - - $this->assertEquals([ - 'syncToken' => 6, - 'modified' => ['todo1.ics'], - 'deleted' => ['todo2.ics'], - 'added' => ['todo3.ics'], - ], $result); - - $result = $backend->getChangesForCalendar($id, null, 1); - - $this->assertEquals([ - 'syncToken' => 6, - 'modified' => [], - 'deleted' => [], - 'added' => ['todo1.ics', 'todo3.ics'], - ], $result); - } - - /** - * @depends testGetChanges - */ - public function testGetChangesBadId() - { - $this->expectException('InvalidArgumentException'); - $backend = new PDO($this->pdo); - $id = $backend->createCalendar( - 'principals/user1', - 'bla', - [] - ); - $backend->getChangesForCalendar('bad-id', null, 1); - } - - public function testCreateSubscriptions() - { - $props = [ - '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics', false), - '{DAV:}displayname' => 'cal', - '{http://apple.com/ns/ical/}refreshrate' => 'P1W', - '{http://apple.com/ns/ical/}calendar-color' => '#FF00FFFF', - '{http://calendarserver.org/ns/}subscribed-strip-todos' => true, - //'{http://calendarserver.org/ns/}subscribed-strip-alarms' => true, - '{http://calendarserver.org/ns/}subscribed-strip-attachments' => true, - ]; - - $backend = new PDO($this->pdo); - $backend->createSubscription('principals/user1', 'sub1', $props); - - $subs = $backend->getSubscriptionsForUser('principals/user1'); - - $expected = $props; - $expected['id'] = 1; - $expected['uri'] = 'sub1'; - $expected['principaluri'] = 'principals/user1'; - - unset($expected['{http://calendarserver.org/ns/}source']); - $expected['source'] = 'http://example.org/cal.ics'; - - $this->assertEquals(1, count($subs)); - foreach ($expected as $k => $v) { - $this->assertEquals($subs[0][$k], $expected[$k]); - } - } - - public function testCreateSubscriptionFail() - { - $this->expectException('Sabre\DAV\Exception\Forbidden'); - $props = [ - ]; - - $backend = new PDO($this->pdo); - $backend->createSubscription('principals/user1', 'sub1', $props); - } - - public function testUpdateSubscriptions() - { - $props = [ - '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics', false), - '{DAV:}displayname' => 'cal', - '{http://apple.com/ns/ical/}refreshrate' => 'P1W', - '{http://apple.com/ns/ical/}calendar-color' => '#FF00FFFF', - '{http://calendarserver.org/ns/}subscribed-strip-todos' => true, - //'{http://calendarserver.org/ns/}subscribed-strip-alarms' => true, - '{http://calendarserver.org/ns/}subscribed-strip-attachments' => true, - ]; - - $backend = new PDO($this->pdo); - $backend->createSubscription('principals/user1', 'sub1', $props); - - $newProps = [ - '{DAV:}displayname' => 'new displayname', - '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal2.ics', false), - ]; - - $propPatch = new DAV\PropPatch($newProps); - $backend->updateSubscription(1, $propPatch); - $result = $propPatch->commit(); - - $this->assertTrue($result); - - $subs = $backend->getSubscriptionsForUser('principals/user1'); - - $expected = array_merge($props, $newProps); - $expected['id'] = 1; - $expected['uri'] = 'sub1'; - $expected['principaluri'] = 'principals/user1'; - - unset($expected['{http://calendarserver.org/ns/}source']); - $expected['source'] = 'http://example.org/cal2.ics'; - - $this->assertEquals(1, count($subs)); - foreach ($expected as $k => $v) { - $this->assertEquals($subs[0][$k], $expected[$k]); - } - } - - public function testUpdateSubscriptionsFail() - { - $props = [ - '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics', false), - '{DAV:}displayname' => 'cal', - '{http://apple.com/ns/ical/}refreshrate' => 'P1W', - '{http://apple.com/ns/ical/}calendar-color' => '#FF00FFFF', - '{http://calendarserver.org/ns/}subscribed-strip-todos' => true, - //'{http://calendarserver.org/ns/}subscribed-strip-alarms' => true, - '{http://calendarserver.org/ns/}subscribed-strip-attachments' => true, - ]; - - $backend = new PDO($this->pdo); - $backend->createSubscription('principals/user1', 'sub1', $props); - - $propPatch = new DAV\PropPatch([ - '{DAV:}displayname' => 'new displayname', - '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal2.ics', false), - '{DAV:}unknown' => 'foo', - ]); - - $backend->updateSubscription(1, $propPatch); - $propPatch->commit(); - - $this->assertEquals([ - '{DAV:}unknown' => 403, - '{DAV:}displayname' => 424, - '{http://calendarserver.org/ns/}source' => 424, - ], $propPatch->getResult()); - } - - public function testDeleteSubscriptions() - { - $props = [ - '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal.ics', false), - '{DAV:}displayname' => 'cal', - '{http://apple.com/ns/ical/}refreshrate' => 'P1W', - '{http://apple.com/ns/ical/}calendar-color' => '#FF00FFFF', - '{http://calendarserver.org/ns/}subscribed-strip-todos' => true, - //'{http://calendarserver.org/ns/}subscribed-strip-alarms' => true, - '{http://calendarserver.org/ns/}subscribed-strip-attachments' => true, - ]; - - $backend = new PDO($this->pdo); - $backend->createSubscription('principals/user1', 'sub1', $props); - - $newProps = [ - '{DAV:}displayname' => 'new displayname', - '{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/cal2.ics', false), - ]; - - $backend->deleteSubscription(1); - - $subs = $backend->getSubscriptionsForUser('principals/user1'); - $this->assertEquals(0, count($subs)); - } - - public function testSchedulingMethods() - { - $backend = new PDO($this->pdo); - - $calData = "BEGIN:VCALENDAR\r\nEND:VCALENDAR\r\n"; - - $backend->createSchedulingObject( - 'principals/user1', - 'schedule1.ics', - $calData - ); - - $calDataResource = "BEGIN:VCALENDAR\r\nEND:VCALENDAR\r\n"; - $stream = fopen('data://text/plain,'.$calData, 'r'); - - $backend->createSchedulingObject( - 'principals/user1', - 'schedule1-resource.ics', - $stream - ); - - $expected = [ - 'calendardata' => $calData, - 'uri' => 'schedule1.ics', - 'etag' => '"'.md5($calData).'"', - 'size' => strlen($calData), - ]; - - $expectedResource = [ - 'calendardata' => $calDataResource, - 'uri' => 'schedule1-resource.ics', - 'etag' => '"'.md5($calDataResource).'"', - 'size' => strlen($calDataResource), - ]; - - $result = $backend->getSchedulingObject('principals/user1', 'schedule1.ics'); - foreach ($expected as $k => $v) { - $this->assertArrayHasKey($k, $result); - if (is_resource($result[$k])) { - $result[$k] = stream_get_contents($result[$k]); - } - $this->assertEquals($v, $result[$k]); - } - - $resultResource = $backend->getSchedulingObject('principals/user1', 'schedule1-resource.ics'); - foreach ($expected as $k => $v) { - $this->assertArrayHasKey($k, $result); - if (is_resource($result[$k])) { - $result[$k] = stream_get_contents($result[$k]); - } - $this->assertEquals($v, $result[$k]); - } - - $backend->deleteSchedulingObject('principals/user1', 'schedule1-resource.ics'); - - $results = $backend->getSchedulingObjects('principals/user1'); - - $this->assertEquals(1, count($results)); - $result = $results[0]; - foreach ($expected as $k => $v) { - if (is_resource($result[$k])) { - $result[$k] = stream_get_contents($result[$k]); - } - $this->assertEquals($v, $result[$k]); - } - - $backend->deleteSchedulingObject('principals/user1', 'schedule1.ics'); - $result = $backend->getSchedulingObject('principals/user1', 'schedule1.ics'); - - $this->assertNull($result); - } - - public function testGetInvites() - { - $backend = new PDO($this->pdo); - - // creating a new calendar - $backend->createCalendar('principals/user1', 'somerandomid', []); - $calendar = $backend->getCalendarsForUser('principals/user1')[0]; - - $result = $backend->getInvites($calendar['id']); - $expected = [ - new Sharee([ - 'href' => 'principals/user1', - 'principal' => 'principals/user1', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, - 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, - ]), - ]; - - $this->assertEquals($expected, $result); - } - - /** - * @depends testGetInvites - */ - public function testGetInvitesBadId() - { - $this->expectException('InvalidArgumentException'); - $backend = new PDO($this->pdo); - - // creating a new calendar - $backend->createCalendar('principals/user1', 'somerandomid', []); - $calendar = $backend->getCalendarsForUser('principals/user1')[0]; - - $backend->getInvites('bad-id'); - } - - /** - * @depends testCreateCalendarAndFetch - */ - public function testUpdateInvites() - { - $backend = new PDO($this->pdo); - - // creating a new calendar - $backend->createCalendar('principals/user1', 'somerandomid', []); - $calendar = $backend->getCalendarsForUser('principals/user1')[0]; - - $ownerSharee = new Sharee([ - 'href' => 'principals/user1', - 'principal' => 'principals/user1', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, - 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, - ]); - - // Add a new invite - $backend->updateInvites( - $calendar['id'], - [ - new Sharee([ - 'href' => 'mailto:user@example.org', - 'principal' => 'principals/user2', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, - 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, - 'properties' => ['{DAV:}displayname' => 'User 2'], - ]), - ] - ); - - $result = $backend->getInvites($calendar['id']); - $expected = [ - $ownerSharee, - new Sharee([ - 'href' => 'mailto:user@example.org', - 'principal' => 'principals/user2', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, - 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, - 'properties' => [ - '{DAV:}displayname' => 'User 2', - ], - ]), - ]; - $this->assertEquals($expected, $result); - - // Checking calendar_instances too - $expectedCalendar = [ - 'id' => [1, 2], - 'principaluri' => 'principals/user2', - '{http://calendarserver.org/ns/}getctag' => 'http://sabre.io/ns/sync/1', - '{http://sabredav.org/ns}sync-token' => '1', - 'share-access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, - 'read-only' => true, - 'share-resource-uri' => '/ns/share/1', - ]; - $calendars = $backend->getCalendarsForUser('principals/user2'); - - foreach ($expectedCalendar as $k => $v) { - $this->assertEquals( - $v, - $calendars[0][$k], - 'Key '.$k.' in calendars array did not have the expected value.' - ); - } - - // Updating an invite - $backend->updateInvites( - $calendar['id'], - [ - new Sharee([ - 'href' => 'mailto:user@example.org', - 'principal' => 'principals/user2', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE, - 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, - ]), - ] - ); - - $result = $backend->getInvites($calendar['id']); - $expected = [ - $ownerSharee, - new Sharee([ - 'href' => 'mailto:user@example.org', - 'principal' => 'principals/user2', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE, - 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, - 'properties' => [ - '{DAV:}displayname' => 'User 2', - ], - ]), - ]; - $this->assertEquals($expected, $result); - - // Removing an invite - $backend->updateInvites( - $calendar['id'], - [ - new Sharee([ - 'href' => 'mailto:user@example.org', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_NOACCESS, - ]), - ] - ); - - $result = $backend->getInvites($calendar['id']); - $expected = [ - $ownerSharee, - ]; - $this->assertEquals($expected, $result); - - // Preventing the owner share from being removed - $backend->updateInvites( - $calendar['id'], - [ - new Sharee([ - 'href' => 'principals/user2', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_NOACCESS, - ]), - ] - ); - - $result = $backend->getInvites($calendar['id']); - $expected = [ - new Sharee([ - 'href' => 'principals/user1', - 'principal' => 'principals/user1', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, - 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, - ]), - ]; - $this->assertEquals($expected, $result); - } - - /** - * @depends testUpdateInvites - */ - public function testUpdateInvitesBadId() - { - $this->expectException('InvalidArgumentException'); - $backend = new PDO($this->pdo); - // Add a new invite - $backend->updateInvites( - 'bad-id', - [] - ); - } - - /** - * @depends testUpdateInvites - */ - public function testUpdateInvitesNoPrincipal() - { - $backend = new PDO($this->pdo); - - // creating a new calendar - $backend->createCalendar('principals/user1', 'somerandomid', []); - $calendar = $backend->getCalendarsForUser('principals/user1')[0]; - - $ownerSharee = new Sharee([ - 'href' => 'principals/user1', - 'principal' => 'principals/user1', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, - 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, - ]); - - // Add a new invite - $backend->updateInvites( - $calendar['id'], - [ - new Sharee([ - 'href' => 'mailto:user@example.org', - 'principal' => null, - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, - 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, - 'properties' => ['{DAV:}displayname' => 'User 2'], - ]), - ] - ); - - $result = $backend->getInvites($calendar['id']); - $expected = [ - $ownerSharee, - new Sharee([ - 'href' => 'mailto:user@example.org', - 'principal' => null, - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, - 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_INVALID, - 'properties' => [ - '{DAV:}displayname' => 'User 2', - ], - ]), - ]; - $this->assertEqualsCanonicalizing($expected, $result); - } - - /** - * @depends testUpdateInvites - */ - public function testDeleteSharedCalendar() - { - $backend = new PDO($this->pdo); - - // creating a new calendar - $backend->createCalendar('principals/user1', 'somerandomid', []); - $calendar = $backend->getCalendarsForUser('principals/user1')[0]; - - $ownerSharee = new Sharee([ - 'href' => 'principals/user1', - 'principal' => 'principals/user1', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, - 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, - ]); - - // Add a new invite - $backend->updateInvites( - $calendar['id'], - [ - new Sharee([ - 'href' => 'mailto:user@example.org', - 'principal' => 'principals/user2', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, - 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, - 'properties' => ['{DAV:}displayname' => 'User 2'], - ]), - ] - ); - - $expectedCalendar = [ - 'id' => [1, 2], - 'principaluri' => 'principals/user2', - '{http://calendarserver.org/ns/}getctag' => 'http://sabre.io/ns/sync/1', - '{http://sabredav.org/ns}sync-token' => '1', - 'share-access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READ, - 'read-only' => true, - 'share-resource-uri' => '/ns/share/1', - ]; - $calendars = $backend->getCalendarsForUser('principals/user2'); - - foreach ($expectedCalendar as $k => $v) { - $this->assertEquals( - $v, - $calendars[0][$k], - 'Key '.$k.' in calendars array did not have the expected value.' - ); - } - - // Removing the shared calendar. - $backend->deleteCalendar($calendars[0]['id']); - - $this->assertEquals( - [], - $backend->getCalendarsForUser('principals/user2') - ); - - $result = $backend->getInvites($calendar['id']); - $expected = [ - new Sharee([ - 'href' => 'principals/user1', - 'principal' => 'principals/user1', - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER, - 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED, - ]), - ]; - $this->assertEquals($expected, $result); - } - - public function testSetPublishStatus() - { - $this->expectException('Sabre\DAV\Exception\NotImplemented'); - $backend = new PDO($this->pdo); - $backend->setPublishStatus([1, 1], true); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractTest.php deleted file mode 100644 index 166de1dab..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/AbstractTest.php +++ /dev/null @@ -1,184 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV\Backend; - -use - Sabre\DAV\PropPatch; - -class AbstractTest extends \PHPUnit\Framework\TestCase -{ - public function testUpdateCalendar() - { - $abstract = new AbstractMock(); - $propPatch = new PropPatch(['{DAV:}displayname' => 'anything']); - - $abstract->updateCalendar('randomid', $propPatch); - $result = $propPatch->commit(); - - $this->assertFalse($result); - } - - public function testCalendarQuery() - { - $abstract = new AbstractMock(); - $filters = [ - 'name' => 'VCALENDAR', - 'comp-filters' => [ - [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], - 'is-not-defined' => false, - 'time-range' => null, - ], - ], - 'prop-filters' => [], - 'is-not-defined' => false, - 'time-range' => null, - ]; - - $this->assertEquals([ - 'event1.ics', - ], $abstract->calendarQuery(1, $filters)); - } - - public function testGetCalendarObjectByUID() - { - $abstract = new AbstractMock(); - $this->assertNull( - $abstract->getCalendarObjectByUID('principal1', 'zim') - ); - $this->assertEquals( - 'cal1/event1.ics', - $abstract->getCalendarObjectByUID('principal1', 'foo') - ); - $this->assertNull( - $abstract->getCalendarObjectByUID('principal3', 'foo') - ); - $this->assertNull( - $abstract->getCalendarObjectByUID('principal1', 'shared') - ); - } - - public function testGetMultipleCalendarObjects() - { - $abstract = new AbstractMock(); - $result = $abstract->getMultipleCalendarObjects(1, [ - 'event1.ics', - 'task1.ics', - ]); - - $expected = [ - [ - 'id' => 1, - 'calendarid' => 1, - 'uri' => 'event1.ics', - 'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n", - ], - [ - 'id' => 2, - 'calendarid' => 1, - 'uri' => 'task1.ics', - 'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n", - ], - ]; - - $this->assertEquals($expected, $result); - } -} - -class AbstractMock extends AbstractBackend -{ - public function getCalendarsForUser($principalUri) - { - return [ - [ - 'id' => 1, - 'principaluri' => 'principal1', - 'uri' => 'cal1', - ], - [ - 'id' => 2, - 'principaluri' => 'principal1', - '{http://sabredav.org/ns}owner-principal' => 'principal2', - 'uri' => 'cal1', - ], - ]; - } - - public function createCalendar($principalUri, $calendarUri, array $properties) - { - } - - public function deleteCalendar($calendarId) - { - } - - public function getCalendarObjects($calendarId) - { - switch ($calendarId) { - case 1: - return [ - [ - 'id' => 1, - 'calendarid' => 1, - 'uri' => 'event1.ics', - ], - [ - 'id' => 2, - 'calendarid' => 1, - 'uri' => 'task1.ics', - ], - ]; - case 2: - return [ - [ - 'id' => 3, - 'calendarid' => 2, - 'uri' => 'shared-event.ics', - ], - ]; - } - } - - public function getCalendarObject($calendarId, $objectUri) - { - switch ($objectUri) { - case 'event1.ics': - return [ - 'id' => 1, - 'calendarid' => 1, - 'uri' => 'event1.ics', - 'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n", - ]; - case 'task1.ics': - return [ - 'id' => 2, - 'calendarid' => 1, - 'uri' => 'task1.ics', - 'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n", - ]; - case 'shared-event.ics': - return [ - 'id' => 3, - 'calendarid' => 2, - 'uri' => 'event1.ics', - 'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:shared\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n", - ]; - } - } - - public function createCalendarObject($calendarId, $objectUri, $calendarData) - { - } - - public function updateCalendarObject($calendarId, $objectUri, $calendarData) - { - } - - public function deleteCalendarObject($calendarId, $objectUri) - { - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/Mock.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/Mock.php deleted file mode 100644 index 01ac1b39e..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/Mock.php +++ /dev/null @@ -1,247 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV\Backend; - -use Sabre\CalDAV; -use Sabre\DAV; - -class Mock extends AbstractBackend -{ - protected $calendarData; - protected $calendars; - - public function __construct(array $calendars = [], array $calendarData = []) - { - foreach ($calendars as &$calendar) { - if (!isset($calendar['id'])) { - $calendar['id'] = DAV\UUIDUtil::getUUID(); - } - } - - $this->calendars = $calendars; - $this->calendarData = $calendarData; - } - - /** - * Returns a list of calendars for a principal. - * - * Every project is an array with the following keys: - * * id, a unique id that will be used by other functions to modify the - * calendar. This can be the same as the uri or a database key. - * * uri, which the basename of the uri with which the calendar is - * accessed. - * * principalUri. The owner of the calendar. Almost always the same as - * principalUri passed to this method. - * - * Furthermore it can contain webdav properties in clark notation. A very - * common one is '{DAV:}displayname'. - * - * @param string $principalUri - * - * @return array - */ - public function getCalendarsForUser($principalUri) - { - $r = []; - foreach ($this->calendars as $row) { - if ($row['principaluri'] == $principalUri) { - $r[] = $row; - } - } - - return $r; - } - - /** - * Creates a new calendar for a principal. - * - * If the creation was a success, an id must be returned that can be used to reference - * this calendar in other methods, such as updateCalendar. - * - * This function must return a server-wide unique id that can be used - * later to reference the calendar. - * - * @param string $principalUri - * @param string $calendarUri - * - * @return string|int - */ - public function createCalendar($principalUri, $calendarUri, array $properties) - { - $id = DAV\UUIDUtil::getUUID(); - $this->calendars[] = array_merge([ - 'id' => $id, - 'principaluri' => $principalUri, - 'uri' => $calendarUri, - '{'.CalDAV\Plugin::NS_CALDAV.'}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet(['VEVENT', 'VTODO']), - ], $properties); - - return $id; - } - - /** - * Updates properties for a calendar. - * - * The list of mutations is stored in a Sabre\DAV\PropPatch object. - * To do the actual updates, you must tell this object which properties - * you're going to process with the handle() method. - * - * Calling the handle method is like telling the PropPatch object "I - * promise I can handle updating this property". - * - * Read the PropPatch documentation for more info and examples. - * - * @param mixed $calendarId - */ - public function updateCalendar($calendarId, \Sabre\DAV\PropPatch $propPatch) - { - $propPatch->handleRemaining(function ($props) use ($calendarId) { - foreach ($this->calendars as $k => $calendar) { - if ($calendar['id'] === $calendarId) { - foreach ($props as $propName => $propValue) { - if (is_null($propValue)) { - unset($this->calendars[$k][$propName]); - } else { - $this->calendars[$k][$propName] = $propValue; - } - } - - return true; - } - } - }); - } - - /** - * Delete a calendar and all it's objects. - * - * @param string $calendarId - */ - public function deleteCalendar($calendarId) - { - foreach ($this->calendars as $k => $calendar) { - if ($calendar['id'] === $calendarId) { - unset($this->calendars[$k]); - } - } - } - - /** - * Returns all calendar objects within a calendar object. - * - * Every item contains an array with the following keys: - * * id - unique identifier which will be used for subsequent updates - * * calendardata - The iCalendar-compatible calendar data - * * uri - a unique key which will be used to construct the uri. This can be any arbitrary string. - * * lastmodified - a timestamp of the last modification time - * * etag - An arbitrary string, surrounded by double-quotes. (e.g.: - * ' "abcdef"') - * * calendarid - The calendarid as it was passed to this function. - * - * Note that the etag is optional, but it's highly encouraged to return for - * speed reasons. - * - * The calendardata is also optional. If it's not returned - * 'getCalendarObject' will be called later, which *is* expected to return - * calendardata. - * - * @param string $calendarId - * - * @return array - */ - public function getCalendarObjects($calendarId) - { - if (!isset($this->calendarData[$calendarId])) { - return []; - } - - $objects = $this->calendarData[$calendarId]; - - foreach ($objects as $uri => &$object) { - $object['calendarid'] = $calendarId; - $object['uri'] = $uri; - $object['lastmodified'] = null; - } - - return $objects; - } - - /** - * Returns information from a single calendar object, based on it's object - * uri. - * - * The object uri is only the basename, or filename and not a full path. - * - * The returned array must have the same keys as getCalendarObjects. The - * 'calendardata' object is required here though, while it's not required - * for getCalendarObjects. - * - * This method must return null if the object did not exist. - * - * @param mixed $calendarId - * @param string $objectUri - * - * @return array|null - */ - public function getCalendarObject($calendarId, $objectUri) - { - if (!isset($this->calendarData[$calendarId][$objectUri])) { - return null; - } - $object = $this->calendarData[$calendarId][$objectUri]; - $object['calendarid'] = $calendarId; - $object['uri'] = $objectUri; - $object['lastmodified'] = null; - - return $object; - } - - /** - * Creates a new calendar object. - * - * @param string $calendarId - * @param string $objectUri - * @param string $calendarData - */ - public function createCalendarObject($calendarId, $objectUri, $calendarData) - { - $this->calendarData[$calendarId][$objectUri] = [ - 'calendardata' => $calendarData, - 'calendarid' => $calendarId, - 'uri' => $objectUri, - ]; - - return '"'.md5($calendarData).'"'; - } - - /** - * Updates an existing calendarobject, based on it's uri. - * - * @param string $calendarId - * @param string $objectUri - * @param string $calendarData - */ - public function updateCalendarObject($calendarId, $objectUri, $calendarData) - { - $this->calendarData[$calendarId][$objectUri] = [ - 'calendardata' => $calendarData, - 'calendarid' => $calendarId, - 'uri' => $objectUri, - ]; - - return '"'.md5($calendarData).'"'; - } - - /** - * Deletes an existing calendar object. - * - * @param string $calendarId - * @param string $objectUri - */ - public function deleteCalendarObject($calendarId, $objectUri) - { - unset($this->calendarData[$calendarId][$objectUri]); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOMySQLTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOMySQLTest.php deleted file mode 100644 index 66388def4..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOMySQLTest.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV\Backend; - -class PDOMySQLTest extends AbstractPDOTest -{ - public $driver = 'mysql'; -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOSqliteTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOSqliteTest.php deleted file mode 100644 index 4470e5810..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Backend/PDOSqliteTest.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV\Backend; - -class PDOSqliteTest extends AbstractPDOTest -{ - public $driver = 'sqlite'; -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarObjectTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarObjectTest.php deleted file mode 100644 index b7eb4539e..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarObjectTest.php +++ /dev/null @@ -1,351 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV; - -class CalendarObjectTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var Sabre\CalDAV\Backend_PDO - */ - protected $backend; - /** - * @var Sabre\CalDAV\Calendar - */ - protected $calendar; - protected $principalBackend; - - public function setup(): void - { - $this->backend = TestUtil::getBackend(); - - $calendars = $this->backend->getCalendarsForUser('principals/user1'); - $this->assertEquals(2, count($calendars)); - $this->calendar = new Calendar($this->backend, $calendars[0]); - } - - public function teardown(): void - { - unset($this->calendar); - unset($this->backend); - } - - public function testSetup() - { - $children = $this->calendar->getChildren(); - $this->assertTrue($children[0] instanceof CalendarObject); - - $this->assertIsString($children[0]->getName()); - $this->assertIsString($children[0]->get()); - $this->assertIsString($children[0]->getETag()); - $this->assertEquals('text/calendar; charset=utf-8', $children[0]->getContentType()); - } - - public function testInvalidArg1() - { - $this->expectException('InvalidArgumentException'); - $obj = new CalendarObject( - new Backend\Mock([], []), - [], - [] - ); - } - - public function testInvalidArg2() - { - $this->expectException('InvalidArgumentException'); - $obj = new CalendarObject( - new Backend\Mock([], []), - [], - ['calendarid' => '1'] - ); - } - - /** - * @depends testSetup - */ - public function testPut() - { - $children = $this->calendar->getChildren(); - $this->assertTrue($children[0] instanceof CalendarObject); - $newData = TestUtil::getTestCalendarData(); - - $children[0]->put($newData); - $this->assertEquals($newData, $children[0]->get()); - } - - /** - * @depends testSetup - */ - public 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()); - } - - /** - * @depends testSetup - */ - public function testDelete() - { - $children = $this->calendar->getChildren(); - $this->assertTrue($children[0] instanceof CalendarObject); - - $obj = $children[0]; - $obj->delete(); - - $children2 = $this->calendar->getChildren(); - $this->assertEquals(count($children) - 1, count($children2)); - } - - /** - * @depends testSetup - */ - public function testGetLastModified() - { - $children = $this->calendar->getChildren(); - $this->assertTrue($children[0] instanceof CalendarObject); - - $obj = $children[0]; - - $lastMod = $obj->getLastModified(); - $this->assertTrue(is_int($lastMod) || ctype_digit($lastMod) || is_null($lastMod)); - } - - /** - * @depends testSetup - */ - public function testGetSize() - { - $children = $this->calendar->getChildren(); - $this->assertTrue($children[0] instanceof CalendarObject); - - $obj = $children[0]; - - $size = $obj->getSize(); - $this->assertIsInt($size); - } - - public function testGetOwner() - { - $children = $this->calendar->getChildren(); - $this->assertTrue($children[0] instanceof CalendarObject); - - $obj = $children[0]; - $this->assertEquals('principals/user1', $obj->getOwner()); - } - - public function testGetGroup() - { - $children = $this->calendar->getChildren(); - $this->assertTrue($children[0] instanceof CalendarObject); - - $obj = $children[0]; - $this->assertNull($obj->getGroup()); - } - - public function testGetACL() - { - $expected = [ - [ - 'privilege' => '{DAV:}read', - 'principal' => 'principals/user1', - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}read', - 'principal' => 'principals/user1/calendar-proxy-write', - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}read', - 'principal' => 'principals/user1/calendar-proxy-read', - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}write', - 'principal' => 'principals/user1', - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}write', - 'principal' => 'principals/user1/calendar-proxy-write', - 'protected' => true, - ], - ]; - - $children = $this->calendar->getChildren(); - $this->assertTrue($children[0] instanceof CalendarObject); - - $obj = $children[0]; - $this->assertEquals($expected, $obj->getACL()); - } - - public function testDefaultACL() - { - $backend = new Backend\Mock([], []); - $calendarObject = new CalendarObject($backend, ['principaluri' => 'principals/user1'], ['calendarid' => 1, 'uri' => 'foo']); - $expected = [ - [ - 'privilege' => '{DAV:}all', - 'principal' => 'principals/user1', - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}all', - 'principal' => 'principals/user1/calendar-proxy-write', - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}read', - 'principal' => 'principals/user1/calendar-proxy-read', - 'protected' => true, - ], - ]; - $this->assertEquals($expected, $calendarObject->getACL()); - } - - public function testSetACL() - { - $this->expectException('Sabre\DAV\Exception\Forbidden'); - $children = $this->calendar->getChildren(); - $this->assertTrue($children[0] instanceof CalendarObject); - - $obj = $children[0]; - $obj->setACL([]); - } - - public function testGet() - { - $children = $this->calendar->getChildren(); - $this->assertTrue($children[0] instanceof CalendarObject); - - $obj = $children[0]; - - $expected = 'BEGIN:VCALENDAR -VERSION:2.0 -PRODID:-//Apple Inc.//iCal 4.0.1//EN -CALSCALE:GREGORIAN -BEGIN:VTIMEZONE -TZID:Asia/Seoul -BEGIN:DAYLIGHT -TZOFFSETFROM:+0900 -RRULE:FREQ=YEARLY;UNTIL=19880507T150000Z;BYMONTH=5;BYDAY=2SU -DTSTART:19870510T000000 -TZNAME:GMT+09:00 -TZOFFSETTO:+1000 -END:DAYLIGHT -BEGIN:STANDARD -TZOFFSETFROM:+1000 -DTSTART:19881009T000000 -TZNAME:GMT+09:00 -TZOFFSETTO:+0900 -END:STANDARD -END:VTIMEZONE -BEGIN:VEVENT -CREATED:20100225T154229Z -UID:39A6B5ED-DD51-4AFE-A683-C35EE3749627 -TRANSP:TRANSPARENT -SUMMARY:Something here -DTSTAMP:20100228T130202Z -DTSTART;TZID=Asia/Seoul:20100223T060000 -DTEND;TZID=Asia/Seoul:20100223T070000 -ATTENDEE;PARTSTAT=NEEDS-ACTION:mailto:lisa@example.com -SEQUENCE:2 -END:VEVENT -END:VCALENDAR'; - - $this->assertEquals($expected, $obj->get()); - } - - public function testGetRefetch() - { - $backend = new Backend\Mock([], [ - 1 => [ - 'foo' => [ - 'calendardata' => 'foo', - 'uri' => 'foo', - ], - ], - ]); - $obj = new CalendarObject($backend, ['id' => 1], ['uri' => 'foo']); - - $this->assertEquals('foo', $obj->get()); - } - - public function testGetEtag1() - { - $objectInfo = [ - 'calendardata' => 'foo', - 'uri' => 'foo', - 'etag' => 'bar', - 'calendarid' => 1, - ]; - - $backend = new Backend\Mock([], []); - $obj = new CalendarObject($backend, [], $objectInfo); - - $this->assertEquals('bar', $obj->getETag()); - } - - public function testGetEtag2() - { - $objectInfo = [ - 'calendardata' => 'foo', - 'uri' => 'foo', - 'calendarid' => 1, - ]; - - $backend = new Backend\Mock([], []); - $obj = new CalendarObject($backend, [], $objectInfo); - - $this->assertEquals('"'.md5('foo').'"', $obj->getETag()); - } - - public function testGetSupportedPrivilegesSet() - { - $objectInfo = [ - 'calendardata' => 'foo', - 'uri' => 'foo', - 'calendarid' => 1, - ]; - - $backend = new Backend\Mock([], []); - $obj = new CalendarObject($backend, [], $objectInfo); - $this->assertNull($obj->getSupportedPrivilegeSet()); - } - - public function testGetSize1() - { - $objectInfo = [ - 'calendardata' => 'foo', - 'uri' => 'foo', - 'calendarid' => 1, - ]; - - $backend = new Backend\Mock([], []); - $obj = new CalendarObject($backend, [], $objectInfo); - $this->assertEquals(3, $obj->getSize()); - } - - public function testGetSize2() - { - $objectInfo = [ - 'uri' => 'foo', - 'calendarid' => 1, - 'size' => 4, - ]; - - $backend = new Backend\Mock([], []); - $obj = new CalendarObject($backend, [], $objectInfo); - $this->assertEquals(4, $obj->getSize()); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryVAlarmTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryVAlarmTest.php deleted file mode 100644 index 660832ba4..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryVAlarmTest.php +++ /dev/null @@ -1,121 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV; - -use Sabre\VObject; - -class CalendarQueryVAlarmTest extends \PHPUnit\Framework\TestCase -{ - /** - * This test is specifically for a time-range query on a VALARM, contained - * in a VEVENT that's recurring. - */ - public function testValarm() - { - $vcalendar = new VObject\Component\VCalendar(); - - $vevent = $vcalendar->createComponent('VEVENT'); - $vevent->RRULE = 'FREQ=MONTHLY'; - $vevent->DTSTART = '20120101T120000Z'; - $vevent->UID = 'bla'; - - $valarm = $vcalendar->createComponent('VALARM'); - $valarm->TRIGGER = '-P15D'; - $vevent->add($valarm); - - $vcalendar->add($vevent); - - $filter = [ - 'name' => 'VCALENDAR', - 'is-not-defined' => false, - 'time-range' => null, - 'prop-filters' => [], - 'comp-filters' => [ - [ - 'name' => 'VEVENT', - 'is-not-defined' => false, - 'time-range' => null, - 'prop-filters' => [], - 'comp-filters' => [ - [ - 'name' => 'VALARM', - 'is-not-defined' => false, - 'prop-filters' => [], - 'comp-filters' => [], - 'time-range' => [ - 'start' => new \DateTime('2012-05-10'), - 'end' => new \DateTime('2012-05-20'), - ], - ], - ], - ], - ], - ]; - - $validator = new CalendarQueryValidator(); - $this->assertTrue($validator->validate($vcalendar, $filter)); - - $vcalendar = new VObject\Component\VCalendar(); - - // A limited recurrence rule, should return false - $vevent = $vcalendar->createComponent('VEVENT'); - $vevent->RRULE = 'FREQ=MONTHLY;COUNT=1'; - $vevent->DTSTART = '20120101T120000Z'; - $vevent->UID = 'bla'; - - $valarm = $vcalendar->createComponent('VALARM'); - $valarm->TRIGGER = '-P15D'; - $vevent->add($valarm); - - $vcalendar->add($vevent); - - $this->assertFalse($validator->validate($vcalendar, $filter)); - } - - public function testAlarmWayBefore() - { - $vcalendar = new VObject\Component\VCalendar(); - - $vevent = $vcalendar->createComponent('VEVENT'); - $vevent->DTSTART = '20120101T120000Z'; - $vevent->UID = 'bla'; - - $valarm = $vcalendar->createComponent('VALARM'); - $valarm->TRIGGER = '-P2W1D'; - $vevent->add($valarm); - - $vcalendar->add($vevent); - - $filter = [ - 'name' => 'VCALENDAR', - 'is-not-defined' => false, - 'time-range' => null, - 'prop-filters' => [], - 'comp-filters' => [ - [ - 'name' => 'VEVENT', - 'is-not-defined' => false, - 'time-range' => null, - 'prop-filters' => [], - 'comp-filters' => [ - [ - 'name' => 'VALARM', - 'is-not-defined' => false, - 'prop-filters' => [], - 'comp-filters' => [], - 'time-range' => [ - 'start' => new \DateTime('2011-12-10'), - 'end' => new \DateTime('2011-12-20'), - ], - ], - ], - ], - ], - ]; - - $validator = new CalendarQueryValidator(); - $this->assertTrue($validator->validate($vcalendar, $filter)); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php deleted file mode 100644 index 9dc8ce188..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php +++ /dev/null @@ -1,823 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV; - -use Sabre\VObject; - -class CalendarQueryValidatorTest extends \PHPUnit\Framework\TestCase -{ - public function testTopLevelFail() - { - $validator = new CalendarQueryValidator(); - $vcal = <<<ICS -BEGIN:VCALENDAR -BEGIN:VEVENT -END:VEVENT -END:VCALENDAR -ICS; - $vcal = VObject\Reader::read($vcal); - $this->assertFalse($validator->validate($vcal, ['name' => 'VFOO'])); - } - - /** - * @param string $icalObject - * @param array $filters - * @param int $outcome - * @dataProvider provider - */ - public function testValid($icalObject, $filters, $outcome) - { - $validator = new CalendarQueryValidator(); - - // Wrapping filter in a VCALENDAR component filter, as this is always - // there anyway. - $filters = [ - 'name' => 'VCALENDAR', - 'comp-filters' => [$filters], - 'prop-filters' => [], - 'is-not-defined' => false, - 'time-range' => null, - ]; - - $vObject = VObject\Reader::read($icalObject); - - switch ($outcome) { - case 0: - $this->assertFalse($validator->validate($vObject, $filters)); - break; - case 1: - $this->assertTrue($validator->validate($vObject, $filters)); - break; - case -1: - try { - $validator->validate($vObject, $filters); - $this->fail('This test was supposed to fail'); - } catch (\Exception $e) { - // We need to test something to be valid for phpunit strict - // mode. - $this->assertTrue(true); - } catch (\Throwable $e) { - // PHP7 - $this->assertTrue(true); - } - break; - } - } - - public function provider() - { - $blob1 = <<<yow -BEGIN:VCALENDAR -BEGIN:VEVENT -SUMMARY:hi -END:VEVENT -END:VCALENDAR -yow; - - $blob2 = <<<yow -BEGIN:VCALENDAR -BEGIN:VEVENT -SUMMARY:hi -BEGIN:VALARM -ACTION:DISPLAY -END:VALARM -END:VEVENT -END:VCALENDAR -yow; - - $blob3 = <<<yow -BEGIN:VCALENDAR -BEGIN:VEVENT -SUMMARY:hi -DTSTART;VALUE=DATE:20110704 -END:VEVENT -END:VCALENDAR -yow; - $blob4 = <<<yow -BEGIN:VCARD -VERSION:3.0 -FN:Evert -END:VCARD -yow; - - $blob5 = <<<yow -BEGIN:VCALENDAR -BEGIN:VEVENT -DTSTART:20110101T120000Z -DTEND:20110102T120000Z -END:VEVENT -END:VCALENDAR -yow; - - $blob6 = <<<yow -BEGIN:VCALENDAR -BEGIN:VEVENT -DTSTART:20110101T120000Z -DURATION:PT5H -END:VEVENT -END:VCALENDAR -yow; - - $blob7 = <<<yow -BEGIN:VCALENDAR -BEGIN:VEVENT -DTSTART;VALUE=DATE:20110101 -END:VEVENT -END:VCALENDAR -yow; - - $blob8 = <<<yow -BEGIN:VCALENDAR -BEGIN:VEVENT -DTSTART:20110101T120000Z -END:VEVENT -END:VCALENDAR -yow; - - $blob9 = <<<yow -BEGIN:VCALENDAR -BEGIN:VTODO -DTSTART:20110101T120000Z -DURATION:PT1H -END:VTODO -END:VCALENDAR -yow; - $blob10 = <<<yow -BEGIN:VCALENDAR -BEGIN:VTODO -DTSTART:20110101T120000Z -DUE:20110101T130000Z -END:VTODO -END:VCALENDAR -yow; - $blob11 = <<<yow -BEGIN:VCALENDAR -BEGIN:VTODO -DTSTART:20110101T120000Z -END:VTODO -END:VCALENDAR -yow; - - $blob12 = <<<yow -BEGIN:VCALENDAR -BEGIN:VTODO -DUE:20110101T130000Z -END:VTODO -END:VCALENDAR -yow; - - $blob13 = <<<yow -BEGIN:VCALENDAR -BEGIN:VTODO -COMPLETED:20110101T130000Z -CREATED:20110101T110000Z -END:VTODO -END:VCALENDAR -yow; - - $blob14 = <<<yow -BEGIN:VCALENDAR -BEGIN:VTODO -COMPLETED:20110101T130000Z -END:VTODO -END:VCALENDAR -yow; - - $blob15 = <<<yow -BEGIN:VCALENDAR -BEGIN:VTODO -CREATED:20110101T110000Z -END:VTODO -END:VCALENDAR -yow; - - $blob16 = <<<yow -BEGIN:VCALENDAR -BEGIN:VTODO -END:VTODO -END:VCALENDAR -yow; - - $blob17 = <<<yow -BEGIN:VCALENDAR -BEGIN:VJOURNAL -END:VJOURNAL -END:VCALENDAR -yow; - - $blob18 = <<<yow -BEGIN:VCALENDAR -BEGIN:VJOURNAL -DTSTART:20110101T120000Z -END:VJOURNAL -END:VCALENDAR -yow; - - $blob19 = <<<yow -BEGIN:VCALENDAR -BEGIN:VJOURNAL -DTSTART;VALUE=DATE:20110101 -END:VJOURNAL -END:VCALENDAR -yow; - - $blob20 = <<<yow -BEGIN:VCALENDAR -BEGIN:VFREEBUSY -END:VFREEBUSY -END:VCALENDAR -yow; - - $blob21 = <<<yow -BEGIN:VCALENDAR -BEGIN:VEVENT -DTSTART:20110101T120000Z -BEGIN:VALARM -TRIGGER:-PT1H -END:VALARM -END:VEVENT -END:VCALENDAR -yow; - - $blob22 = <<<yow -BEGIN:VCALENDAR -BEGIN:VEVENT -DTSTART:20110101T120000Z -BEGIN:VALARM -TRIGGER;VALUE=DURATION:-PT1H -END:VALARM -END:VEVENT -END:VCALENDAR -yow; - - $blob23 = <<<yow -BEGIN:VCALENDAR -BEGIN:VEVENT -DTSTART:20110101T120000Z -BEGIN:VALARM -TRIGGER;VALUE=DURATION;RELATED=END:-PT1H -END:VALARM -END:VEVENT -END:VCALENDAR -yow; - - $blob24 = <<<yow -BEGIN:VCALENDAR -BEGIN:VEVENT -DTSTART:20110101T120000Z -DTEND:20110101T130000Z -BEGIN:VALARM -TRIGGER;VALUE=DURATION;RELATED=END:-PT2H -END:VALARM -END:VEVENT -END:VCALENDAR -yow; - - $blob25 = <<<yow -BEGIN:VCALENDAR -BEGIN:VEVENT -DTSTART:20110101T120000Z -DURATION:PT1H -BEGIN:VALARM -TRIGGER;VALUE=DURATION;RELATED=END:-PT2H -END:VALARM -END:VEVENT -END:VCALENDAR -yow; - - $blob26 = <<<yow -BEGIN:VCALENDAR -BEGIN:VEVENT -DTSTART:20110101T120000Z -DURATION:PT1H -BEGIN:VALARM -TRIGGER;VALUE=DATE-TIME:20110101T110000Z -END:VALARM -END:VEVENT -END:VCALENDAR -yow; - - $blob27 = <<<yow -BEGIN:VCALENDAR -BEGIN:VTODO -DTSTART:20110101T120000Z -DUE:20110101T130000Z -BEGIN:VALARM -TRIGGER;VALUE=DURATION;RELATED=END:-PT2H -END:VALARM -END:VTODO -END:VCALENDAR -yow; - - $blob28 = <<<yow -BEGIN:VCALENDAR -BEGIN:VJOURNAL -DTSTART:20110101T120000Z -BEGIN:VALARM -TRIGGER;VALUE=DURATION;RELATED=END:-PT2H -END:VALARM -END:VJOURNAL -END:VCALENDAR -yow; - - $blob29 = <<<yow -BEGIN:VCALENDAR -BEGIN:VEVENT -DTSTART:20110101T120000Z -DURATION:PT1H -BEGIN:VALARM -TRIGGER;VALUE=DATE-TIME:20110101T090000Z -REPEAT:2 -DURATION:PT1H -END:VALARM -END:VEVENT -END:VCALENDAR -yow; - - $blob30 = <<<yow -BEGIN:VCALENDAR -BEGIN:VEVENT -DTSTART:20110101T120000Z -DURATION:PT1H -BEGIN:VALARM -TRIGGER;VALUE=DATE-TIME:20110101T090000Z -DURATION:PT1H -END:VALARM -END:VEVENT -END:VCALENDAR -yow; - - $blob31 = <<<yow -BEGIN:VCALENDAR -BEGIN:VEVENT -UID:foobar -DTSTART:20080101T120000Z -DURATION:PT1H -RRULE:FREQ=YEARLY -END:VEVENT -END:VCALENDAR -yow; - - $blob32 = <<<yow -BEGIN:VCALENDAR -BEGIN:VEVENT -UID:foobar -DTSTART:20080102T120000Z -DURATION:PT1H -RRULE:FREQ=YEARLY -END:VEVENT -END:VCALENDAR -yow; - $blob33 = <<<yow -BEGIN:VCALENDAR -BEGIN:VEVENT -UID:foobar -DTSTART;VALUE=DATE:20120628 -RRULE:FREQ=DAILY -END:VEVENT -END:VCALENDAR -yow; - $blob34 = <<<yow -BEGIN:VCALENDAR -BEGIN:VEVENT -UID:foobar -DTSTART;VALUE=DATE:20120628 -RRULE:FREQ=DAILY -BEGIN:VALARM -TRIGGER:P52W -END:VALARM -END:VEVENT -END:VCALENDAR -yow; - - $filter1 = [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], - 'is-not-defined' => false, - 'time-range' => null, - ]; - $filter2 = $filter1; - $filter2['name'] = 'VTODO'; - - $filter3 = $filter1; - $filter3['is-not-defined'] = true; - - $filter4 = $filter1; - $filter4['name'] = 'VTODO'; - $filter4['is-not-defined'] = true; - - $filter5 = $filter1; - $filter5['comp-filters'] = [ - [ - 'name' => 'VALARM', - 'is-not-defined' => false, - 'comp-filters' => [], - 'prop-filters' => [], - 'time-range' => null, - ], - ]; - $filter6 = $filter1; - $filter6['prop-filters'] = [ - [ - 'name' => 'SUMMARY', - 'is-not-defined' => false, - 'param-filters' => [], - 'time-range' => null, - 'text-match' => null, - ], - ]; - $filter7 = $filter6; - $filter7['prop-filters'][0]['name'] = 'DESCRIPTION'; - - $filter8 = $filter6; - $filter8['prop-filters'][0]['is-not-defined'] = true; - - $filter9 = $filter7; - $filter9['prop-filters'][0]['is-not-defined'] = true; - - $filter10 = $filter5; - $filter10['prop-filters'] = $filter6['prop-filters']; - - // Param filters - $filter11 = $filter1; - $filter11['prop-filters'] = [ - [ - 'name' => 'DTSTART', - 'is-not-defined' => false, - 'param-filters' => [ - [ - 'name' => 'VALUE', - 'is-not-defined' => false, - 'text-match' => null, - ], - ], - 'time-range' => null, - 'text-match' => null, - ], - ]; - - $filter12 = $filter11; - $filter12['prop-filters'][0]['param-filters'][0]['name'] = 'TZID'; - - $filter13 = $filter11; - $filter13['prop-filters'][0]['param-filters'][0]['is-not-defined'] = true; - - $filter14 = $filter12; - $filter14['prop-filters'][0]['param-filters'][0]['is-not-defined'] = true; - - // Param text filter - $filter15 = $filter11; - $filter15['prop-filters'][0]['param-filters'][0]['text-match'] = [ - 'collation' => 'i;ascii-casemap', - 'value' => 'dAtE', - 'negate-condition' => false, - ]; - $filter16 = $filter15; - $filter16['prop-filters'][0]['param-filters'][0]['text-match']['collation'] = 'i;octet'; - - $filter17 = $filter15; - $filter17['prop-filters'][0]['param-filters'][0]['text-match']['negate-condition'] = true; - - $filter18 = $filter15; - $filter18['prop-filters'][0]['param-filters'][0]['text-match']['negate-condition'] = true; - $filter18['prop-filters'][0]['param-filters'][0]['text-match']['collation'] = 'i;octet'; - - // prop + text - $filter19 = $filter5; - $filter19['comp-filters'][0]['prop-filters'] = [ - [ - 'name' => 'action', - 'is-not-defined' => false, - 'time-range' => null, - 'param-filters' => [], - 'text-match' => [ - 'collation' => 'i;ascii-casemap', - 'value' => 'display', - 'negate-condition' => false, - ], - ], - ]; - - // Time range - $filter20 = [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], - 'is-not-defined' => false, - 'time-range' => [ - 'start' => new \DateTime('2011-01-01 10:00:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 13:00:00', new \DateTimeZone('GMT')), - ], - ]; - // Time range, no end date - $filter21 = $filter20; - $filter21['time-range']['end'] = null; - - // Time range, no start date - $filter22 = $filter20; - $filter22['time-range']['start'] = null; - - // Time range, other dates - $filter23 = $filter20; - $filter23['time-range'] = [ - 'start' => new \DateTime('2011-02-01 10:00:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-02-01 13:00:00', new \DateTimeZone('GMT')), - ]; - // Time range - $filter24 = [ - 'name' => 'VTODO', - 'comp-filters' => [], - 'prop-filters' => [], - 'is-not-defined' => false, - 'time-range' => [ - 'start' => new \DateTime('2011-01-01 12:45:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 13:15:00', new \DateTimeZone('GMT')), - ], - ]; - // Time range, other dates (1 month in the future) - $filter25 = $filter24; - $filter25['time-range'] = [ - 'start' => new \DateTime('2011-02-01 10:00:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-02-01 13:00:00', new \DateTimeZone('GMT')), - ]; - $filter26 = $filter24; - $filter26['time-range'] = [ - 'start' => new \DateTime('2011-01-01 11:45:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 12:15:00', new \DateTimeZone('GMT')), - ]; - - // Time range for VJOURNAL - $filter27 = [ - 'name' => 'VJOURNAL', - 'comp-filters' => [], - 'prop-filters' => [], - 'is-not-defined' => false, - 'time-range' => [ - 'start' => new \DateTime('2011-01-01 12:45:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 13:15:00', new \DateTimeZone('GMT')), - ], - ]; - $filter28 = $filter27; - $filter28['time-range'] = [ - 'start' => new \DateTime('2011-01-01 11:45:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 12:15:00', new \DateTimeZone('GMT')), - ]; - // Time range for VFREEBUSY - $filter29 = [ - 'name' => 'VFREEBUSY', - 'comp-filters' => [], - 'prop-filters' => [], - 'is-not-defined' => false, - 'time-range' => [ - 'start' => new \DateTime('2011-01-01 12:45:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 13:15:00', new \DateTimeZone('GMT')), - ], - ]; - // Time range filter on property - $filter30 = [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [ - [ - 'name' => 'DTSTART', - 'is-not-defined' => false, - 'param-filters' => [], - 'time-range' => [ - 'start' => new \DateTime('2011-01-01 10:00:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 13:00:00', new \DateTimeZone('GMT')), - ], - 'text-match' => null, - ], - ], - 'is-not-defined' => false, - 'time-range' => null, - ]; - - // Time range for alarm - $filter31 = [ - 'name' => 'VEVENT', - 'prop-filters' => [], - 'comp-filters' => [ - [ - 'name' => 'VALARM', - 'is-not-defined' => false, - 'comp-filters' => [], - 'prop-filters' => [], - 'time-range' => [ - 'start' => new \DateTime('2011-01-01 10:45:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 11:15:00', new \DateTimeZone('GMT')), - ], - 'text-match' => null, - ], - ], - 'is-not-defined' => false, - 'time-range' => null, - ]; - $filter32 = $filter31; - $filter32['comp-filters'][0]['time-range'] = [ - 'start' => new \DateTime('2011-01-01 11:45:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 12:15:00', new \DateTimeZone('GMT')), - ]; - - $filter33 = $filter31; - $filter33['name'] = 'VTODO'; - $filter34 = $filter32; - $filter34['name'] = 'VTODO'; - $filter35 = $filter31; - $filter35['name'] = 'VJOURNAL'; - $filter36 = $filter32; - $filter36['name'] = 'VJOURNAL'; - - // Time range filter on non-datetime property - $filter37 = [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [ - [ - 'name' => 'SUMMARY', - 'is-not-defined' => false, - 'param-filters' => [], - 'time-range' => [ - 'start' => new \DateTime('2011-01-01 10:00:00', new \DateTimeZone('GMT')), - 'end' => new \DateTime('2011-01-01 13:00:00', new \DateTimeZone('GMT')), - ], - 'text-match' => null, - ], - ], - 'is-not-defined' => false, - 'time-range' => null, - ]; - - $filter38 = [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], - 'is-not-defined' => false, - 'time-range' => [ - 'start' => new \DateTime('2012-07-01 00:00:00', new \DateTimeZone('UTC')), - 'end' => new \DateTime('2012-08-01 00:00:00', new \DateTimeZone('UTC')), - ], - ]; - $filter39 = [ - 'name' => 'VEVENT', - 'comp-filters' => [ - [ - 'name' => 'VALARM', - 'comp-filters' => [], - 'prop-filters' => [], - 'is-not-defined' => false, - 'time-range' => [ - 'start' => new \DateTime('2012-09-01 00:00:00', new \DateTimeZone('UTC')), - 'end' => new \DateTime('2012-10-01 00:00:00', new \DateTimeZone('UTC')), - ], - ], - ], - 'prop-filters' => [], - 'is-not-defined' => false, - 'time-range' => null, - ]; - - return [ - // Component check - - [$blob1, $filter1, 1], - [$blob1, $filter2, 0], - [$blob1, $filter3, 0], - [$blob1, $filter4, 1], - - // Subcomponent check (4) - [$blob1, $filter5, 0], - [$blob2, $filter5, 1], - - // Property checki (6) - [$blob1, $filter6, 1], - [$blob1, $filter7, 0], - [$blob1, $filter8, 0], - [$blob1, $filter9, 1], - - // Subcomponent + property (10) - [$blob2, $filter10, 1], - - // Param filter (11) - [$blob3, $filter11, 1], - [$blob3, $filter12, 0], - [$blob3, $filter13, 0], - [$blob3, $filter14, 1], - - // Param + text (15) - [$blob3, $filter15, 1], - [$blob3, $filter16, 0], - [$blob3, $filter17, 0], - [$blob3, $filter18, 1], - - // Prop + text (19) - [$blob2, $filter19, 1], - - // Incorrect object (vcard) (20) - [$blob4, $filter1, -1], - - // Time-range for event (21) - [$blob5, $filter20, 1], - [$blob6, $filter20, 1], - [$blob7, $filter20, 1], - [$blob8, $filter20, 1], - - [$blob5, $filter21, 1], - [$blob5, $filter22, 1], - - [$blob5, $filter23, 0], - [$blob6, $filter23, 0], - [$blob7, $filter23, 0], - [$blob8, $filter23, 0], - - // Time-range for todo (31) - [$blob9, $filter24, 1], - [$blob9, $filter25, 0], - [$blob9, $filter26, 1], - [$blob10, $filter24, 1], - [$blob10, $filter25, 0], - [$blob10, $filter26, 1], - - [$blob11, $filter24, 0], - [$blob11, $filter25, 0], - [$blob11, $filter26, 1], - - [$blob12, $filter24, 1], - [$blob12, $filter25, 0], - [$blob12, $filter26, 0], - - [$blob13, $filter24, 1], - [$blob13, $filter25, 0], - [$blob13, $filter26, 1], - - [$blob14, $filter24, 1], - [$blob14, $filter25, 0], - [$blob14, $filter26, 0], - - [$blob15, $filter24, 1], - [$blob15, $filter25, 1], - [$blob15, $filter26, 1], - - [$blob16, $filter24, 1], - [$blob16, $filter25, 1], - [$blob16, $filter26, 1], - - // Time-range for journals (55) - [$blob17, $filter27, 0], - [$blob17, $filter28, 0], - [$blob18, $filter27, 0], - [$blob18, $filter28, 1], - [$blob19, $filter27, 1], - [$blob19, $filter28, 1], - - // Time-range for free-busy (61) - [$blob20, $filter29, -1], - - // Time-range on property (62) - [$blob5, $filter30, 1], - [$blob3, $filter37, -1], - [$blob3, $filter30, 0], - - // Time-range on alarm in vevent (65) - [$blob21, $filter31, 1], - [$blob21, $filter32, 0], - [$blob22, $filter31, 1], - [$blob22, $filter32, 0], - [$blob23, $filter31, 1], - [$blob23, $filter32, 0], - [$blob24, $filter31, 1], - [$blob24, $filter32, 0], - [$blob25, $filter31, 1], - [$blob25, $filter32, 0], - [$blob26, $filter31, 1], - [$blob26, $filter32, 0], - - // Time-range on alarm for vtodo (77) - [$blob27, $filter33, 1], - [$blob27, $filter34, 0], - - // Time-range on alarm for vjournal (79) - [$blob28, $filter35, -1], - [$blob28, $filter36, -1], - - // Time-range on alarm with duration (81) - [$blob29, $filter31, 1], - [$blob29, $filter32, 0], - [$blob30, $filter31, 0], - [$blob30, $filter32, 0], - - // Time-range with RRULE (85) - [$blob31, $filter20, 1], - [$blob32, $filter20, 0], - - // Bug reported on mailing list, related to all-day events (87) - //array($blob33, $filter38, 1), - - // Event in timerange, but filtered alarm is in the far future (88). - [$blob34, $filter39, 0], - ]; - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarTest.php deleted file mode 100644 index 18c3ec126..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/CalendarTest.php +++ /dev/null @@ -1,229 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV; - -use Sabre\DAV\PropPatch; - -class CalendarTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var Sabre\CalDAV\Backend\PDO - */ - protected $backend; - protected $principalBackend; - /** - * @var Sabre\CalDAV\Calendar - */ - protected $calendar; - /** - * @var array - */ - protected $calendars; - - public function setup(): void - { - $this->backend = TestUtil::getBackend(); - - $this->calendars = $this->backend->getCalendarsForUser('principals/user1'); - $this->assertEquals(2, count($this->calendars)); - $this->calendar = new Calendar($this->backend, $this->calendars[0]); - } - - public function teardown(): void - { - unset($this->backend); - } - - public function testSimple() - { - $this->assertEquals($this->calendars[0]['uri'], $this->calendar->getName()); - } - - /** - * @depends testSimple - */ - public function testUpdateProperties() - { - $propPatch = new PropPatch([ - '{DAV:}displayname' => 'NewName', - ]); - - $result = $this->calendar->propPatch($propPatch); - $result = $propPatch->commit(); - - $this->assertEquals(true, $result); - - $calendars2 = $this->backend->getCalendarsForUser('principals/user1'); - $this->assertEquals('NewName', $calendars2[0]['{DAV:}displayname']); - } - - /** - * @depends testSimple - */ - public function testGetProperties() - { - $question = [ - '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set', - ]; - - $result = $this->calendar->getProperties($question); - - foreach ($question as $q) { - $this->assertArrayHasKey($q, $result); - } - - $this->assertEquals(['VEVENT', 'VTODO'], $result['{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set']->getValue()); - } - - /** - * @depends testSimple - */ - public function testGetChildNotFound() - { - $this->expectException('Sabre\DAV\Exception\NotFound'); - $this->calendar->getChild('randomname'); - } - - /** - * @depends testSimple - */ - public function testGetChildren() - { - $children = $this->calendar->getChildren(); - $this->assertEquals(1, count($children)); - - $this->assertTrue($children[0] instanceof CalendarObject); - } - - /** - * @depends testGetChildren - */ - public function testChildExists() - { - $this->assertFalse($this->calendar->childExists('foo')); - - $children = $this->calendar->getChildren(); - $this->assertTrue($this->calendar->childExists($children[0]->getName())); - } - - public function testCreateDirectory() - { - $this->expectException('Sabre\DAV\Exception\MethodNotAllowed'); - $this->calendar->createDirectory('hello'); - } - - public function testSetName() - { - $this->expectException('Sabre\DAV\Exception\MethodNotAllowed'); - $this->calendar->setName('hello'); - } - - public function testGetLastModified() - { - $this->assertNull($this->calendar->getLastModified()); - } - - public function testCreateFile() - { - $file = fopen('php://memory', 'r+'); - fwrite($file, TestUtil::getTestCalendarData()); - rewind($file); - - $this->calendar->createFile('hello', $file); - - $file = $this->calendar->getChild('hello'); - $this->assertTrue($file instanceof CalendarObject); - } - - public 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); - } - - public function testDelete() - { - $this->calendar->delete(); - - $calendars = $this->backend->getCalendarsForUser('principals/user1'); - $this->assertEquals(1, count($calendars)); - } - - public function testGetOwner() - { - $this->assertEquals('principals/user1', $this->calendar->getOwner()); - } - - public function testGetGroup() - { - $this->assertNull($this->calendar->getGroup()); - } - - public function testGetACL() - { - $expected = [ - [ - 'privilege' => '{DAV:}read', - 'principal' => 'principals/user1', - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}read', - 'principal' => 'principals/user1/calendar-proxy-write', - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}read', - 'principal' => 'principals/user1/calendar-proxy-read', - 'protected' => true, - ], - [ - 'privilege' => '{'.Plugin::NS_CALDAV.'}read-free-busy', - 'principal' => '{DAV:}authenticated', - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}write', - 'principal' => 'principals/user1', - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}write', - 'principal' => 'principals/user1/calendar-proxy-write', - 'protected' => true, - ], - ]; - $this->assertEquals($expected, $this->calendar->getACL()); - } - - public function testSetACL() - { - $this->expectException('Sabre\DAV\Exception\Forbidden'); - $this->calendar->setACL([]); - } - - public function testGetSyncToken() - { - $this->assertNull($this->calendar->getSyncToken()); - } - - public function testGetSyncTokenNoSyncSupport() - { - $calendar = new Calendar(new Backend\Mock([], []), []); - $this->assertNull($calendar->getSyncToken()); - } - - public function testGetChanges() - { - $this->assertNull($this->calendar->getChanges(1, 1)); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDTest.php deleted file mode 100644 index 93fc56dae..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDTest.php +++ /dev/null @@ -1,114 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV; - -use Sabre\HTTP; -use Sabre\VObject; - -/** - * This unittests is created to find out why recurring events have wrong DTSTART value. - * - * @copyright Copyright (C) fruux GmbH (https://fruux.com/) - * @author Evert Pot (http://evertpot.com/) - * @license http://sabre.io/license/ Modified BSD License - */ -class ExpandEventsDTSTARTandDTENDTest extends \Sabre\DAVServerTest -{ - protected $setupCalDAV = true; - - protected $caldavCalendars = [ - [ - 'id' => 1, - 'name' => 'Calendar', - 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ], - ]; - - protected $caldavCalendarObjects = [ - 1 => [ - 'event.ics' => [ - 'calendardata' => 'BEGIN:VCALENDAR -VERSION:2.0 -BEGIN:VEVENT -UID:foobar -DTEND;TZID=Europe/Berlin:20120207T191500 -RRULE:FREQ=DAILY;INTERVAL=1;COUNT=3 -SUMMARY:RecurringEvents 3 times -DTSTART;TZID=Europe/Berlin:20120207T181500 -END:VEVENT -BEGIN:VEVENT -CREATED:20120207T111900Z -UID:foobar -DTEND;TZID=Europe/Berlin:20120208T191500 -SUMMARY:RecurringEvents 3 times OVERWRITTEN -DTSTART;TZID=Europe/Berlin:20120208T181500 -RECURRENCE-ID;TZID=Europe/Berlin:20120208T181500 -END:VEVENT -END:VCALENDAR -', - ], - ], - ]; - - public function testExpand() - { - $request = HTTP\Sapi::createFromServerArray([ - '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="20120205T230000Z" end="20120212T225959Z"/> - </C:calendar-data> - <D:getetag/> - </D:prop> - <C:filter> - <C:comp-filter name="VCALENDAR"> - <C:comp-filter name="VEVENT"> - <C:time-range start="20120205T230000Z" end="20120212T225959Z"/> - </C:comp-filter> - </C:comp-filter> - </C:filter> -</C:calendar-query>'); - - $response = $this->request($request); - - $bodyAsString = $response->getBodyAsString(); - // Everts super awesome xml parser. - $body = substr( - $bodyAsString, - $start = strpos($bodyAsString, 'BEGIN:VCALENDAR'), - strpos($bodyAsString, 'END:VCALENDAR') - $start + 13 - ); - $body = str_replace(' ', '', $body); - - try { - $vObject = VObject\Reader::read($body); - } catch (VObject\ParseException $e) { - $this->fail('Could not parse object. Error:'.$e->getMessage().' full object: '.$response->getBodyAsString()); - } - - // check if DTSTARTs and DTENDs are correct - foreach ($vObject->VEVENT as $vevent) { - /** @var $vevent Sabre\VObject\Component\VEvent */ - foreach ($vevent->children() as $child) { - /** @var $child Sabre\VObject\Property */ - if ('DTSTART' == $child->name) { - // DTSTART has to be one of three valid values - $this->assertContains($child->getValue(), ['20120207T171500Z', '20120208T171500Z', '20120209T171500Z'], 'DTSTART is not a valid value: '.$child->getValue()); - } elseif ('DTEND' == $child->name) { - // DTEND has to be one of three valid values - $this->assertContains($child->getValue(), ['20120207T181500Z', '20120208T181500Z', '20120209T181500Z'], 'DTEND is not a valid value: '.$child->getValue()); - } - } - } - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDbyDayTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDbyDayTest.php deleted file mode 100644 index 50fb6c03c..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDbyDayTest.php +++ /dev/null @@ -1,104 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV; - -use Sabre\HTTP; -use Sabre\VObject; - -/** - * This unittests is created to find out why recurring events have wrong DTSTART value. - * - * @copyright Copyright (C) fruux GmbH (https://fruux.com/) - * @author Evert Pot (http://evertpot.com/) - * @license http://sabre.io/license/ Modified BSD License - */ -class ExpandEventsDTSTARTandDTENDbyDayTest extends \Sabre\DAVServerTest -{ - protected $setupCalDAV = true; - - protected $caldavCalendars = [ - [ - 'id' => 1, - 'name' => 'Calendar', - 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ], - ]; - - protected $caldavCalendarObjects = [ - 1 => [ - 'event.ics' => [ - 'calendardata' => 'BEGIN:VCALENDAR -VERSION:2.0 -BEGIN:VEVENT -UID:foobar -DTEND;TZID=Europe/Berlin:20120207T191500 -RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU,TH -SUMMARY:RecurringEvents on tuesday and thursday -DTSTART;TZID=Europe/Berlin:20120207T181500 -END:VEVENT -END:VCALENDAR -', - ], - ], - ]; - - public function testExpandRecurringByDayEvent() - { - $request = HTTP\Sapi::createFromServerArray([ - '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="20120210T230000Z" end="20120217T225959Z"/> - </C:calendar-data> - <D:getetag/> - </D:prop> - <C:filter> - <C:comp-filter name="VCALENDAR"> - <C:comp-filter name="VEVENT"> - <C:time-range start="20120210T230000Z" end="20120217T225959Z"/> - </C:comp-filter> - </C:comp-filter> - </C:filter> -</C:calendar-query>'); - - $response = $this->request($request); - - $bodyAsString = $response->getBodyAsString(); - // Everts super awesome xml parser. - $body = substr( - $bodyAsString, - $start = strpos($bodyAsString, 'BEGIN:VCALENDAR'), - strpos($bodyAsString, 'END:VCALENDAR') - $start + 13 - ); - $body = str_replace(' ', '', $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 */ - foreach ($vevent->children() as $child) { - /** @var $child Sabre\VObject\Property */ - if ('DTSTART' == $child->name) { - // DTSTART has to be one of two valid values - $this->assertContains($child->getValue(), ['20120214T171500Z', '20120216T171500Z'], 'DTSTART is not a valid value: '.$child->getValue()); - } elseif ('DTEND' == $child->name) { - // DTEND has to be one of two valid values - $this->assertContains($child->getValue(), ['20120214T181500Z', '20120216T181500Z'], 'DTEND is not a valid value: '.$child->getValue()); - } - } - } - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDoubleEventsTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDoubleEventsTest.php deleted file mode 100644 index 5e5c153e0..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/ExpandEventsDoubleEventsTest.php +++ /dev/null @@ -1,104 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV; - -use Sabre\HTTP; -use Sabre\VObject; - -/** - * This unittests is created to find out why certain events show up twice. - * - * Hopefully, by the time I'm done with this, I've both found the problem, and - * fixed it :) - * - * @copyright Copyright (C) fruux GmbH (https://fruux.com/) - * @author Evert Pot (http://evertpot.com/) - * @license http://sabre.io/license/ Modified BSD License - */ -class ExpandEventsDoubleEventsTest extends \Sabre\DAVServerTest -{ - protected $setupCalDAV = true; - - protected $caldavCalendars = [ - [ - 'id' => 1, - 'name' => 'Calendar', - 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ], - ]; - - protected $caldavCalendarObjects = [ - 1 => [ - 'event.ics' => [ - 'calendardata' => 'BEGIN:VCALENDAR -VERSION:2.0 -BEGIN:VEVENT -UID:foobar -DTEND;TZID=Europe/Berlin:20120207T191500 -RRULE:FREQ=DAILY;INTERVAL=1;COUNT=3 -SUMMARY:RecurringEvents 3 times -DTSTART;TZID=Europe/Berlin:20120207T181500 -END:VEVENT -BEGIN:VEVENT -CREATED:20120207T111900Z -UID:foobar -DTEND;TZID=Europe/Berlin:20120208T191500 -SUMMARY:RecurringEvents 3 times OVERWRITTEN -DTSTART;TZID=Europe/Berlin:20120208T181500 -RECURRENCE-ID;TZID=Europe/Berlin:20120208T181500 -END:VEVENT -END:VCALENDAR -', - ], - ], - ]; - - public function testExpand() - { - $request = HTTP\Sapi::createFromServerArray([ - '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="20120205T230000Z" end="20120212T225959Z"/> - </C:calendar-data> - <D:getetag/> - </D:prop> - <C:filter> - <C:comp-filter name="VCALENDAR"> - <C:comp-filter name="VEVENT"> - <C:time-range start="20120205T230000Z" end="20120212T225959Z"/> - </C:comp-filter> - </C:comp-filter> - </C:filter> -</C:calendar-query>'); - - $response = $this->request($request); - - $bodyAsString = $response->getBodyAsString(); - // Everts super awesome xml parser. - $body = substr( - $bodyAsString, - $start = strpos($bodyAsString, 'BEGIN:VCALENDAR'), - strpos($bodyAsString, 'END:VCALENDAR') - $start + 13 - ); - $body = str_replace(' ', '', $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); - - // TZID should be gone - $this->assertFalse(isset($vObject->VEVENT->DTSTART['TZID'])); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/FreeBusyReportTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/FreeBusyReportTest.php deleted file mode 100644 index 44823edab..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/FreeBusyReportTest.php +++ /dev/null @@ -1,158 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV; - -use Sabre\DAV; -use Sabre\HTTP; - -class FreeBusyReportTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var Plugin - */ - protected $plugin; - /** - * @var DAV\Server - */ - protected $server; - - public function setup(): void - { - $obj1 = <<<ics -BEGIN:VCALENDAR -BEGIN:VEVENT -DTSTART:20111005T120000Z -DURATION:PT1H -END:VEVENT -END:VCALENDAR -ics; - - $obj2 = fopen('php://memory', 'r+'); - fwrite($obj2, <<<ics -BEGIN:VCALENDAR -BEGIN:VEVENT -DTSTART:20121005T120000Z -DURATION:PT1H -END:VEVENT -END:VCALENDAR -ics - ); - rewind($obj2); - - $obj3 = <<<ics -BEGIN:VCALENDAR -BEGIN:VEVENT -DTSTART:20111006T120000 -DURATION:PT1H -END:VEVENT -END:VCALENDAR -ics; - - $calendarData = [ - 1 => [ - 'obj1' => [ - 'calendarid' => 1, - 'uri' => 'event1.ics', - 'calendardata' => $obj1, - ], - 'obj2' => [ - 'calendarid' => 1, - 'uri' => 'event2.ics', - 'calendardata' => $obj2, - ], - 'obj3' => [ - 'calendarid' => 1, - 'uri' => 'event3.ics', - 'calendardata' => $obj3, - ], - ], - ]; - - $caldavBackend = new Backend\Mock([], $calendarData); - - $calendar = new Calendar($caldavBackend, [ - 'id' => 1, - 'uri' => 'calendar', - 'principaluri' => 'principals/user1', - '{'.Plugin::NS_CALDAV.'}calendar-timezone' => "BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nTZID:Europe/Berlin\r\nEND:VTIMEZONE\r\nEND:VCALENDAR", - ]); - - $this->server = new DAV\Server([$calendar]); - - $request = new HTTP\Request('GET', '/calendar'); - $this->server->httpRequest = $request; - $this->server->httpResponse = new HTTP\ResponseMock(); - - $this->plugin = new Plugin(); - $this->server->addPlugin($this->plugin); - } - - public function testFreeBusyReport() - { - $reportXML = <<<XML -<?xml version="1.0"?> -<c:free-busy-query xmlns:c="urn:ietf:params:xml:ns:caldav"> - <c:time-range start="20111001T000000Z" end="20111101T000000Z" /> -</c:free-busy-query> -XML; - - $report = $this->server->xml->parse($reportXML, null, $rootElem); - $this->plugin->report($rootElem, $report, null); - - $this->assertEquals(200, $this->server->httpResponse->status); - $this->assertEquals('text/calendar', $this->server->httpResponse->getHeader('Content-Type')); - $this->assertTrue(false !== strpos($this->server->httpResponse->body, 'BEGIN:VFREEBUSY')); - $this->assertTrue(false !== strpos($this->server->httpResponse->body, '20111005T120000Z/20111005T130000Z')); - $this->assertTrue(false !== strpos($this->server->httpResponse->body, '20111006T100000Z/20111006T110000Z')); - } - - public function testFreeBusyReportNoTimeRange() - { - $this->expectException('Sabre\DAV\Exception\BadRequest'); - $reportXML = <<<XML -<?xml version="1.0"?> -<c:free-busy-query xmlns:c="urn:ietf:params:xml:ns:caldav"> -</c:free-busy-query> -XML; - - $report = $this->server->xml->parse($reportXML, null, $rootElem); - } - - public function testFreeBusyReportWrongNode() - { - $this->expectException('Sabre\DAV\Exception\NotImplemented'); - $request = new HTTP\Request('REPORT', '/'); - $this->server->httpRequest = $request; - - $reportXML = <<<XML -<?xml version="1.0"?> -<c:free-busy-query xmlns:c="urn:ietf:params:xml:ns:caldav"> - <c:time-range start="20111001T000000Z" end="20111101T000000Z" /> -</c:free-busy-query> -XML; - - $report = $this->server->xml->parse($reportXML, null, $rootElem); - $this->plugin->report($rootElem, $report, null); - } - - public function testFreeBusyReportNoACLPlugin() - { - $this->expectException('Sabre\DAV\Exception'); - $this->server = new DAV\Server(); - $this->server->httpRequest = new HTTP\Request('REPORT', '/'); - $this->plugin = new Plugin(); - $this->server->addPlugin($this->plugin); - - $reportXML = <<<XML -<?xml version="1.0"?> -<c:free-busy-query xmlns:c="urn:ietf:params:xml:ns:caldav"> - <c:time-range start="20111001T000000Z" end="20111101T000000Z" /> -</c:free-busy-query> -XML; - - $report = $this->server->xml->parse($reportXML, null, $rootElem); - $this->plugin->report($rootElem, $report, null); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/GetEventsByTimerangeTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/GetEventsByTimerangeTest.php deleted file mode 100644 index e82a85dd8..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/GetEventsByTimerangeTest.php +++ /dev/null @@ -1,82 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV; - -use Sabre\HTTP; - -/** - * This unittest is created to check if queries for time-range include the start timestamp or not. - * - * @copyright Copyright (C) fruux GmbH (https://fruux.com/) - * @author Evert Pot (http://evertpot.com/) - * @license http://sabre.io/license/ Modified BSD License - */ -class GetEventsByTimerangeTest extends \Sabre\DAVServerTest -{ - protected $setupCalDAV = true; - - protected $caldavCalendars = [ - [ - 'id' => 1, - 'name' => 'Calendar', - 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ], - ]; - - protected $caldavCalendarObjects = [ - 1 => [ - 'event.ics' => [ - 'calendardata' => 'BEGIN:VCALENDAR -VERSION:2.0 -BEGIN:VEVENT -CREATED:20120313T142342Z -UID:171EBEFC-C951-499D-B234-7BA7D677B45D -DTEND;TZID=Europe/Berlin:20120227T010000 -TRANSP:OPAQUE -SUMMARY:Monday 0h -DTSTART;TZID=Europe/Berlin:20120227T000000 -DTSTAMP:20120313T142416Z -SEQUENCE:4 -END:VEVENT -END:VCALENDAR -', - ], - ], - ]; - - public function testQueryTimerange() - { - $request = new HTTP\Request( - 'REPORT', - '/calendars/user1/calendar1', - [ - 'Content-Type' => 'application/xml', - '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="20120226T220000Z" end="20120228T225959Z"/> - </C:calendar-data> - <D:getetag/> - </D:prop> - <C:filter> - <C:comp-filter name="VCALENDAR"> - <C:comp-filter name="VEVENT"> - <C:time-range start="20120226T220000Z" end="20120228T225959Z"/> - </C:comp-filter> - </C:comp-filter> - </C:filter> -</C:calendar-query>'); - - $response = $this->request($request); - - $this->assertTrue(false !== strpos($response->getBodyAsString(), 'BEGIN:VCALENDAR')); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/ICSExportPluginTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/ICSExportPluginTest.php deleted file mode 100644 index 8771f538b..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/ICSExportPluginTest.php +++ /dev/null @@ -1,366 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV; - -use Sabre\DAV; -use Sabre\DAVACL; -use Sabre\HTTP; -use Sabre\VObject; - -class ICSExportPluginTest extends \Sabre\DAVServerTest -{ - protected $setupCalDAV = true; - - protected $icsExportPlugin; - - public function setup(): void - { - parent::setUp(); - $this->icsExportPlugin = new ICSExportPlugin(); - $this->server->addPlugin( - $this->icsExportPlugin - ); - - $id = $this->caldavBackend->createCalendar( - 'principals/admin', - 'UUID-123467', - [ - '{DAV:}displayname' => 'Hello!', - '{http://apple.com/ns/ical/}calendar-color' => '#AA0000FF', - ] - ); - - $this->caldavBackend->createCalendarObject( - $id, - 'event-1', - <<<ICS -BEGIN:VCALENDAR -BEGIN:VTIMEZONE -TZID:Europe/Amsterdam -END:VTIMEZONE -BEGIN:VEVENT -UID:event-1 -DTSTART;TZID=Europe/Amsterdam:20151020T000000 -END:VEVENT -END:VCALENDAR -ICS - ); - $this->caldavBackend->createCalendarObject( - $id, - 'todo-1', - <<<ICS -BEGIN:VCALENDAR -BEGIN:VTODO -UID:todo-1 -END:VTODO -END:VCALENDAR -ICS - ); - } - - public function testInit() - { - $this->assertEquals( - $this->icsExportPlugin, - $this->server->getPlugin('ics-export') - ); - $this->assertEquals($this->icsExportPlugin, $this->server->getPlugin('ics-export')); - $this->assertEquals('ics-export', $this->icsExportPlugin->getPluginInfo()['name']); - } - - public function testBeforeMethod() - { - $request = new HTTP\Request( - 'GET', - '/calendars/admin/UUID-123467?export' - ); - - $response = $this->request($request); - - $this->assertEquals(200, $response->getStatus()); - $this->assertEquals('text/calendar', $response->getHeader('Content-Type')); - - $obj = VObject\Reader::read($response->getBodyAsString()); - - $this->assertEquals(8, count($obj->children())); - $this->assertEquals(1, count($obj->VERSION)); - $this->assertEquals(1, count($obj->CALSCALE)); - $this->assertEquals(1, count($obj->PRODID)); - $this->assertTrue(false !== strpos((string) $obj->PRODID, DAV\Version::VERSION)); - $this->assertEquals(1, count($obj->VTIMEZONE)); - $this->assertEquals(1, count($obj->VEVENT)); - $this->assertEquals('Hello!', $obj->{'X-WR-CALNAME'}); - $this->assertEquals('#AA0000FF', $obj->{'X-APPLE-CALENDAR-COLOR'}); - } - - public function testBeforeMethodNoVersion() - { - $request = new HTTP\Request( - 'GET', - '/calendars/admin/UUID-123467?export' - ); - DAV\Server::$exposeVersion = false; - $response = $this->request($request); - DAV\Server::$exposeVersion = true; - - $this->assertEquals(200, $response->getStatus()); - $this->assertEquals('text/calendar', $response->getHeader('Content-Type')); - - $obj = VObject\Reader::read($response->getBodyAsString()); - - $this->assertEquals(8, count($obj->children())); - $this->assertEquals(1, count($obj->VERSION)); - $this->assertEquals(1, count($obj->CALSCALE)); - $this->assertEquals(1, count($obj->PRODID)); - $this->assertFalse(false !== strpos((string) $obj->PRODID, DAV\Version::VERSION)); - $this->assertEquals(1, count($obj->VTIMEZONE)); - $this->assertEquals(1, count($obj->VEVENT)); - } - - public function testBeforeMethodNoExport() - { - $request = new HTTP\Request( - 'GET', - '/calendars/admin/UUID-123467' - ); - $response = new HTTP\Response(); - $this->assertNull($this->icsExportPlugin->httpGet($request, $response)); - } - - public function testACLIntegrationBlocked() - { - $aclPlugin = new DAVACL\Plugin(); - $aclPlugin->allowUnauthenticatedAccess = false; - $this->server->addPlugin( - $aclPlugin - ); - - $request = new HTTP\Request( - 'GET', - '/calendars/admin/UUID-123467?export' - ); - - $this->request($request, 403); - } - - public function testACLIntegrationNotBlocked() - { - $aclPlugin = new DAVACL\Plugin(); - $aclPlugin->allowUnauthenticatedAccess = false; - $this->server->addPlugin( - $aclPlugin - ); - $this->server->addPlugin( - new Plugin() - ); - - $this->autoLogin('admin'); - - $request = new HTTP\Request( - 'GET', - '/calendars/admin/UUID-123467?export' - ); - - $response = $this->request($request, 200); - $this->assertEquals('text/calendar', $response->getHeader('Content-Type')); - - $obj = VObject\Reader::read($response->getBodyAsString()); - - $this->assertEquals(8, count($obj->children())); - $this->assertEquals(1, count($obj->VERSION)); - $this->assertEquals(1, count($obj->CALSCALE)); - $this->assertEquals(1, count($obj->PRODID)); - $this->assertTrue(false !== strpos((string) $obj->PRODID, DAV\Version::VERSION)); - $this->assertEquals(1, count($obj->VTIMEZONE)); - $this->assertEquals(1, count($obj->VEVENT)); - } - - public function testBadStartParam() - { - $request = new HTTP\Request( - 'GET', - '/calendars/admin/UUID-123467?export&start=foo' - ); - $this->request($request, 400); - } - - public function testBadEndParam() - { - $request = new HTTP\Request( - 'GET', - '/calendars/admin/UUID-123467?export&end=foo' - ); - $this->request($request, 400); - } - - public function testFilterStartEnd() - { - $request = new HTTP\Request( - 'GET', - '/calendars/admin/UUID-123467?export&start=1&end=2' - ); - $response = $this->request($request, 200); - - $obj = VObject\Reader::read($response->getBody()); - - $this->assertNull($obj->VTIMEZONE); - $this->assertNull($obj->VEVENT); - } - - public function testExpandNoStart() - { - $request = new HTTP\Request( - 'GET', - '/calendars/admin/UUID-123467?export&expand=1&end=2' - ); - $this->request($request, 400); - } - - public function testExpand() - { - $request = new HTTP\Request( - 'GET', - '/calendars/admin/UUID-123467?export&start=1&end=2000000000&expand=1' - ); - $response = $this->request($request, 200); - - $obj = VObject\Reader::read($response->getBody()); - - $this->assertNull($obj->VTIMEZONE); - $this->assertEquals(1, count($obj->VEVENT)); - } - - public function testJCal() - { - $request = new HTTP\Request( - 'GET', - '/calendars/admin/UUID-123467?export', - ['Accept' => 'application/calendar+json'] - ); - - $response = $this->request($request, 200); - $this->assertEquals('application/calendar+json', $response->getHeader('Content-Type')); - } - - public function testJCalInUrl() - { - $request = new HTTP\Request( - 'GET', - '/calendars/admin/UUID-123467?export&accept=jcal' - ); - - $response = $this->request($request, 200); - $this->assertEquals('application/calendar+json', $response->getHeader('Content-Type')); - } - - public function testNegotiateDefault() - { - $request = new HTTP\Request( - 'GET', - '/calendars/admin/UUID-123467?export', - ['Accept' => 'text/plain'] - ); - - $response = $this->request($request, 200); - $this->assertEquals('text/calendar', $response->getHeader('Content-Type')); - } - - public function testFilterComponentVEVENT() - { - $request = new HTTP\Request( - 'GET', - '/calendars/admin/UUID-123467?export&componentType=VEVENT' - ); - - $response = $this->request($request, 200); - - $obj = VObject\Reader::read($response->getBodyAsString()); - $this->assertEquals(1, count($obj->VTIMEZONE)); - $this->assertEquals(1, count($obj->VEVENT)); - $this->assertNull($obj->VTODO); - } - - public function testFilterComponentVTODO() - { - $request = new HTTP\Request( - 'GET', - '/calendars/admin/UUID-123467?export&componentType=VTODO' - ); - - $response = $this->request($request, 200); - - $obj = VObject\Reader::read($response->getBodyAsString()); - - $this->assertNull($obj->VTIMEZONE); - $this->assertNull($obj->VEVENT); - $this->assertEquals(1, count($obj->VTODO)); - } - - public function testFilterComponentBadComponent() - { - $request = new HTTP\Request( - 'GET', - '/calendars/admin/UUID-123467?export&componentType=VVOODOO' - ); - - $response = $this->request($request, 400); - } - - public function testContentDisposition() - { - $request = new HTTP\Request( - 'GET', - '/calendars/admin/UUID-123467?export' - ); - - $response = $this->request($request, 200); - $this->assertEquals('text/calendar', $response->getHeader('Content-Type')); - $this->assertEquals( - 'attachment; filename="UUID-123467-'.date('Y-m-d').'.ics"', - $response->getHeader('Content-Disposition') - ); - } - - public function testContentDispositionJson() - { - $request = new HTTP\Request( - 'GET', - '/calendars/admin/UUID-123467?export', - ['Accept' => 'application/calendar+json'] - ); - - $response = $this->request($request, 200); - $this->assertEquals('application/calendar+json', $response->getHeader('Content-Type')); - $this->assertEquals( - 'attachment; filename="UUID-123467-'.date('Y-m-d').'.json"', - $response->getHeader('Content-Disposition') - ); - } - - public function testContentDispositionBadChars() - { - $this->caldavBackend->createCalendar( - 'principals/admin', - 'UUID-b_ad"(ch)ars', - [ - '{DAV:}displayname' => 'Test bad characters', - '{http://apple.com/ns/ical/}calendar-color' => '#AA0000FF', - ] - ); - - $request = new HTTP\Request( - 'GET', - '/calendars/admin/UUID-b_ad"(ch)ars?export', - ['Accept' => 'application/calendar+json'] - ); - - $response = $this->request($request, 200); - $this->assertEquals('application/calendar+json', $response->getHeader('Content-Type')); - $this->assertEquals( - 'attachment; filename="UUID-b_adchars-'.date('Y-m-d').'.json"', - $response->getHeader('Content-Disposition') - ); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue166Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue166Test.php deleted file mode 100644 index 02d39fe84..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue166Test.php +++ /dev/null @@ -1,63 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV; - -use Sabre\VObject; - -class Issue166Test extends \PHPUnit\Framework\TestCase -{ - public function testFlaw() - { - $input = <<<HI -BEGIN:VCALENDAR -PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN -VERSION:2.0 -BEGIN:VTIMEZONE -TZID:Asia/Pyongyang -X-LIC-LOCATION:Asia/Pyongyang -BEGIN:STANDARD -TZOFFSETFROM:+0900 -TZOFFSETTO:+0900 -TZNAME:KST -DTSTART:19700101T000000 -END:STANDARD -END:VTIMEZONE -BEGIN:VEVENT -CREATED:20111118T010857Z -LAST-MODIFIED:20111118T010937Z -DTSTAMP:20111118T010937Z -UID:a03245b3-9947-9a48-a088-863c74e0fdd8 -SUMMARY:New Event -RRULE:FREQ=YEARLY -DTSTART;TZID=Asia/Pyongyang:19960102T111500 -DTEND;TZID=Asia/Pyongyang:19960102T121500 -END:VEVENT -END:VCALENDAR -HI; - - $validator = new CalendarQueryValidator(); - - $filters = [ - 'name' => 'VCALENDAR', - 'comp-filters' => [ - [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], - 'is-not-defined' => false, - 'time-range' => [ - 'start' => new \DateTime('2011-12-01'), - 'end' => new \DateTime('2012-02-01'), - ], - ], - ], - 'prop-filters' => [], - 'is-not-defined' => false, - 'time-range' => null, - ]; - $input = VObject\Reader::read($input); - $this->assertTrue($validator->validate($input, $filters)); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue172Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue172Test.php deleted file mode 100644 index 83120fe6a..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue172Test.php +++ /dev/null @@ -1,140 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV; - -use Sabre\VObject; - -class Issue172Test extends \PHPUnit\Framework\TestCase -{ - // DateTimeZone() native name: America/Los_Angeles (GMT-8 in January) - public function testBuiltInTimezoneName() - { - $input = <<<HI -BEGIN:VCALENDAR -VERSION:2.0 -BEGIN:VEVENT -DTSTART;TZID=America/Los_Angeles:20120118T204500 -DTEND;TZID=America/Los_Angeles:20120118T214500 -END:VEVENT -END:VCALENDAR -HI; - $validator = new CalendarQueryValidator(); - $filters = [ - 'name' => 'VCALENDAR', - 'comp-filters' => [ - [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], - 'is-not-defined' => false, - 'time-range' => [ - 'start' => new \DateTime('2012-01-18 21:00:00 GMT-08:00'), - 'end' => new \DateTime('2012-01-18 21:00:00 GMT-08:00'), - ], - ], - ], - 'prop-filters' => [], - ]; - $input = VObject\Reader::read($input); - $this->assertTrue($validator->validate($input, $filters)); - } - - // Pacific Standard Time, translates to America/Los_Angeles (GMT-8 in January) - public function testOutlookTimezoneName() - { - $input = <<<HI -BEGIN:VCALENDAR -VERSION:2.0 -BEGIN:VTIMEZONE -TZID:Pacific Standard Time -BEGIN:STANDARD -DTSTART:16010101T030000 -TZOFFSETFROM:+0200 -TZOFFSETTO:+0100 -RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10 -END:STANDARD -BEGIN:DAYLIGHT -DTSTART:16010101T020000 -TZOFFSETFROM:+0100 -TZOFFSETTO:+0200 -RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3 -END:DAYLIGHT -END:VTIMEZONE -BEGIN:VEVENT -DTSTART;TZID=Pacific Standard Time:20120113T100000 -DTEND;TZID=Pacific Standard Time:20120113T110000 -END:VEVENT -END:VCALENDAR -HI; - $validator = new CalendarQueryValidator(); - $filters = [ - 'name' => 'VCALENDAR', - 'comp-filters' => [ - [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], - 'is-not-defined' => false, - 'time-range' => [ - 'start' => new \DateTime('2012-01-13 10:30:00 GMT-08:00'), - 'end' => new \DateTime('2012-01-13 10:30:00 GMT-08:00'), - ], - ], - ], - 'prop-filters' => [], - ]; - $input = VObject\Reader::read($input); - $this->assertTrue($validator->validate($input, $filters)); - } - - // X-LIC-LOCATION, translates to America/Los_Angeles (GMT-8 in January) - public function testLibICalLocationName() - { - $input = <<<HI -BEGIN:VCALENDAR -VERSION:2.0 -BEGIN:VTIMEZONE -TZID:My own timezone name -X-LIC-LOCATION:America/Los_Angeles -BEGIN:STANDARD -DTSTART:16010101T030000 -TZOFFSETFROM:+0200 -TZOFFSETTO:+0100 -RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10 -END:STANDARD -BEGIN:DAYLIGHT -DTSTART:16010101T020000 -TZOFFSETFROM:+0100 -TZOFFSETTO:+0200 -RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3 -END:DAYLIGHT -END:VTIMEZONE -BEGIN:VEVENT -DTSTART;TZID=My own timezone name:20120113T100000 -DTEND;TZID=My own timezone name:20120113T110000 -END:VEVENT -END:VCALENDAR -HI; - $validator = new CalendarQueryValidator(); - $filters = [ - 'name' => 'VCALENDAR', - 'comp-filters' => [ - [ - 'name' => 'VEVENT', - 'comp-filters' => [], - 'prop-filters' => [], - 'is-not-defined' => false, - 'time-range' => [ - 'start' => new \DateTime('2012-01-13 10:30:00 GMT-08:00'), - 'end' => new \DateTime('2012-01-13 10:30:00 GMT-08:00'), - ], - ], - ], - 'prop-filters' => [], - ]; - $input = VObject\Reader::read($input); - $this->assertTrue($validator->validate($input, $filters)); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue203Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue203Test.php deleted file mode 100644 index 9a786c505..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue203Test.php +++ /dev/null @@ -1,138 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV; - -use Sabre\HTTP; -use Sabre\VObject; - -/** - * This unittest is created to find out why an overwritten DAILY event has wrong DTSTART, DTEND, SUMMARY and RECURRENCEID. - * - * @copyright Copyright (C) fruux GmbH (https://fruux.com/) - * @author Evert Pot (http://evertpot.com/) - * @license http://sabre.io/license/ Modified BSD License - */ -class Issue203Test extends \Sabre\DAVServerTest -{ - protected $setupCalDAV = true; - - protected $caldavCalendars = [ - [ - 'id' => 1, - 'name' => 'Calendar', - 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ], - ]; - - protected $caldavCalendarObjects = [ - 1 => [ - 'event.ics' => [ - 'calendardata' => 'BEGIN:VCALENDAR -VERSION:2.0 -BEGIN:VEVENT -UID:20120330T155305CEST-6585fBUVgV -DTSTAMP:20120330T135305Z -DTSTART;TZID=Europe/Berlin:20120326T155200 -DTEND;TZID=Europe/Berlin:20120326T165200 -RRULE:FREQ=DAILY;COUNT=2;INTERVAL=1 -SUMMARY:original summary -TRANSP:OPAQUE -END:VEVENT -BEGIN:VEVENT -UID:20120330T155305CEST-6585fBUVgV -DTSTAMP:20120330T135352Z -DESCRIPTION: -DTSTART;TZID=Europe/Berlin:20120328T155200 -DTEND;TZID=Europe/Berlin:20120328T165200 -RECURRENCE-ID;TZID=Europe/Berlin:20120327T155200 -SEQUENCE:1 -SUMMARY:overwritten summary -TRANSP:OPAQUE -END:VEVENT -END:VCALENDAR -', - ], - ], - ]; - - public function testIssue203() - { - $request = HTTP\Sapi::createFromServerArray([ - '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="20120325T220000Z" end="20120401T215959Z"/> - </C:calendar-data> - <D:getetag/> - </D:prop> - <C:filter> - <C:comp-filter name="VCALENDAR"> - <C:comp-filter name="VEVENT"> - <C:time-range start="20120325T220000Z" end="20120401T215959Z"/> - </C:comp-filter> - </C:comp-filter> - </C:filter> -</C:calendar-query>'); - - $response = $this->request($request); - - $bodyAsString = $response->getBodyAsString(); - // Everts super awesome xml parser. - $body = substr( - $bodyAsString, - $start = strpos($bodyAsString, 'BEGIN:VCALENDAR'), - strpos($bodyAsString, 'END:VCALENDAR') - $start + 13 - ); - $body = str_replace(' ', '', $body); - - $vObject = VObject\Reader::read($body); - - $this->assertEquals(2, count($vObject->VEVENT)); - - $expectedEvents = [ - [ - 'DTSTART' => '20120326T135200Z', - 'DTEND' => '20120326T145200Z', - 'SUMMARY' => 'original summary', - ], - [ - 'DTSTART' => '20120328T135200Z', - 'DTEND' => '20120328T145200Z', - 'SUMMARY' => 'overwritten summary', - 'RECURRENCE-ID' => '20120327T135200Z', - ], - ]; - - // try to match agains $expectedEvents array - foreach ($expectedEvents as $expectedEvent) { - $matching = false; - - foreach ($vObject->VEVENT as $vevent) { - /** @var $vevent Sabre\VObject\Component\VEvent */ - foreach ($vevent->children() as $child) { - /** @var $child Sabre\VObject\Property */ - if (isset($expectedEvent[$child->name])) { - if ($expectedEvent[$child->name] != $child->getValue()) { - continue 2; - } - } - } - - $matching = true; - break; - } - - $this->assertTrue($matching, 'Did not find the following event in the response: '.var_export($expectedEvent, true)); - } - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue205Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue205Test.php deleted file mode 100644 index b021634ba..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue205Test.php +++ /dev/null @@ -1,99 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV; - -use Sabre\HTTP; -use Sabre\VObject; - -/** - * This unittest is created to check if a VALARM TRIGGER of PT0S is supported. - * - * @copyright Copyright (C) fruux GmbH (https://fruux.com/) - * @author Evert Pot (http://evertpot.com/) - * @license http://sabre.io/license/ Modified BSD License - */ -class Issue205Test extends \Sabre\DAVServerTest -{ - protected $setupCalDAV = true; - - protected $caldavCalendars = [ - [ - 'id' => 1, - 'name' => 'Calendar', - 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ], - ]; - - protected $caldavCalendarObjects = [ - 1 => [ - 'event.ics' => [ - 'calendardata' => 'BEGIN:VCALENDAR -VERSION:2.0 -BEGIN:VEVENT -UID:20120330T155305CEST-6585fBUVgV -DTSTAMP:20120330T135305Z -DTSTART;TZID=Europe/Berlin:20120326T155200 -DTEND;TZID=Europe/Berlin:20120326T165200 -SUMMARY:original summary -TRANSP:OPAQUE -BEGIN:VALARM -ACTION:AUDIO -ATTACH;VALUE=URI:Basso -TRIGGER:PT0S -END:VALARM -END:VEVENT -END:VCALENDAR -', - ], - ], - ]; - - public function testIssue205() - { - $request = HTTP\Sapi::createFromServerArray([ - '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="20120325T220000Z" end="20120401T215959Z"/> - </C:calendar-data> - <D:getetag/> - </D:prop> - <C:filter> - <C:comp-filter name="VCALENDAR"> - <C:comp-filter name="VEVENT"> - <C:comp-filter name="VALARM"> - <C:time-range start="20120325T220000Z" end="20120401T215959Z"/> - </C:comp-filter> - </C:comp-filter> - </C:comp-filter> - </C:filter> -</C:calendar-query>'); - - $response = $this->request($request); - - $this->assertFalse(strpos($response->getBodyAsString(), '<s:exception>Exception</s:exception>'), 'Exception occurred: '.$response->getBodyAsString()); - $this->assertFalse(strpos($response->getBodyAsString(), 'Unknown or bad format'), 'DateTime unknown format Exception: '.$response->getBodyAsString()); - - // Everts super awesome xml parser. - $body = substr( - $response->getBodyAsString(), - $start = strpos($response->getBodyAsString(), 'BEGIN:VCALENDAR'), - strpos($response->getBodyAsString(), 'END:VCALENDAR') - $start + 13 - ); - $body = str_replace(' ', '', $body); - - $vObject = VObject\Reader::read($body); - - $this->assertEquals(1, count($vObject->VEVENT)); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue211Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue211Test.php deleted file mode 100644 index d7fa18c09..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue211Test.php +++ /dev/null @@ -1,90 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV; - -use Sabre\HTTP; - -/** - * This unittest is created to check for an endless loop in Sabre\CalDAV\CalendarQueryValidator. - * - * @copyright Copyright (C) fruux GmbH (https://fruux.com/) - * @author Evert Pot (http://evertpot.com/) - * @license http://sabre.io/license/ Modified BSD License - */ -class Issue211Test extends \Sabre\DAVServerTest -{ - protected $setupCalDAV = true; - - protected $caldavCalendars = [ - [ - 'id' => 1, - 'name' => 'Calendar', - 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ], - ]; - - protected $caldavCalendarObjects = [ - 1 => [ - 'event.ics' => [ - 'calendardata' => 'BEGIN:VCALENDAR -VERSION:2.0 -BEGIN:VEVENT -UID:20120418T172519CEST-3510gh1hVw -DTSTAMP:20120418T152519Z -DTSTART;VALUE=DATE:20120330 -DTEND;VALUE=DATE:20120531 -EXDATE;TZID=Europe/Berlin:20120330T000000 -RRULE:FREQ=YEARLY;INTERVAL=1 -SEQUENCE:1 -SUMMARY:Birthday -TRANSP:TRANSPARENT -BEGIN:VALARM -ACTION:EMAIL -ATTENDEE:MAILTO:xxx@domain.de -DESCRIPTION:Dies ist eine Kalender Erinnerung -SUMMARY:Kalender Alarm Erinnerung -TRIGGER;VALUE=DATE-TIME:20120329T060000Z -END:VALARM -END:VEVENT -END:VCALENDAR -', - ], - ], - ]; - - public function testIssue211() - { - $request = HTTP\Sapi::createFromServerArray([ - '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/> - <D:getetag/> - </D:prop> - <C:filter> - <C:comp-filter name="VCALENDAR"> - <C:comp-filter name="VEVENT"> - <C:comp-filter name="VALARM"> - <C:time-range start="20120426T220000Z" end="20120427T215959Z"/> - </C:comp-filter> - </C:comp-filter> - </C:comp-filter> - </C:filter> -</C:calendar-query>'); - - $response = $this->request($request); - - // if this assert is reached, the endless loop is gone - // There should be no matching events - $this->assertFalse(strpos('BEGIN:VEVENT', $response->getBodyAsString())); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue220Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue220Test.php deleted file mode 100644 index 8e51e49e2..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue220Test.php +++ /dev/null @@ -1,101 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV; - -use Sabre\HTTP; - -/** - * This unittest is created to check for an endless loop in CalendarQueryValidator. - * - * @copyright Copyright (C) fruux GmbH (https://fruux.com/) - * @author Evert Pot (http://evertpot.com/) - * @license http://sabre.io/license/ Modified BSD License - */ -class Issue220Test extends \Sabre\DAVServerTest -{ - protected $setupCalDAV = true; - - protected $caldavCalendars = [ - [ - 'id' => 1, - 'name' => 'Calendar', - 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ], - ]; - - protected $caldavCalendarObjects = [ - 1 => [ - 'event.ics' => [ - 'calendardata' => 'BEGIN:VCALENDAR -VERSION:2.0 -BEGIN:VEVENT -DTSTART;TZID=Europe/Berlin:20120601T180000 -SUMMARY:Brot backen -RRULE:FREQ=DAILY;INTERVAL=1;WKST=MO -TRANSP:OPAQUE -DURATION:PT20M -LAST-MODIFIED:20120601T064634Z -CREATED:20120601T064634Z -DTSTAMP:20120601T064634Z -UID:b64f14c5-dccc-4eda-947f-bdb1f763fbcd -BEGIN:VALARM -TRIGGER;VALUE=DURATION:-PT5M -ACTION:DISPLAY -DESCRIPTION:Default Event Notification -X-WR-ALARMUID:cd952c1b-b3d6-41fb-b0a6-ec3a1a5bdd58 -END:VALARM -END:VEVENT -BEGIN:VEVENT -DTSTART;TZID=Europe/Berlin:20120606T180000 -SUMMARY:Brot backen -TRANSP:OPAQUE -STATUS:CANCELLED -DTEND;TZID=Europe/Berlin:20120606T182000 -LAST-MODIFIED:20120605T094310Z -SEQUENCE:1 -RECURRENCE-ID:20120606T160000Z -UID:b64f14c5-dccc-4eda-947f-bdb1f763fbcd -END:VEVENT -END:VCALENDAR -', - ], - ], - ]; - - public function testIssue220() - { - $request = HTTP\Sapi::createFromServerArray([ - '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/> - <D:getetag/> - </D:prop> - <C:filter> - <C:comp-filter name="VCALENDAR"> - <C:comp-filter name="VEVENT"> - <C:comp-filter name="VALARM"> - <C:time-range start="20120607T161646Z" end="20120612T161646Z"/> - </C:comp-filter> - </C:comp-filter> - </C:comp-filter> - </C:filter> -</C:calendar-query>'); - - $response = $this->request($request); - - $this->assertFalse(strpos($response->getBodyAsString(), '<s:exception>PHPUnit_Framework_Error_Warning</s:exception>'), 'Error Warning occurred: '.$response->getBodyAsString()); - $this->assertFalse(strpos($response->getBodyAsString(), 'Invalid argument supplied for foreach()'), 'Invalid argument supplied for foreach(): '.$response->getBodyAsString()); - - $this->assertEquals(207, $response->status); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue228Test.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Issue228Test.php deleted file mode 100644 index 1f698e7dd..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Issue228Test.php +++ /dev/null @@ -1,80 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV; - -use Sabre\HTTP; - -/** - * This unittest is created to check if the time-range filter is working correctly with all-day-events. - * - * @copyright Copyright (C) fruux GmbH (https://fruux.com/) - * @author Evert Pot (http://evertpot.com/) - * @license http://sabre.io/license/ Modified BSD License - */ -class Issue228Test extends \Sabre\DAVServerTest -{ - protected $setupCalDAV = true; - - protected $caldavCalendars = [ - [ - 'id' => 1, - 'name' => 'Calendar', - 'principaluri' => 'principals/user1', - 'uri' => 'calendar1', - ], - ]; - - protected $caldavCalendarObjects = [ - 1 => [ - 'event.ics' => [ - '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 -', - ], - ], - ]; - - public function testIssue228() - { - $request = HTTP\Sapi::createFromServerArray([ - '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->getBodyAsString(), 'BEGIN:VCALENDAR')); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/CollectionTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/CollectionTest.php deleted file mode 100644 index 594241e0d..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/CollectionTest.php +++ /dev/null @@ -1,78 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV\Notifications; - -use Sabre\CalDAV; - -class CollectionTest extends \PHPUnit\Framework\TestCase -{ - protected $caldavBackend; - protected $principalUri; - protected $notification; - - public function getInstance() - { - $this->principalUri = 'principals/user1'; - - $this->notification = new CalDAV\Xml\Notification\SystemStatus(1, '"1"'); - - $this->caldavBackend = new CalDAV\Backend\MockSharing([], [], [ - 'principals/user1' => [ - $this->notification, - ], - ]); - - return new Collection($this->caldavBackend, $this->principalUri); - } - - public function testGetChildren() - { - $col = $this->getInstance(); - $this->assertEquals('notifications', $col->getName()); - - $this->assertEquals([ - new Node($this->caldavBackend, $this->principalUri, $this->notification), - ], $col->getChildren()); - } - - public function testGetOwner() - { - $col = $this->getInstance(); - $this->assertEquals('principals/user1', $col->getOwner()); - } - - public function testGetGroup() - { - $col = $this->getInstance(); - $this->assertNull($col->getGroup()); - } - - public function testGetACL() - { - $col = $this->getInstance(); - $expected = [ - [ - 'privilege' => '{DAV:}all', - 'principal' => '{DAV:}owner', - 'protected' => true, - ], - ]; - - $this->assertEquals($expected, $col->getACL()); - } - - public function testSetACL() - { - $this->expectException('Sabre\DAV\Exception\Forbidden'); - $col = $this->getInstance(); - $col->setACL([]); - } - - public function testGetSupportedPrivilegeSet() - { - $col = $this->getInstance(); - $this->assertNull($col->getSupportedPrivilegeSet()); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/NodeTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/NodeTest.php deleted file mode 100644 index 623525e69..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Notifications/NodeTest.php +++ /dev/null @@ -1,88 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV\Notifications; - -use Sabre\CalDAV; - -class NodeTest extends \PHPUnit\Framework\TestCase -{ - protected $systemStatus; - protected $caldavBackend; - - public function getInstance() - { - $principalUri = 'principals/user1'; - - $this->systemStatus = new CalDAV\Xml\Notification\SystemStatus(1, '"1"'); - - $this->caldavBackend = new CalDAV\Backend\MockSharing([], [], [ - 'principals/user1' => [ - $this->systemStatus, - ], - ]); - - $node = new Node($this->caldavBackend, 'principals/user1', $this->systemStatus); - - return $node; - } - - public function testGetId() - { - $node = $this->getInstance(); - $this->assertEquals($this->systemStatus->getId().'.xml', $node->getName()); - } - - public function testGetEtag() - { - $node = $this->getInstance(); - $this->assertEquals('"1"', $node->getETag()); - } - - public function testGetNotificationType() - { - $node = $this->getInstance(); - $this->assertEquals($this->systemStatus, $node->getNotificationType()); - } - - public function testDelete() - { - $node = $this->getInstance(); - $node->delete(); - $this->assertEquals([], $this->caldavBackend->getNotificationsForPrincipal('principals/user1')); - } - - public function testGetGroup() - { - $node = $this->getInstance(); - $this->assertNull($node->getGroup()); - } - - public function testGetACL() - { - $node = $this->getInstance(); - $expected = [ - [ - 'privilege' => '{DAV:}all', - 'principal' => '{DAV:}owner', - 'protected' => true, - ], - ]; - - $this->assertEquals($expected, $node->getACL()); - } - - public function testSetACL() - { - $this->expectException('Sabre\DAV\Exception\Forbidden'); - $node = $this->getInstance(); - $node->setACL([]); - } - - public function testGetSupportedPrivilegeSet() - { - $node = $this->getInstance(); - $this->assertNull($node->getSupportedPrivilegeSet()); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/PluginTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/PluginTest.php deleted file mode 100644 index a4f08f7e5..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/PluginTest.php +++ /dev/null @@ -1,1071 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV; - -use DateTime; -use DateTimeZone; -use Sabre\DAV; -use Sabre\DAVACL; -use Sabre\HTTP; - -class PluginTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var DAV\Server - */ - protected $server; - /** - * @var Plugin - */ - protected $plugin; - protected $response; - /** - * @var Backend\PDO - */ - protected $caldavBackend; - - public function setup(): void - { - $caldavNS = '{urn:ietf:params:xml:ns:caldav}'; - - $this->caldavBackend = new Backend\Mock([ - [ - 'id' => 1, - 'uri' => 'UUID-123467', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'user1 calendar', - $caldavNS.'calendar-description' => 'Calendar description', - '{http://apple.com/ns/ical/}calendar-order' => '1', - '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', - $caldavNS.'supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet(['VEVENT', 'VTODO']), - ], - [ - 'id' => 2, - 'uri' => 'UUID-123468', - 'principaluri' => 'principals/user1', - '{DAV:}displayname' => 'user1 calendar2', - $caldavNS.'calendar-description' => 'Calendar description', - '{http://apple.com/ns/ical/}calendar-order' => '1', - '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', - $caldavNS.'supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet(['VEVENT', 'VTODO']), - ], - ], [ - 1 => [ - 'UUID-2345' => [ - 'calendardata' => TestUtil::getTestCalendarData(), - ], - ], - ]); - $principalBackend = new DAVACL\PrincipalBackend\Mock(); - $principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-read', ['principals/user1']); - $principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-write', ['principals/user1']); - $principalBackend->addPrincipal([ - 'uri' => 'principals/admin/calendar-proxy-read', - ]); - $principalBackend->addPrincipal([ - 'uri' => 'principals/admin/calendar-proxy-write', - ]); - - $calendars = new CalendarRoot($principalBackend, $this->caldavBackend); - $principals = new Principal\Collection($principalBackend); - - $root = new DAV\SimpleCollection('root'); - $root->addChild($calendars); - $root->addChild($principals); - - $this->server = new DAV\Server($root); - $this->server->sapi = new HTTP\SapiMock(); - $this->server->debugExceptions = true; - $this->server->setBaseUri('/'); - $this->plugin = new Plugin(); - $this->server->addPlugin($this->plugin); - - // Adding ACL plugin - $aclPlugin = new DAVACL\Plugin(); - $aclPlugin->allowUnauthenticatedAccess = false; - $this->server->addPlugin($aclPlugin); - - // Adding Auth plugin, and ensuring that we are logged in. - $authBackend = new DAV\Auth\Backend\Mock(); - $authBackend->setPrincipal('principals/user1'); - $authPlugin = new DAV\Auth\Plugin($authBackend); - $authPlugin->beforeMethod(new \Sabre\HTTP\Request('GET', '/'), new \Sabre\HTTP\Response()); - $this->server->addPlugin($authPlugin); - - // This forces a login - $authPlugin->beforeMethod(new HTTP\Request('GET', '/'), new HTTP\Response()); - - $this->response = new HTTP\ResponseMock(); - $this->server->httpResponse = $this->response; - } - - public function testSimple() - { - $this->assertEquals(['MKCALENDAR'], $this->plugin->getHTTPMethods('calendars/user1/randomnewcalendar')); - $this->assertEquals(['calendar-access', 'calendar-proxy'], $this->plugin->getFeatures()); - $this->assertEquals( - 'caldav', - $this->plugin->getPluginInfo()['name'] - ); - } - - public function testUnknownMethodPassThrough() - { - $request = new HTTP\Request('MKBREAKFAST', '/'); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(501, $this->response->status, 'Incorrect status returned. Full response body:'.$this->response->getBodyAsString()); - } - - public function testGetWithoutContentType() - { - $request = new HTTP\Request('GET', '/'); - $this->plugin->httpAfterGet($request, $this->response); - $this->assertTrue(true); - } - - public function testReportPassThrough() - { - $request = new HTTP\Request('REPORT', '/', ['Content-Type' => 'application/xml']); - $request->setBody('<?xml version="1.0"?><s:somereport xmlns:s="http://www.rooftopsolutions.nl/NS/example" />'); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(415, $this->response->status); - } - - public function testMkCalendarBadLocation() - { - $request = new HTTP\Request('MKCALENDAR', '/blabla'); - - $body = '<?xml version="1.0" encoding="utf-8" ?> - <C:mkcalendar xmlns:D="DAV:" - xmlns:C="urn:ietf:params:xml:ns:caldav"> - <D:set> - <D:prop> - <D:displayname>Lisa\'s Events</D:displayname> - <C:calendar-description xml:lang="en" - >Calendar restricted to events.</C:calendar-description> - <C:supported-calendar-component-set> - <C:comp name="VEVENT"/> - </C:supported-calendar-component-set> - <C:calendar-timezone><![CDATA[BEGIN:VCALENDAR - PRODID:-//Example Corp.//CalDAV Client//EN - VERSION:2.0 - BEGIN:VTIMEZONE - TZID:US-Eastern - LAST-MODIFIED:19870101T000000Z - BEGIN:STANDARD - DTSTART:19671029T020000 - RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10 - TZOFFSETFROM:-0400 - TZOFFSETTO:-0500 - TZNAME:Eastern Standard Time (US & Canada) - END:STANDARD - BEGIN:DAYLIGHT - DTSTART:19870405T020000 - RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4 - TZOFFSETFROM:-0500 - TZOFFSETTO:-0400 - TZNAME:Eastern Daylight Time (US & Canada) - END:DAYLIGHT - END:VTIMEZONE - END:VCALENDAR - ]]></C:calendar-timezone> - </D:prop> - </D:set> - </C:mkcalendar>'; - - $request->setBody($body); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(403, $this->response->status); - } - - public function testMkCalendarNoParentNode() - { - $request = new HTTP\Request('MKCALENDAR', '/doesntexist/calendar'); - - $body = '<?xml version="1.0" encoding="utf-8" ?> - <C:mkcalendar xmlns:D="DAV:" - xmlns:C="urn:ietf:params:xml:ns:caldav"> - <D:set> - <D:prop> - <D:displayname>Lisa\'s Events</D:displayname> - <C:calendar-description xml:lang="en" - >Calendar restricted to events.</C:calendar-description> - <C:supported-calendar-component-set> - <C:comp name="VEVENT"/> - </C:supported-calendar-component-set> - <C:calendar-timezone><![CDATA[BEGIN:VCALENDAR - PRODID:-//Example Corp.//CalDAV Client//EN - VERSION:2.0 - BEGIN:VTIMEZONE - TZID:US-Eastern - LAST-MODIFIED:19870101T000000Z - BEGIN:STANDARD - DTSTART:19671029T020000 - RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10 - TZOFFSETFROM:-0400 - TZOFFSETTO:-0500 - TZNAME:Eastern Standard Time (US & Canada) - END:STANDARD - BEGIN:DAYLIGHT - DTSTART:19870405T020000 - RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4 - TZOFFSETFROM:-0500 - TZOFFSETTO:-0400 - TZNAME:Eastern Daylight Time (US & Canada) - END:DAYLIGHT - END:VTIMEZONE - END:VCALENDAR - ]]></C:calendar-timezone> - </D:prop> - </D:set> - </C:mkcalendar>'; - - $request->setBody($body); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(409, $this->response->status); - } - - public function testMkCalendarExistingCalendar() - { - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'MKCALENDAR', - 'REQUEST_URI' => '/calendars/user1/UUID-123467', - ]); - - $body = '<?xml version="1.0" encoding="utf-8" ?> - <C:mkcalendar xmlns:D="DAV:" - xmlns:C="urn:ietf:params:xml:ns:caldav"> - <D:set> - <D:prop> - <D:displayname>Lisa\'s Events</D:displayname> - <C:calendar-description xml:lang="en" - >Calendar restricted to events.</C:calendar-description> - <C:supported-calendar-component-set> - <C:comp name="VEVENT"/> - </C:supported-calendar-component-set> - <C:calendar-timezone><![CDATA[BEGIN:VCALENDAR - PRODID:-//Example Corp.//CalDAV Client//EN - VERSION:2.0 - BEGIN:VTIMEZONE - TZID:US-Eastern - LAST-MODIFIED:19870101T000000Z - BEGIN:STANDARD - DTSTART:19671029T020000 - RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10 - TZOFFSETFROM:-0400 - TZOFFSETTO:-0500 - TZNAME:Eastern Standard Time (US & Canada) - END:STANDARD - BEGIN:DAYLIGHT - DTSTART:19870405T020000 - RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4 - TZOFFSETFROM:-0500 - TZOFFSETTO:-0400 - TZNAME:Eastern Daylight Time (US & Canada) - END:DAYLIGHT - END:VTIMEZONE - END:VCALENDAR - ]]></C:calendar-timezone> - </D:prop> - </D:set> - </C:mkcalendar>'; - - $request->setBody($body); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(405, $this->response->status); - } - - public function testMkCalendarSucceed() - { - $request = new HTTP\Request('MKCALENDAR', '/calendars/user1/NEWCALENDAR'); - - $timezone = 'BEGIN:VCALENDAR -PRODID:-//Example Corp.//CalDAV Client//EN -VERSION:2.0 -BEGIN:VTIMEZONE -TZID:US-Eastern -LAST-MODIFIED:19870101T000000Z -BEGIN:STANDARD -DTSTART:19671029T020000 -RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10 -TZOFFSETFROM:-0400 -TZOFFSETTO:-0500 -TZNAME:Eastern Standard Time (US & Canada) -END:STANDARD -BEGIN:DAYLIGHT -DTSTART:19870405T020000 -RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4 -TZOFFSETFROM:-0500 -TZOFFSETTO:-0400 -TZNAME:Eastern Daylight Time (US & Canada) -END:DAYLIGHT -END:VTIMEZONE -END:VCALENDAR'; - - $body = '<?xml version="1.0" encoding="utf-8" ?> - <C:mkcalendar xmlns:D="DAV:" - xmlns:C="urn:ietf:params:xml:ns:caldav"> - <D:set> - <D:prop> - <D:displayname>Lisa\'s Events</D:displayname> - <C:calendar-description xml:lang="en" - >Calendar restricted to events.</C:calendar-description> - <C:supported-calendar-component-set> - <C:comp name="VEVENT"/> - </C:supported-calendar-component-set> - <C:calendar-timezone><![CDATA['.$timezone.']]></C:calendar-timezone> - </D:prop> - </D:set> - </C:mkcalendar>'; - - $request->setBody($body); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(201, $this->response->status, 'Invalid response code received. Full response body: '.$this->response->getBodyAsString()); - - $calendars = $this->caldavBackend->getCalendarsForUser('principals/user1'); - $this->assertEquals(3, count($calendars)); - - $newCalendar = null; - foreach ($calendars as $calendar) { - if ('NEWCALENDAR' === $calendar['uri']) { - $newCalendar = $calendar; - break; - } - } - - $this->assertIsArray($newCalendar); - - $keys = [ - 'uri' => 'NEWCALENDAR', - 'id' => null, - '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar restricted to events.', - '{urn:ietf:params:xml:ns:caldav}calendar-timezone' => $timezone, - '{DAV:}displayname' => 'Lisa\'s Events', - '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => null, - ]; - - foreach ($keys as $key => $value) { - $this->assertArrayHasKey($key, $newCalendar); - - if (is_null($value)) { - continue; - } - $this->assertEquals($value, $newCalendar[$key]); - } - $sccs = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set'; - $this->assertTrue($newCalendar[$sccs] instanceof Xml\Property\SupportedCalendarComponentSet); - $this->assertEquals(['VEVENT'], $newCalendar[$sccs]->getValue()); - } - - public function testMkCalendarEmptyBodySucceed() - { - $request = new HTTP\Request('MKCALENDAR', '/calendars/user1/NEWCALENDAR'); - - $request->setBody(''); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(201, $this->response->status, 'Invalid response code received. Full response body: '.$this->response->getBodyAsString()); - - $calendars = $this->caldavBackend->getCalendarsForUser('principals/user1'); - $this->assertEquals(3, count($calendars)); - - $newCalendar = null; - foreach ($calendars as $calendar) { - if ('NEWCALENDAR' === $calendar['uri']) { - $newCalendar = $calendar; - break; - } - } - - $this->assertIsArray($newCalendar); - - $keys = [ - 'uri' => 'NEWCALENDAR', - 'id' => null, - '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => null, - ]; - - foreach ($keys as $key => $value) { - $this->assertArrayHasKey($key, $newCalendar); - - if (is_null($value)) { - continue; - } - $this->assertEquals($value, $newCalendar[$key]); - } - $sccs = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set'; - $this->assertTrue($newCalendar[$sccs] instanceof Xml\Property\SupportedCalendarComponentSet); - $this->assertEquals(['VEVENT', 'VTODO'], $newCalendar[$sccs]->getValue()); - } - - public function testMkCalendarBadXml() - { - $request = new HTTP\Request('MKCALENDAR', '/blabla'); - $body = 'This is not xml'; - - $request->setBody($body); - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(400, $this->response->status); - } - - public function testPrincipalProperties() - { - $httpRequest = new HTTP\Request('FOO', '/blabla', ['Host' => 'sabredav.org']); - $this->server->httpRequest = $httpRequest; - - $props = $this->server->getPropertiesForPath('/principals/user1', [ - '{'.Plugin::NS_CALDAV.'}calendar-home-set', - '{'.Plugin::NS_CALENDARSERVER.'}calendar-proxy-read-for', - '{'.Plugin::NS_CALENDARSERVER.'}calendar-proxy-write-for', - '{'.Plugin::NS_CALENDARSERVER.'}notification-URL', - '{'.Plugin::NS_CALENDARSERVER.'}email-address-set', - ]); - - $this->assertArrayHasKey(0, $props); - $this->assertArrayHasKey(200, $props[0]); - - $this->assertArrayHasKey('{urn:ietf:params:xml:ns:caldav}calendar-home-set', $props[0][200]); - $prop = $props[0][200]['{urn:ietf:params:xml:ns:caldav}calendar-home-set']; - $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $prop); - $this->assertEquals('calendars/user1/', $prop->getHref()); - - $this->assertArrayHasKey('{http://calendarserver.org/ns/}calendar-proxy-read-for', $props[0][200]); - $prop = $props[0][200]['{http://calendarserver.org/ns/}calendar-proxy-read-for']; - $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $prop); - $this->assertEquals(['principals/admin/'], $prop->getHrefs()); - - $this->assertArrayHasKey('{http://calendarserver.org/ns/}calendar-proxy-write-for', $props[0][200]); - $prop = $props[0][200]['{http://calendarserver.org/ns/}calendar-proxy-write-for']; - $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $prop); - $this->assertEquals(['principals/admin/'], $prop->getHrefs()); - - $this->assertArrayHasKey('{'.Plugin::NS_CALENDARSERVER.'}email-address-set', $props[0][200]); - $prop = $props[0][200]['{'.Plugin::NS_CALENDARSERVER.'}email-address-set']; - $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\EmailAddressSet', $prop); - $this->assertEquals(['user1.sabredav@sabredav.org'], $prop->getValue()); - } - - public function testSupportedReportSetPropertyNonCalendar() - { - $props = $this->server->getPropertiesForPath('/calendars/user1', [ - '{DAV:}supported-report-set', - ]); - - $this->assertArrayHasKey(0, $props); - $this->assertArrayHasKey(200, $props[0]); - $this->assertArrayHasKey('{DAV:}supported-report-set', $props[0][200]); - - $prop = $props[0][200]['{DAV:}supported-report-set']; - - $this->assertInstanceOf('\\Sabre\\DAV\\Xml\\Property\\SupportedReportSet', $prop); - $value = [ - '{DAV:}expand-property', - '{DAV:}principal-match', - '{DAV:}principal-property-search', - '{DAV:}principal-search-property-set', - ]; - $this->assertEquals($value, $prop->getValue()); - } - - /** - * @depends testSupportedReportSetPropertyNonCalendar - */ - public function testSupportedReportSetProperty() - { - $props = $this->server->getPropertiesForPath('/calendars/user1/UUID-123467', [ - '{DAV:}supported-report-set', - ]); - - $this->assertArrayHasKey(0, $props); - $this->assertArrayHasKey(200, $props[0]); - $this->assertArrayHasKey('{DAV:}supported-report-set', $props[0][200]); - - $prop = $props[0][200]['{DAV:}supported-report-set']; - - $this->assertInstanceOf('\\Sabre\\DAV\\Xml\\Property\\SupportedReportSet', $prop); - $value = [ - '{urn:ietf:params:xml:ns:caldav}calendar-multiget', - '{urn:ietf:params:xml:ns:caldav}calendar-query', - '{urn:ietf:params:xml:ns:caldav}free-busy-query', - '{DAV:}expand-property', - '{DAV:}principal-match', - '{DAV:}principal-property-search', - '{DAV:}principal-search-property-set', - ]; - $this->assertEquals($value, $prop->getValue()); - } - - public function testSupportedReportSetUserCalendars() - { - $this->server->addPlugin(new \Sabre\DAV\Sync\Plugin()); - - $props = $this->server->getPropertiesForPath('/calendars/user1', [ - '{DAV:}supported-report-set', - ]); - - $this->assertArrayHasKey(0, $props); - $this->assertArrayHasKey(200, $props[0]); - $this->assertArrayHasKey('{DAV:}supported-report-set', $props[0][200]); - - $prop = $props[0][200]['{DAV:}supported-report-set']; - - $this->assertInstanceOf('\\Sabre\\DAV\\Xml\\Property\\SupportedReportSet', $prop); - $value = [ - '{DAV:}sync-collection', - '{DAV:}expand-property', - '{DAV:}principal-match', - '{DAV:}principal-property-search', - '{DAV:}principal-search-property-set', - ]; - $this->assertEquals($value, $prop->getValue()); - } - - /** - * @depends testSupportedReportSetProperty - */ - public function testCalendarMultiGetReport() - { - $body = - '<?xml version="1.0"?>'. - '<c:calendar-multiget xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">'. - '<d:prop>'. - ' <c:calendar-data />'. - ' <d:getetag />'. - '</d:prop>'. - '<d:href>/calendars/user1/UUID-123467/UUID-2345</d:href>'. - '</c:calendar-multiget>'; - - $request = new HTTP\Request('REPORT', '/calendars/user1', ['Depth' => '1']); - $request->setBody($body); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(207, $this->response->status, 'Invalid HTTP status received. Full response body'); - - $expectedIcal = TestUtil::getTestCalendarData(); - - $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()); - } - - /** - * @depends testCalendarMultiGetReport - */ - public function testCalendarMultiGetReportExpand() - { - $body = - '<?xml version="1.0"?>'. - '<c:calendar-multiget xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">'. - '<d:prop>'. - ' <c:calendar-data>'. - ' <c:expand start="20110101T000000Z" end="20111231T235959Z" />'. - ' </c:calendar-data>'. - ' <d:getetag />'. - '</d:prop>'. - '<d:href>/calendars/user1/UUID-123467/UUID-2345</d:href>'. - '</c:calendar-multiget>'; - - $request = new HTTP\Request('REPORT', '/calendars/user1', ['Depth' => '1']); - $request->setBody($body); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $bodyAsString = $this->response->getBodyAsString(); - $this->assertEquals(207, $this->response->status, 'Invalid HTTP status received. Full response body: '.$bodyAsString); - - $expectedIcal = TestUtil::getTestCalendarData(); - $expectedIcal = \Sabre\VObject\Reader::read($expectedIcal); - $expectedIcal = $expectedIcal->expand( - new DateTime('2011-01-01 00:00:00', new DateTimeZone('UTC')), - new DateTime('2011-12-31 23:59:59', new DateTimeZone('UTC')) - ); - $expectedIcal = str_replace("\r\n", "
\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, $bodyAsString); - } - - /** - * @depends testSupportedReportSetProperty - * @depends testCalendarMultiGetReport - */ - public function testCalendarQueryReport() - { - $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', ['Depth' => '1']); - $request->setBody($body); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $bodyAsString = $this->response->getBodyAsString(); - $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: '.$bodyAsString); - - $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", "
\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, $bodyAsString); - } - - /** - * @depends testSupportedReportSetProperty - * @depends testCalendarMultiGetReport - */ - public function testCalendarQueryReportWindowsPhone() - { - $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', [ - 'Depth' => '0', - 'User-Agent' => 'MSFT-WP/8.10.14219 (gzip)', - ]); - - $request->setBody($body); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $bodyAsString = $this->response->getBodyAsString(); - $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: '.$bodyAsString); - - $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", "
\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, $bodyAsString); - } - - /** - * @depends testSupportedReportSetProperty - * @depends testCalendarMultiGetReport - */ - public function testCalendarQueryReportBadDepth() - { - $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', [ - 'Depth' => '0', - ]); - $request->setBody($body); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(400, $this->response->status, 'Received an unexpected status. Full response body: '.$this->response->getBodyAsString()); - } - - /** - * @depends testCalendarQueryReport - */ - public function testCalendarQueryReportNoCalData() - { - $body = - '<?xml version="1.0"?>'. - '<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">'. - '<d:prop>'. - ' <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', [ - 'Depth' => '1', - ]); - $request->setBody($body); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $bodyAsString = $this->server->httpResponse->getBodyAsString(); - $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: '.$bodyAsString); - - $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> - <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, $bodyAsString); - } - - /** - * @depends testCalendarQueryReport - */ - public function testCalendarQueryReportNoFilters() - { - $body = - '<?xml version="1.0"?>'. - '<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">'. - '<d:prop>'. - ' <c:calendar-data />'. - ' <d:getetag />'. - '</d:prop>'. - '</c:calendar-query>'; - - $request = new HTTP\Request('REPORT', '/calendars/user1/UUID-123467'); - $request->setBody($body); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(400, $this->response->status, 'Received an unexpected status. Full response body: '.$this->response->getBodyAsString()); - } - - /** - * @depends testSupportedReportSetProperty - * @depends testCalendarMultiGetReport - */ - public 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(); - - $bodyAsString = $this->server->httpResponse->getBodyAsString(); - $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: '.$bodyAsString); - - $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", "
\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, $bodyAsString); - } - - /** - * @depends testSupportedReportSetProperty - * @depends testCalendarMultiGetReport - */ - public function testCalendarQueryReport1ObjectNoCalData() - { - $body = - '<?xml version="1.0"?>'. - '<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">'. - '<d:prop>'. - ' <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(); - - $bodyAsString = $this->server->httpResponse->getBodyAsString(); - $this->assertEquals(207, $this->response->status, 'Received an unexpected status. Full response body: '.$bodyAsString); - - $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> - <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, $bodyAsString); - } - - public function testHTMLActionsPanel() - { - $output = ''; - $r = $this->server->emit('onHTMLActionsPanel', [$this->server->tree->getNodeForPath('calendars/user1'), &$output]); - $this->assertFalse($r); - - $this->assertTrue((bool) strpos($output, 'Display name')); - } - - /** - * @depends testCalendarMultiGetReport - */ - public function testCalendarMultiGetReportNoEnd() - { - $body = - '<?xml version="1.0"?>'. - '<c:calendar-multiget xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">'. - '<d:prop>'. - ' <c:calendar-data>'. - ' <c:expand start="20110101T000000Z" />'. - ' </c:calendar-data>'. - ' <d:getetag />'. - '</d:prop>'. - '<d:href>/calendars/user1/UUID-123467/UUID-2345</d:href>'. - '</c:calendar-multiget>'; - - $request = new HTTP\Request('REPORT', '/calendars/user1', ['Depth' => '1']); - $request->setBody($body); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(400, $this->response->status, 'Invalid HTTP status received. Full response body: '.$this->response->getBodyAsString()); - } - - /** - * @depends testCalendarMultiGetReport - */ - public function testCalendarMultiGetReportNoStart() - { - $body = - '<?xml version="1.0"?>'. - '<c:calendar-multiget xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">'. - '<d:prop>'. - ' <c:calendar-data>'. - ' <c:expand end="20110101T000000Z" />'. - ' </c:calendar-data>'. - ' <d:getetag />'. - '</d:prop>'. - '<d:href>/calendars/user1/UUID-123467/UUID-2345</d:href>'. - '</c:calendar-multiget>'; - - $request = new HTTP\Request('REPORT', '/calendars/user1', ['Depth' => '1']); - $request->setBody($body); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(400, $this->response->status, 'Invalid HTTP status received. Full response body: '.$this->response->getBodyAsString()); - } - - /** - * @depends testCalendarMultiGetReport - */ - public function testCalendarMultiGetReportEndBeforeStart() - { - $body = - '<?xml version="1.0"?>'. - '<c:calendar-multiget xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">'. - '<d:prop>'. - ' <c:calendar-data>'. - ' <c:expand start="20200101T000000Z" end="20110101T000000Z" />'. - ' </c:calendar-data>'. - ' <d:getetag />'. - '</d:prop>'. - '<d:href>/calendars/user1/UUID-123467/UUID-2345</d:href>'. - '</c:calendar-multiget>'; - - $request = new HTTP\Request('REPORT', '/calendars/user1', ['Depth' => '1']); - $request->setBody($body); - - $this->server->httpRequest = $request; - $this->server->exec(); - - $this->assertEquals(400, $this->response->status, 'Invalid HTTP status received. Full response body: '.$this->response->getBodyAsString()); - } - - /** - * @depends testSupportedReportSetPropertyNonCalendar - */ - public function testCalendarProperties() - { - $ns = '{urn:ietf:params:xml:ns:caldav}'; - $props = $this->server->getProperties('calendars/user1/UUID-123467', [ - $ns.'max-resource-size', - $ns.'supported-calendar-data', - $ns.'supported-collation-set', - ]); - - $this->assertEquals([ - $ns.'max-resource-size' => 10000000, - $ns.'supported-calendar-data' => new Xml\Property\SupportedCalendarData(), - $ns.'supported-collation-set' => new Xml\Property\SupportedCollationSet(), - ], $props); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/CollectionTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/CollectionTest.php deleted file mode 100644 index 277de0664..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/CollectionTest.php +++ /dev/null @@ -1,20 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV\Principal; - -use Sabre\DAVACL; - -class CollectionTest extends \PHPUnit\Framework\TestCase -{ - public function testGetChildForPrincipal() - { - $back = new DAVACL\PrincipalBackend\Mock(); - $col = new Collection($back); - $r = $col->getChildForPrincipal([ - 'uri' => 'principals/admin', - ]); - $this->assertInstanceOf('Sabre\\CalDAV\\Principal\\User', $r); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyReadTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyReadTest.php deleted file mode 100644 index 95ff86fa1..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyReadTest.php +++ /dev/null @@ -1,91 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV\Principal; - -use Sabre\DAVACL; - -class ProxyReadTest extends \PHPUnit\Framework\TestCase -{ - protected $backend; - - public function getInstance() - { - $backend = new DAVACL\PrincipalBackend\Mock(); - $principal = new ProxyRead($backend, [ - 'uri' => 'principal/user', - ]); - $this->backend = $backend; - - return $principal; - } - - public function testGetName() - { - $i = $this->getInstance(); - $this->assertEquals('calendar-proxy-read', $i->getName()); - } - - public function testGetDisplayName() - { - $i = $this->getInstance(); - $this->assertEquals('calendar-proxy-read', $i->getDisplayName()); - } - - public function testGetLastModified() - { - $i = $this->getInstance(); - $this->assertNull($i->getLastModified()); - } - - public function testDelete() - { - $this->expectException('Sabre\DAV\Exception\Forbidden'); - $i = $this->getInstance(); - $i->delete(); - } - - public function testSetName() - { - $this->expectException('Sabre\DAV\Exception\Forbidden'); - $i = $this->getInstance(); - $i->setName('foo'); - } - - public function testGetAlternateUriSet() - { - $i = $this->getInstance(); - $this->assertEquals([], $i->getAlternateUriSet()); - } - - public function testGetPrincipalUri() - { - $i = $this->getInstance(); - $this->assertEquals('principal/user/calendar-proxy-read', $i->getPrincipalUrl()); - } - - public function testGetGroupMemberSet() - { - $i = $this->getInstance(); - $this->assertEquals([], $i->getGroupMemberSet()); - } - - public function testGetGroupMembership() - { - $i = $this->getInstance(); - $this->assertEquals([], $i->getGroupMembership()); - } - - public function testSetGroupMemberSet() - { - $i = $this->getInstance(); - $i->setGroupMemberSet(['principals/foo']); - - $expected = [ - $i->getPrincipalUrl() => ['principals/foo'], - ]; - - $this->assertEquals($expected, $this->backend->groupMembers); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyWriteTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyWriteTest.php deleted file mode 100644 index df1715ee5..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/ProxyWriteTest.php +++ /dev/null @@ -1,39 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV\Principal; - -use Sabre\DAVACL; - -class ProxyWriteTest extends ProxyReadTest -{ - public function getInstance() - { - $backend = new DAVACL\PrincipalBackend\Mock(); - $principal = new ProxyWrite($backend, [ - 'uri' => 'principal/user', - ]); - $this->backend = $backend; - - return $principal; - } - - public function testGetName() - { - $i = $this->getInstance(); - $this->assertEquals('calendar-proxy-write', $i->getName()); - } - - public function testGetDisplayName() - { - $i = $this->getInstance(); - $this->assertEquals('calendar-proxy-write', $i->getDisplayName()); - } - - public function testGetPrincipalUri() - { - $i = $this->getInstance(); - $this->assertEquals('principal/user/calendar-proxy-write', $i->getPrincipalUrl()); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/UserTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/UserTest.php deleted file mode 100644 index fd079acb2..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Principal/UserTest.php +++ /dev/null @@ -1,111 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV\Principal; - -use Sabre\DAVACL; - -class UserTest extends \PHPUnit\Framework\TestCase -{ - public function getInstance() - { - $backend = new DAVACL\PrincipalBackend\Mock(); - $backend->addPrincipal([ - 'uri' => 'principals/user/calendar-proxy-read', - ]); - $backend->addPrincipal([ - 'uri' => 'principals/user/calendar-proxy-write', - ]); - $backend->addPrincipal([ - 'uri' => 'principals/user/random', - ]); - - return new User($backend, [ - 'uri' => 'principals/user', - ]); - } - - public function testCreateFile() - { - $this->expectException('Sabre\DAV\Exception\Forbidden'); - $u = $this->getInstance(); - $u->createFile('test'); - } - - public function testCreateDirectory() - { - $this->expectException('Sabre\DAV\Exception\Forbidden'); - $u = $this->getInstance(); - $u->createDirectory('test'); - } - - public function testGetChildProxyRead() - { - $u = $this->getInstance(); - $child = $u->getChild('calendar-proxy-read'); - $this->assertInstanceOf('Sabre\\CalDAV\\Principal\\ProxyRead', $child); - } - - public function testGetChildProxyWrite() - { - $u = $this->getInstance(); - $child = $u->getChild('calendar-proxy-write'); - $this->assertInstanceOf('Sabre\\CalDAV\\Principal\\ProxyWrite', $child); - } - - public function testGetChildNotFound() - { - $this->expectException('Sabre\DAV\Exception\NotFound'); - $u = $this->getInstance(); - $child = $u->getChild('foo'); - } - - public function testGetChildNotFound2() - { - $this->expectException('Sabre\DAV\Exception\NotFound'); - $u = $this->getInstance(); - $child = $u->getChild('random'); - } - - public function testGetChildren() - { - $u = $this->getInstance(); - $children = $u->getChildren(); - $this->assertEquals(2, count($children)); - $this->assertInstanceOf('Sabre\\CalDAV\\Principal\\ProxyRead', $children[0]); - $this->assertInstanceOf('Sabre\\CalDAV\\Principal\\ProxyWrite', $children[1]); - } - - public function testChildExist() - { - $u = $this->getInstance(); - $this->assertTrue($u->childExists('calendar-proxy-read')); - $this->assertTrue($u->childExists('calendar-proxy-write')); - $this->assertFalse($u->childExists('foo')); - } - - public function testGetACL() - { - $expected = [ - [ - 'privilege' => '{DAV:}all', - 'principal' => '{DAV:}owner', - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}read', - 'principal' => 'principals/user/calendar-proxy-read', - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}read', - 'principal' => 'principals/user/calendar-proxy-write', - 'protected' => true, - ], - ]; - - $u = $this->getInstance(); - $this->assertEquals($expected, $u->getACL()); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/Schedule/OutboxTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/Schedule/OutboxTest.php deleted file mode 100644 index df70fe7ec..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/Schedule/OutboxTest.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV\Schedule; - -use Sabre\CalDAV; - -class OutboxTest extends \PHPUnit\Framework\TestCase -{ - public function testSetup() - { - $outbox = new Outbox('principals/user1'); - $this->assertEquals('outbox', $outbox->getName()); - $this->assertEquals([], $outbox->getChildren()); - $this->assertEquals('principals/user1', $outbox->getOwner()); - $this->assertEquals(null, $outbox->getGroup()); - - $this->assertEquals([ - [ - 'privilege' => '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-send', - 'principal' => 'principals/user1', - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}read', - 'principal' => 'principals/user1', - 'protected' => true, - ], - [ - 'privilege' => '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-send', - 'principal' => 'principals/user1/calendar-proxy-write', - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}read', - 'principal' => 'principals/user1/calendar-proxy-read', - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}read', - 'principal' => 'principals/user1/calendar-proxy-write', - 'protected' => true, - ], - ], $outbox->getACL()); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/SharedCalendarTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/SharedCalendarTest.php deleted file mode 100644 index 735bbef41..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/SharedCalendarTest.php +++ /dev/null @@ -1,172 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV; - -use Sabre\DAV\Sharing; -use Sabre\DAV\Xml\Element\Sharee; - -class SharedCalendarTest extends \PHPUnit\Framework\TestCase -{ - protected $backend; - - public function getInstance(array $props = null) - { - if (is_null($props)) { - $props = [ - '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, - 'share-access' => Sharing\Plugin::ACCESS_READWRITE, - 'principaluri' => 'principals/sharee', - ]; - } - - $this->backend = new Backend\MockSharing( - [$props], - [], - [] - ); - - $sharee = new Sharee(); - $sharee->href = 'mailto:removeme@example.org'; - $sharee->properties['{DAV:}displayname'] = 'To be removed'; - $sharee->access = Sharing\Plugin::ACCESS_READ; - $this->backend->updateInvites(1, [$sharee]); - - return new SharedCalendar($this->backend, $props); - } - - public function testGetInvites() - { - $sharee = new Sharee(); - $sharee->href = 'mailto:removeme@example.org'; - $sharee->properties['{DAV:}displayname'] = 'To be removed'; - $sharee->access = Sharing\Plugin::ACCESS_READ; - $sharee->inviteStatus = Sharing\Plugin::INVITE_NORESPONSE; - - $this->assertEquals( - [$sharee], - $this->getInstance()->getInvites() - ); - } - - public function testGetOwner() - { - $this->assertEquals('principals/sharee', $this->getInstance()->getOwner()); - } - - public function testGetACL() - { - $expected = [ - [ - 'privilege' => '{DAV:}write', - 'principal' => 'principals/sharee', - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}write', - 'principal' => 'principals/sharee/calendar-proxy-write', - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}write-properties', - 'principal' => 'principals/sharee', - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}write-properties', - 'principal' => 'principals/sharee/calendar-proxy-write', - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}read', - 'principal' => 'principals/sharee', - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}read', - 'principal' => 'principals/sharee/calendar-proxy-read', - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}read', - 'principal' => 'principals/sharee/calendar-proxy-write', - 'protected' => true, - ], - [ - 'privilege' => '{'.Plugin::NS_CALDAV.'}read-free-busy', - 'principal' => '{DAV:}authenticated', - 'protected' => true, - ], - ]; - - $this->assertEquals($expected, $this->getInstance()->getACL()); - } - - public function testGetChildACL() - { - $expected = [ - [ - 'privilege' => '{DAV:}write', - 'principal' => 'principals/sharee', - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}write', - 'principal' => 'principals/sharee/calendar-proxy-write', - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}read', - 'principal' => 'principals/sharee', - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}read', - 'principal' => 'principals/sharee/calendar-proxy-write', - 'protected' => true, - ], - [ - 'privilege' => '{DAV:}read', - 'principal' => 'principals/sharee/calendar-proxy-read', - 'protected' => true, - ], - ]; - - $this->assertEquals($expected, $this->getInstance()->getChildACL()); - } - - public function testUpdateInvites() - { - $instance = $this->getInstance(); - $newSharees = [ - new Sharee(), - new Sharee(), - ]; - $newSharees[0]->href = 'mailto:test@example.org'; - $newSharees[0]->properties['{DAV:}displayname'] = 'Foo Bar'; - $newSharees[0]->comment = 'Booh'; - $newSharees[0]->access = Sharing\Plugin::ACCESS_READWRITE; - - $newSharees[1]->href = 'mailto:removeme@example.org'; - $newSharees[1]->access = Sharing\Plugin::ACCESS_NOACCESS; - - $instance->updateInvites($newSharees); - - $expected = [ - clone $newSharees[0], - ]; - $expected[0]->inviteStatus = Sharing\Plugin::INVITE_NORESPONSE; - $this->assertEquals($expected, $instance->getInvites()); - } - - public function testPublish() - { - $instance = $this->getInstance(); - $this->assertNull($instance->setPublishStatus(true)); - $this->assertNull($instance->setPublishStatus(false)); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/SharingPluginTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/SharingPluginTest.php deleted file mode 100644 index f11af8b95..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/SharingPluginTest.php +++ /dev/null @@ -1,383 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV; - -use Sabre\DAV; -use Sabre\DAV\Xml\Element\Sharee; -use Sabre\DAVServerTest; -use Sabre\HTTP; - -class SharingPluginTest extends DAVServerTest -{ - protected $setupCalDAV = true; - protected $setupCalDAVSharing = true; - protected $setupACL = true; - protected $autoLogin = 'user1'; - - public function setup(): void - { - $this->caldavCalendars = [ - [ - 'principaluri' => 'principals/user1', - 'id' => 1, - 'uri' => 'cal1', - ], - [ - 'principaluri' => 'principals/user1', - 'id' => 2, - 'uri' => 'cal2', - 'share-access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE, - ], - [ - 'principaluri' => 'principals/user1', - 'id' => 3, - 'uri' => 'cal3', - ], - ]; - - parent::setUp(); - - // Making the logged in user an admin, for full access: - $this->aclPlugin->adminPrincipals[] = 'principals/user2'; - } - - public function testSimple() - { - $this->assertInstanceOf('Sabre\\CalDAV\\SharingPlugin', $this->server->getPlugin('caldav-sharing')); - $this->assertEquals( - 'caldav-sharing', - $this->caldavSharingPlugin->getPluginInfo()['name'] - ); - } - - public function testSetupWithoutCoreSharingPlugin() - { - $this->expectException('LogicException'); - $server = new DAV\Server(); - $server->addPlugin( - new SharingPlugin() - ); - } - - public function testGetFeatures() - { - $this->assertEquals(['calendarserver-sharing'], $this->caldavSharingPlugin->getFeatures()); - } - - public function testBeforeGetShareableCalendar() - { - // Forcing the server to authenticate: - $this->authPlugin->beforeMethod(new HTTP\Request('GET', '/'), new HTTP\Response()); - $props = $this->server->getProperties('calendars/user1/cal1', [ - '{'.Plugin::NS_CALENDARSERVER.'}invite', - '{'.Plugin::NS_CALENDARSERVER.'}allowed-sharing-modes', - ]); - - $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\Invite', $props['{'.Plugin::NS_CALENDARSERVER.'}invite']); - $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\AllowedSharingModes', $props['{'.Plugin::NS_CALENDARSERVER.'}allowed-sharing-modes']); - } - - public function testBeforeGetSharedCalendar() - { - $props = $this->server->getProperties('calendars/user1/cal2', [ - '{'.Plugin::NS_CALENDARSERVER.'}shared-url', - '{'.Plugin::NS_CALENDARSERVER.'}invite', - ]); - - $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\Invite', $props['{'.Plugin::NS_CALENDARSERVER.'}invite']); - //$this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $props['{' . Plugin::NS_CALENDARSERVER . '}shared-url']); - } - - public function testUpdateResourceType() - { - $this->caldavBackend->updateInvites(1, - [ - new Sharee([ - 'href' => 'mailto:joe@example.org', - ]), - ] - ); - $result = $this->server->updateProperties('calendars/user1/cal1', [ - '{DAV:}resourcetype' => new DAV\Xml\Property\ResourceType(['{DAV:}collection']), - ]); - - $this->assertEquals([ - '{DAV:}resourcetype' => 200, - ], $result); - - $this->assertEquals(0, count($this->caldavBackend->getInvites(1))); - } - - public function testUpdatePropertiesPassThru() - { - $result = $this->server->updateProperties('calendars/user1/cal3', [ - '{DAV:}foo' => 'bar', - ]); - - $this->assertEquals([ - '{DAV:}foo' => 200, - ], $result); - } - - public function testUnknownMethodNoPOST() - { - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'PATCH', - 'REQUEST_URI' => '/', - ]); - - $response = $this->request($request); - - $this->assertEquals(501, $response->status, $response->getBodyAsString()); - } - - public function testUnknownMethodNoXML() - { - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'POST', - 'REQUEST_URI' => '/', - 'CONTENT_TYPE' => 'text/plain', - ]); - - $response = $this->request($request); - - $this->assertEquals(501, $response->status, $response->getBodyAsString()); - } - - public function testUnknownMethodNoNode() - { - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'POST', - 'REQUEST_URI' => '/foo', - 'CONTENT_TYPE' => 'text/xml', - ]); - - $response = $this->request($request); - - $this->assertEquals(501, $response->status, $response->getBodyAsString()); - } - - public function testShareRequest() - { - $request = new HTTP\Request('POST', '/calendars/user1/cal1', ['Content-Type' => 'text/xml']); - - $xml = <<<RRR -<?xml version="1.0"?> -<cs:share xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:"> - <cs:set> - <d:href>mailto:joe@example.org</d:href> - <cs:common-name>Joe Shmoe</cs:common-name> - <cs:read-write /> - </cs:set> - <cs:remove> - <d:href>mailto:nancy@example.org</d:href> - </cs:remove> -</cs:share> -RRR; - - $request->setBody($xml); - - $this->request($request, 200); - - $this->assertEquals( - [ - new Sharee([ - 'href' => 'mailto:joe@example.org', - 'properties' => [ - '{DAV:}displayname' => 'Joe Shmoe', - ], - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE, - 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_NORESPONSE, - 'comment' => '', - ]), - ], - $this->caldavBackend->getInvites(1) - ); - - // Wiping out tree cache - $this->server->tree->markDirty(''); - - // Verifying that the calendar is now marked shared. - $props = $this->server->getProperties('calendars/user1/cal1', ['{DAV:}resourcetype']); - $this->assertTrue( - $props['{DAV:}resourcetype']->is('{http://calendarserver.org/ns/}shared-owner') - ); - } - - public function testShareRequestNoShareableCalendar() - { - $request = new HTTP\Request( - 'POST', - '/calendars/user1/cal2', - ['Content-Type' => 'text/xml'] - ); - - $xml = '<?xml version="1.0"?> -<cs:share xmlns:cs="'.Plugin::NS_CALENDARSERVER.'" xmlns:d="DAV:"> - <cs:set> - <d:href>mailto:joe@example.org</d:href> - <cs:common-name>Joe Shmoe</cs:common-name> - <cs:read-write /> - </cs:set> - <cs:remove> - <d:href>mailto:nancy@example.org</d:href> - </cs:remove> -</cs:share> -'; - - $request->setBody($xml); - - $this->request($request, 403); - } - - public function testInviteReply() - { - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'POST', - 'REQUEST_URI' => '/calendars/user1', - 'CONTENT_TYPE' => 'text/xml', - ]); - - $xml = '<?xml version="1.0"?> -<cs:invite-reply xmlns:cs="'.Plugin::NS_CALENDARSERVER.'" xmlns:d="DAV:"> - <cs:hosturl><d:href>/principals/owner</d:href></cs:hosturl> - <cs:invite-accepted /> -</cs:invite-reply> -'; - - $request->setBody($xml); - $response = $this->request($request); - $this->assertEquals(200, $response->status, $response->getBodyAsString()); - } - - public function testInviteBadXML() - { - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'POST', - 'REQUEST_URI' => '/calendars/user1', - 'CONTENT_TYPE' => 'text/xml', - ]); - - $xml = '<?xml version="1.0"?> -<cs:invite-reply xmlns:cs="'.Plugin::NS_CALENDARSERVER.'" xmlns:d="DAV:"> -</cs:invite-reply> -'; - $request->setBody($xml); - $response = $this->request($request); - $this->assertEquals(400, $response->status, $response->getBodyAsString()); - } - - public function testInviteWrongUrl() - { - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'POST', - 'REQUEST_URI' => '/calendars/user1/cal1', - 'CONTENT_TYPE' => 'text/xml', - ]); - - $xml = '<?xml version="1.0"?> -<cs:invite-reply xmlns:cs="'.Plugin::NS_CALENDARSERVER.'" xmlns:d="DAV:"> - <cs:hosturl><d:href>/principals/owner</d:href></cs:hosturl> -</cs:invite-reply> -'; - $request->setBody($xml); - $response = $this->request($request); - $this->assertEquals(501, $response->status, $response->getBodyAsString()); - - // If the plugin did not handle this request, it must ensure that the - // body is still accessible by other plugins. - $this->assertEquals($xml, $request->getBody()); - } - - public function testPostWithoutContentType() - { - $request = new HTTP\Request('POST', '/'); - $response = new HTTP\ResponseMock(); - - $this->caldavSharingPlugin->httpPost($request, $response); - $this->assertTrue(true); - } - - public function testPublish() - { - $request = new HTTP\Request('POST', '/calendars/user1/cal1', ['Content-Type' => 'text/xml']); - - $xml = '<?xml version="1.0"?> -<cs:publish-calendar xmlns:cs="'.Plugin::NS_CALENDARSERVER.'" xmlns:d="DAV:" /> -'; - - $request->setBody($xml); - - $response = $this->request($request); - $this->assertEquals(202, $response->status, $response->getBodyAsString()); - } - - public function testUnpublish() - { - $request = new HTTP\Request( - 'POST', - '/calendars/user1/cal1', - ['Content-Type' => 'text/xml'] - ); - - $xml = '<?xml version="1.0"?> -<cs:unpublish-calendar xmlns:cs="'.Plugin::NS_CALENDARSERVER.'" xmlns:d="DAV:" /> -'; - - $request->setBody($xml); - - $response = $this->request($request); - $this->assertEquals(200, $response->status, $response->getBodyAsString()); - } - - public function testPublishWrongUrl() - { - $request = new HTTP\Request( - 'POST', - '/calendars/user1', - ['Content-Type' => 'text/xml'] - ); - - $xml = '<?xml version="1.0"?> -<cs:publish-calendar xmlns:cs="'.Plugin::NS_CALENDARSERVER.'" xmlns:d="DAV:" /> -'; - - $request->setBody($xml); - $this->request($request, 501); - } - - public function testUnpublishWrongUrl() - { - $request = new HTTP\Request( - 'POST', - '/calendars/user1', - ['Content-Type' => 'text/xml'] - ); - $xml = '<?xml version="1.0"?> -<cs:unpublish-calendar xmlns:cs="'.Plugin::NS_CALENDARSERVER.'" xmlns:d="DAV:" /> -'; - - $request->setBody($xml); - - $this->request($request, 501); - } - - public function testUnknownXmlDoc() - { - $request = new HTTP\Request( - 'POST', - '/calendars/user1/cal2', - ['Content-Type' => 'text/xml'] - ); - - $xml = '<?xml version="1.0"?> -<cs:foo-bar xmlns:cs="'.Plugin::NS_CALENDARSERVER.'" xmlns:d="DAV:" />'; - - $request->setBody($xml); - - $response = $this->request($request); - $this->assertEquals(501, $response->status, $response->getBodyAsString()); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/TestUtil.php b/vendor/sabre/dav/tests/Sabre/CalDAV/TestUtil.php deleted file mode 100644 index 5de11a31a..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/TestUtil.php +++ /dev/null @@ -1,102 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV; - -class TestUtil -{ - public static function getBackend() - { - $backend = new Backend\Mock(); - $calendarId = $backend->createCalendar( - 'principals/user1', - 'UUID-123467', - [ - '{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', - ] - ); - $backend->createCalendar( - 'principals/user1', - 'UUID-123468', - [ - '{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', - ] - ); - $backend->createCalendarObject($calendarId, 'UUID-2345', self::getTestCalendarData()); - - return $backend; - } - - public static function getTestCalendarData($type = 1) - { - $calendarData = 'BEGIN:VCALENDAR -VERSION:2.0 -PRODID:-//Apple Inc.//iCal 4.0.1//EN -CALSCALE:GREGORIAN -BEGIN:VTIMEZONE -TZID:Asia/Seoul -BEGIN:DAYLIGHT -TZOFFSETFROM:+0900 -RRULE:FREQ=YEARLY;UNTIL=19880507T150000Z;BYMONTH=5;BYDAY=2SU -DTSTART:19870510T000000 -TZNAME:GMT+09:00 -TZOFFSETTO:+1000 -END:DAYLIGHT -BEGIN:STANDARD -TZOFFSETFROM:+1000 -DTSTART:19881009T000000 -TZNAME:GMT+09:00 -TZOFFSETTO:+0900 -END:STANDARD -END:VTIMEZONE -BEGIN:VEVENT -CREATED:20100225T154229Z -UID:39A6B5ED-DD51-4AFE-A683-C35EE3749627 -TRANSP:TRANSPARENT -SUMMARY:Something here -DTSTAMP:20100228T130202Z'; - - switch ($type) { - case 1: - $calendarData .= "\nDTSTART;TZID=Asia/Seoul:20100223T060000\nDTEND;TZID=Asia/Seoul:20100223T070000\n"; - break; - case 2: - $calendarData .= "\nDTSTART:20100223T060000\nDTEND:20100223T070000\n"; - break; - case 3: - $calendarData .= "\nDTSTART;VALUE=DATE:20100223\nDTEND;VALUE=DATE:20100223\n"; - break; - case 4: - $calendarData .= "\nDTSTART;TZID=Asia/Seoul:20100223T060000\nDURATION:PT1H\n"; - break; - case 5: - $calendarData .= "\nDTSTART;TZID=Asia/Seoul:20100223T060000\nDURATION:-P5D\n"; - break; - case 6: - $calendarData .= "\nDTSTART;VALUE=DATE:20100223\n"; - break; - case 7: - $calendarData .= "\nDTSTART;VALUE=DATETIME:20100223T060000\n"; - break; - - // No DTSTART, so intentionally broken - case 'X': - $calendarData .= "\n"; - break; - } - - $calendarData .= 'ATTENDEE;PARTSTAT=NEEDS-ACTION:mailto:lisa@example.com -SEQUENCE:2 -END:VEVENT -END:VCALENDAR'; - - return $calendarData; - } -} diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php deleted file mode 100644 index 4e2411391..000000000 --- a/vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php +++ /dev/null @@ -1,392 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\CalDAV; - -use Sabre\DAV; -use Sabre\DAVACL; -use Sabre\HTTP; - -class ValidateICalTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var DAV\Server - */ - protected $server; - /** - * @var Sabre\CalDAV\Backend\Mock - */ - protected $calBackend; - - public function setup(): void - { - $calendars = [ - [ - 'id' => 'calendar1', - 'principaluri' => 'principals/admin', - 'uri' => 'calendar1', - '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet(['VEVENT', 'VTODO', 'VJOURNAL']), - ], - [ - 'id' => 'calendar2', - 'principaluri' => 'principals/admin', - 'uri' => 'calendar2', - '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet(['VTODO', 'VJOURNAL']), - ], - ]; - - $this->calBackend = new Backend\Mock($calendars, []); - $principalBackend = new DAVACL\PrincipalBackend\Mock(); - - $tree = [ - new CalendarRoot($principalBackend, $this->calBackend), - ]; - - $this->server = new DAV\Server($tree); - $this->server->sapi = new HTTP\SapiMock(); - $this->server->debugExceptions = true; - - $plugin = new Plugin(); - $this->server->addPlugin($plugin); - - $response = new HTTP\ResponseMock(); - $this->server->httpResponse = $response; - } - - /** - * @return Sabre\HTTP\ResponseMock - */ - public function request(HTTP\Request $request) - { - $this->server->httpRequest = $request; - $this->server->exec(); - - return $this->server->httpResponse; - } - - public function testCreateFile() - { - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', - ]); - - $response = $this->request($request); - - $this->assertEquals(415, $response->status); - } - - public function testCreateFileValid() - { - $request = new HTTP\Request( - 'PUT', - '/calendars/admin/calendar1/blabla.ics', - ['Prefer' => 'handling=strict'] - ); - - $ics = <<<ICS -BEGIN:VCALENDAR -VERSION:2.0 -PRODID:foo -BEGIN:VEVENT -UID:foo -DTSTAMP:20160406T052348Z -DTSTART:20160706T140000Z -END:VEVENT -END:VCALENDAR -ICS; - - $request->setBody($ics); - - $response = $this->request($request); - - $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: '.$response->getBodyAsString()); - $this->assertEquals([ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], - 'ETag' => ['"'.md5($ics).'"'], - ], $response->getHeaders()); - - $expected = [ - 'uri' => 'blabla.ics', - 'calendardata' => $ics, - 'calendarid' => 'calendar1', - 'lastmodified' => null, - ]; - - $this->assertEquals($expected, $this->calBackend->getCalendarObject('calendar1', 'blabla.ics')); - } - - public function testCreateFileNoVersion() - { - $request = new HTTP\Request( - 'PUT', - '/calendars/admin/calendar1/blabla.ics', - ['Prefer' => 'handling=strict'] - ); - - $ics = <<<ICS -BEGIN:VCALENDAR -PRODID:foo -BEGIN:VEVENT -UID:foo -DTSTAMP:20160406T052348Z -DTSTART:20160706T140000Z -END:VEVENT -END:VCALENDAR -ICS; - - $request->setBody($ics); - - $response = $this->request($request); - - $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: '.$response->getBodyAsString()); - } - - public function testCreateFileNoVersionFixed() - { - $request = new HTTP\Request( - 'PUT', - '/calendars/admin/calendar1/blabla.ics', - ['Prefer' => 'handling=lenient'] - ); - - $ics = <<<ICS -BEGIN:VCALENDAR -PRODID:foo -BEGIN:VEVENT -UID:foo -DTSTAMP:20160406T052348Z -DTSTART:20160706T140000Z -END:VEVENT -END:VCALENDAR -ICS; - - $request->setBody($ics); - - $response = $this->request($request); - - $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: '.$response->getBodyAsString()); - $this->assertEquals([ - 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Length' => ['0'], - 'X-Sabre-Ew-Gross' => ['iCalendar validation warning: VERSION MUST appear exactly once in a VCALENDAR component'], - ], $response->getHeaders()); - - $ics = <<<ICS -BEGIN:VCALENDAR\r -VERSION:2.0\r -PRODID:foo\r -BEGIN:VEVENT\r -UID:foo\r -DTSTAMP:20160406T052348Z\r -DTSTART:20160706T140000Z\r -END:VEVENT\r -END:VCALENDAR\r - -ICS; - - $expected = [ - 'uri' => 'blabla.ics', - 'calendardata' => $ics, - 'calendarid' => 'calendar1', - 'lastmodified' => null, - ]; - - $this->assertEquals($expected, $this->calBackend->getCalendarObject('calendar1', 'blabla.ics')); - } - - public function testCreateFileNoComponents() - { - $request = new HTTP\Request( - 'PUT', - '/calendars/admin/calendar1/blabla.ics', - ['Prefer' => 'handling=strict'] - ); - $ics = <<<ICS -BEGIN:VCALENDAR -VERSION:2.0 -PRODID:foo -END:VCALENDAR -ICS; - - $request->setBody($ics); - - $response = $this->request($request); - $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: '.$response->getBodyAsString()); - } - - public function testCreateFileNoUID() - { - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', - ]); - $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); - - $response = $this->request($request); - - $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: '.$response->getBodyAsString()); - } - - public function testCreateFileVCard() - { - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', - ]); - $request->setBody("BEGIN:VCARD\r\nEND:VCARD\r\n"); - - $response = $this->request($request); - - $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: '.$response->getBodyAsString()); - } - - public function testCreateFile2Components() - { - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', - ]); - $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nBEGIN:VJOURNAL\r\nUID:foo\r\nEND:VJOURNAL\r\nEND:VCALENDAR\r\n"); - - $response = $this->request($request); - - $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: '.$response->getBodyAsString()); - } - - public function testCreateFile2UIDS() - { - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', - ]); - $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nBEGIN:VEVENT\r\nUID:bar\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); - - $response = $this->request($request); - - $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: '.$response->getBodyAsString()); - } - - public function testCreateFileWrongComponent() - { - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', - ]); - $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nEND:VTIMEZONE\r\nBEGIN:VFREEBUSY\r\nUID:foo\r\nEND:VFREEBUSY\r\nEND:VCALENDAR\r\n"); - - $response = $this->request($request); - - $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: '.$response->getBodyAsString()); - } - - public function testUpdateFile() - { - $this->calBackend->createCalendarObject('calendar1', 'blabla.ics', 'foo'); - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics', - ]); - - $response = $this->request($request); - - $this->assertEquals(415, $response->status); - } - - public function testUpdateFileParsableBody() - { - $this->calBackend->createCalendarObject('calendar1', 'blabla.ics', 'foo'); - $request = new HTTP\Request( - 'PUT', - '/calendars/admin/calendar1/blabla.ics' - ); - $ics = <<<ICS -BEGIN:VCALENDAR -VERSION:2.0 -PRODID:foo -BEGIN:VEVENT -UID:foo -DTSTAMP:20160406T052348Z -DTSTART:20160706T140000Z -END:VEVENT -END:VCALENDAR -ICS; - - $request->setBody($ics); - $response = $this->request($request); - - $this->assertEquals(204, $response->status); - - $expected = [ - 'uri' => 'blabla.ics', - 'calendardata' => $ics, - 'calendarid' => 'calendar1', - 'lastmodified' => null, - ]; - - $this->assertEquals($expected, $this->calBackend->getCalendarObject('calendar1', 'blabla.ics')); - } - - public function testCreateFileInvalidComponent() - { - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar2/blabla.ics', - ]); - $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); - - $response = $this->request($request); - - $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: '.$response->getBodyAsString()); - } - - public function testUpdateFileInvalidComponent() - { - $this->calBackend->createCalendarObject('calendar2', 'blabla.ics', 'foo'); - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'PUT', - 'REQUEST_URI' => '/calendars/admin/calendar2/blabla.ics', - ]); - $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); - - $response = $this->request($request); - - $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: '.$response->getBodyAsString()); - } - - /** - * What we are testing here, is if we send in a latin1 character, the - * server should automatically transform this into UTF-8. - * - * More importantly. If any transformation happens, the etag must no longer - * be returned by the server. - */ - public function testCreateFileModified() - { - $request = new HTTP\Request( - 'PUT', - '/calendars/admin/calendar1/blabla.ics' - ); - $ics = <<<ICS -BEGIN:VCALENDAR -VERSION:2.0 -PRODID:foo -BEGIN:VEVENT -UID:foo -SUMMARY:Meeting in M\xfcnster -DTSTAMP:20160406T052348Z -DTSTART:20160706T140000Z -END:VEVENT -END:VCALENDAR -ICS; - - $request->setBody($ics); - - $response = $this->request($request); - - $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: '.$response->getBodyAsString()); - $this->assertNull($response->getHeader('ETag')); - } -} |