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.php91
1 files changed, 61 insertions, 30 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php
index 6634b9c3b..be166d9e6 100644
--- a/vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php
+++ b/vendor/sabre/dav/tests/Sabre/CalDAV/ValidateICalTest.php
@@ -26,24 +26,25 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
'id' => 'calendar1',
'principaluri' => 'principals/admin',
'uri' => 'calendar1',
- '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Property\SupportedCalendarComponentSet( array('VEVENT','VTODO','VJOURNAL') ),
+ '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet( ['VEVENT','VTODO','VJOURNAL'] ),
),
array(
'id' => 'calendar2',
'principaluri' => 'principals/admin',
'uri' => 'calendar2',
- '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Property\SupportedCalendarComponentSet( array('VTODO','VJOURNAL') ),
+ '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet( ['VTODO','VJOURNAL'] ),
)
);
- $this->calBackend = new Backend\Mock($calendars,array());
+ $this->calBackend = new Backend\Mock($calendars, []);
$principalBackend = new DAVACL\PrincipalBackend\Mock();
- $tree = array(
- new CalendarRootNode($principalBackend, $this->calBackend),
- );
+ $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();
@@ -65,20 +66,20 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
function testCreateFile() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PUT',
'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
));
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 415 Unsupported Media Type', $response->status);
+ $this->assertEquals(415, $response->status);
}
function testCreateFileValid() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PUT',
'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
));
@@ -86,11 +87,18 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 201 Created', $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(array(
+ 'X-Sabre-Version' => [DAV\Version::VERSION],
+ 'Content-Length' => ['0'],
+ 'ETag' => ['"' . md5("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n") . '"'],
+ ), $response->getHeaders());
+
$expected = array(
'uri' => 'blabla.ics',
'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n",
'calendarid' => 'calendar1',
+ 'lastmodified' => null,
);
$this->assertEquals($expected, $this->calBackend->getCalendarObject('calendar1','blabla.ics'));
@@ -99,7 +107,7 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
function testCreateFileNoComponents() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PUT',
'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
));
@@ -107,13 +115,13 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 400 Bad request', $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
+ $this->assertEquals(400, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
}
function testCreateFileNoUID() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PUT',
'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
));
@@ -121,13 +129,13 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 400 Bad request', $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
+ $this->assertEquals(400, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
}
function testCreateFileVCard() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PUT',
'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
));
@@ -135,13 +143,13 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 415 Unsupported Media Type', $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() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PUT',
'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
));
@@ -149,13 +157,13 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 400 Bad request', $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
+ $this->assertEquals(400, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
}
function testCreateFile2UIDS() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PUT',
'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
));
@@ -163,13 +171,13 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 400 Bad request', $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
+ $this->assertEquals(400, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
}
function testCreateFileWrongComponent() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PUT',
'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
));
@@ -177,28 +185,28 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 400 Bad request', $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
+ $this->assertEquals(400, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
}
function testUpdateFile() {
$this->calBackend->createCalendarObject('calendar1','blabla.ics','foo');
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PUT',
'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
));
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 415 Unsupported Media Type', $response->status);
+ $this->assertEquals(415, $response->status);
}
function testUpdateFileParsableBody() {
$this->calBackend->createCalendarObject('calendar1','blabla.ics','foo');
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PUT',
'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
));
@@ -207,12 +215,13 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 204 No Content', $response->status);
+ $this->assertEquals(204, $response->status);
$expected = array(
'uri' => 'blabla.ics',
'calendardata' => $body,
'calendarid' => 'calendar1',
+ 'lastmodified' => null,
);
$this->assertEquals($expected, $this->calBackend->getCalendarObject('calendar1','blabla.ics'));
@@ -221,7 +230,7 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
function testCreateFileInvalidComponent() {
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PUT',
'REQUEST_URI' => '/calendars/admin/calendar2/blabla.ics',
));
@@ -229,14 +238,14 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 403 Forbidden', $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() {
$this->calBackend->createCalendarObject('calendar2','blabla.ics','foo');
- $request = new HTTP\Request(array(
+ $request = HTTP\Sapi::createFromServerArray(array(
'REQUEST_METHOD' => 'PUT',
'REQUEST_URI' => '/calendars/admin/calendar2/blabla.ics',
));
@@ -244,7 +253,29 @@ class ValidateICalTest extends \PHPUnit_Framework_TestCase {
$response = $this->request($request);
- $this->assertEquals('HTTP/1.1 403 Forbidden', $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
+ $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
+
+ }
+
+ /**
+ * 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.
+ */
+ function testCreateFileModified() {
+
+ $request = HTTP\Sapi::createFromServerArray(array(
+ 'REQUEST_METHOD' => 'PUT',
+ 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
+ ));
+ $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:foo\r\nSUMMARY:Meeting in M\xfcnster\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
+
+ $response = $this->request($request);
+
+ $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
+ $this->assertNull($response->getHeader('ETag'));
}
}