aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php')
-rw-r--r--vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php167
1 files changed, 76 insertions, 91 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php
index 629df90c1..e6d1edace 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CalDAV;
use Sabre\DAV;
@@ -8,8 +10,8 @@ use Sabre\HTTP;
require_once 'Sabre/HTTP/ResponseMock.php';
-class ValidateICalTest extends \PHPUnit_Framework_TestCase {
-
+class ValidateICalTest extends \PHPUnit\Framework\TestCase
+{
/**
* @var Sabre\DAV\Server
*/
@@ -19,21 +21,21 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
*/
protected $calBackend;
- function setUp() {
-
+ public function setUp()
+ {
$calendars = [
[
- 'id' => 'calendar1',
- 'principaluri' => 'principals/admin',
- 'uri' => 'calendar1',
+ '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',
+ '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, []);
@@ -52,33 +54,30 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
$response = new HTTP\ResponseMock();
$this->server->httpResponse = $response;
-
}
- function request(HTTP\Request $request) {
-
+ public function request(HTTP\Request $request)
+ {
$this->server->httpRequest = $request;
$this->server->exec();
return $this->server->httpResponse;
-
}
- function testCreateFile() {
-
+ public function testCreateFile()
+ {
$request = HTTP\Sapi::createFromServerArray([
'REQUEST_METHOD' => 'PUT',
- 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
+ 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
]);
$response = $this->request($request);
$this->assertEquals(415, $response->status);
-
}
- function testCreateFileValid() {
-
+ public function testCreateFileValid()
+ {
$request = new HTTP\Request(
'PUT',
'/calendars/admin/calendar1/blabla.ics',
@@ -101,26 +100,25 @@ ICS;
$response = $this->request($request);
- $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
+ $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: '.$response->body);
$this->assertEquals([
'X-Sabre-Version' => [DAV\Version::VERSION],
- 'Content-Length' => ['0'],
- 'ETag' => ['"' . md5($ics) . '"'],
+ 'Content-Length' => ['0'],
+ 'ETag' => ['"'.md5($ics).'"'],
], $response->getHeaders());
$expected = [
- 'uri' => 'blabla.ics',
+ 'uri' => 'blabla.ics',
'calendardata' => $ics,
- 'calendarid' => 'calendar1',
+ 'calendarid' => 'calendar1',
'lastmodified' => null,
];
$this->assertEquals($expected, $this->calBackend->getCalendarObject('calendar1', 'blabla.ics'));
-
}
- function testCreateFileNoVersion() {
-
+ public function testCreateFileNoVersion()
+ {
$request = new HTTP\Request(
'PUT',
'/calendars/admin/calendar1/blabla.ics',
@@ -142,12 +140,11 @@ ICS;
$response = $this->request($request);
- $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
-
+ $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: '.$response->body);
}
- function testCreateFileNoVersionFixed() {
-
+ public function testCreateFileNoVersionFixed()
+ {
$request = new HTTP\Request(
'PUT',
'/calendars/admin/calendar1/blabla.ics',
@@ -169,10 +166,10 @@ ICS;
$response = $this->request($request);
- $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
+ $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: '.$response->body);
$this->assertEquals([
- 'X-Sabre-Version' => [DAV\Version::VERSION],
- 'Content-Length' => ['0'],
+ '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());
@@ -190,18 +187,17 @@ END:VCALENDAR\r
ICS;
$expected = [
- 'uri' => 'blabla.ics',
+ 'uri' => 'blabla.ics',
'calendardata' => $ics,
- 'calendarid' => 'calendar1',
+ 'calendarid' => 'calendar1',
'lastmodified' => null,
];
$this->assertEquals($expected, $this->calBackend->getCalendarObject('calendar1', 'blabla.ics'));
-
}
- function testCreateFileNoComponents() {
-
+ public function testCreateFileNoComponents()
+ {
$request = new HTTP\Request(
'PUT',
'/calendars/admin/calendar1/blabla.ics',
@@ -217,96 +213,89 @@ ICS;
$request->setBody($ics);
$response = $this->request($request);
- $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
-
+ $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: '.$response->body);
}
- function testCreateFileNoUID() {
-
+ public function testCreateFileNoUID()
+ {
$request = HTTP\Sapi::createFromServerArray([
'REQUEST_METHOD' => 'PUT',
- 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
+ '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->body);
-
+ $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: '.$response->body);
}
- function testCreateFileVCard() {
-
+ public function testCreateFileVCard()
+ {
$request = HTTP\Sapi::createFromServerArray([
'REQUEST_METHOD' => 'PUT',
- 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
+ '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->body);
-
+ $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: '.$response->body);
}
- function testCreateFile2Components() {
-
+ public function testCreateFile2Components()
+ {
$request = HTTP\Sapi::createFromServerArray([
'REQUEST_METHOD' => 'PUT',
- 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
+ '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->body);
-
+ $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: '.$response->body);
}
- function testCreateFile2UIDS() {
-
+ public function testCreateFile2UIDS()
+ {
$request = HTTP\Sapi::createFromServerArray([
'REQUEST_METHOD' => 'PUT',
- 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
+ '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->body);
-
+ $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: '.$response->body);
}
- function testCreateFileWrongComponent() {
-
+ public function testCreateFileWrongComponent()
+ {
$request = HTTP\Sapi::createFromServerArray([
'REQUEST_METHOD' => 'PUT',
- 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
+ '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->body);
-
+ $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: '.$response->body);
}
- function testUpdateFile() {
-
+ public function testUpdateFile()
+ {
$this->calBackend->createCalendarObject('calendar1', 'blabla.ics', 'foo');
$request = HTTP\Sapi::createFromServerArray([
'REQUEST_METHOD' => 'PUT',
- 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
+ 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
]);
$response = $this->request($request);
$this->assertEquals(415, $response->status);
-
}
- function testUpdateFileParsableBody() {
-
+ public function testUpdateFileParsableBody()
+ {
$this->calBackend->createCalendarObject('calendar1', 'blabla.ics', 'foo');
$request = new HTTP\Request(
'PUT',
@@ -330,43 +319,40 @@ ICS;
$this->assertEquals(204, $response->status);
$expected = [
- 'uri' => 'blabla.ics',
+ 'uri' => 'blabla.ics',
'calendardata' => $ics,
- 'calendarid' => 'calendar1',
+ 'calendarid' => 'calendar1',
'lastmodified' => null,
];
$this->assertEquals($expected, $this->calBackend->getCalendarObject('calendar1', 'blabla.ics'));
-
}
- function testCreateFileInvalidComponent() {
-
+ public function testCreateFileInvalidComponent()
+ {
$request = HTTP\Sapi::createFromServerArray([
'REQUEST_METHOD' => 'PUT',
- 'REQUEST_URI' => '/calendars/admin/calendar2/blabla.ics',
+ '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->body);
-
+ $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: '.$response->body);
}
- function testUpdateFileInvalidComponent() {
-
+ 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_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->body);
-
+ $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: '.$response->body);
}
/**
@@ -376,8 +362,8 @@ ICS;
* More importantly. If any transformation happens, the etag must no longer
* be returned by the server.
*/
- function testCreateFileModified() {
-
+ public function testCreateFileModified()
+ {
$request = new HTTP\Request(
'PUT',
'/calendars/admin/calendar1/blabla.ics'
@@ -399,8 +385,7 @@ ICS;
$response = $this->request($request);
- $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
+ $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: '.$response->body);
$this->assertNull($response->getHeader('ETag'));
-
}
}