From 0b02a6d123b2014705998c94ddf3d460948d3eac Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 10 May 2016 17:26:44 -0700 Subject: initial sabre upgrade (needs lots of work - to wit: authentication, redo the browser interface, and rework event export/import) --- .../sabre/dav/tests/Sabre/DAV/ServerMKCOLTest.php | 159 +++++++++------------ 1 file changed, 67 insertions(+), 92 deletions(-) (limited to 'vendor/sabre/dav/tests/Sabre/DAV/ServerMKCOLTest.php') diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerMKCOLTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerMKCOLTest.php index 34b084dcd..e35189ec3 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/ServerMKCOLTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerMKCOLTest.php @@ -4,10 +4,6 @@ namespace Sabre\DAV; use Sabre\HTTP; -require_once 'Sabre/HTTP/ResponseMock.php'; -require_once 'Sabre/DAV/AbstractServer.php'; -require_once 'Sabre/DAV/Exception.php'; - class ServerMKCOLTest extends AbstractServer { function testMkcol() { @@ -17,16 +13,17 @@ class ServerMKCOLTest extends AbstractServer { 'REQUEST_METHOD' => 'MKCOL', ); - $request = new HTTP\Request($serverVars); + $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody(""); $this->server->httpRequest = ($request); $this->server->exec(); $this->assertEquals(array( - 'Content-Length' => '0', - ),$this->response->headers); + 'X-Sabre-Version' => [Version::VERSION], + 'Content-Length' => ['0'], + ),$this->response->getHeaders()); - $this->assertEquals('HTTP/1.1 201 Created',$this->response->status); + $this->assertEquals(201, $this->response->status); $this->assertEquals('', $this->response->body); $this->assertTrue(is_dir($this->tempDir . '/testcol')); @@ -42,16 +39,17 @@ class ServerMKCOLTest extends AbstractServer { 'REQUEST_METHOD' => 'MKCOL', ); - $request = new HTTP\Request($serverVars); + $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody("Hello"); $this->server->httpRequest = ($request); $this->server->exec(); $this->assertEquals(array( - 'Content-Type' => 'application/xml; charset=utf-8', - ),$this->response->headers); + 'X-Sabre-Version' => [Version::VERSION], + 'Content-Type' => ['application/xml; charset=utf-8'], + ),$this->response->getHeaders()); - $this->assertEquals('HTTP/1.1 415 Unsupported Media Type',$this->response->status); + $this->assertEquals(415, $this->response->status); } @@ -66,16 +64,17 @@ class ServerMKCOLTest extends AbstractServer { 'HTTP_CONTENT_TYPE' => 'application/xml', ); - $request = new HTTP\Request($serverVars); + $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody("Hello"); $this->server->httpRequest = ($request); $this->server->exec(); $this->assertEquals(array( - 'Content-Type' => 'application/xml; charset=utf-8', - ),$this->response->headers); + 'X-Sabre-Version' => [Version::VERSION], + 'Content-Type' => ['application/xml; charset=utf-8'], + ),$this->response->getHeaders()); - $this->assertEquals('HTTP/1.1 400 Bad request',$this->response->status); + $this->assertEquals(400, $this->response->getStatus(), $this->response->getBodyAsString() ); } @@ -90,16 +89,17 @@ class ServerMKCOLTest extends AbstractServer { 'HTTP_CONTENT_TYPE' => 'application/xml', ); - $request = new HTTP\Request($serverVars); + $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody(''); $this->server->httpRequest = ($request); $this->server->exec(); $this->assertEquals(array( - 'Content-Type' => 'application/xml; charset=utf-8', - ),$this->response->headers); + 'X-Sabre-Version' => [Version::VERSION], + 'Content-Type' => ['application/xml; charset=utf-8'], + ),$this->response->getHeaders()); - $this->assertEquals('HTTP/1.1 415 Unsupported Media Type',$this->response->status); + $this->assertEquals(400, $this->response->getStatus()); } @@ -114,7 +114,7 @@ class ServerMKCOLTest extends AbstractServer { 'HTTP_CONTENT_TYPE' => 'application/xml', ); - $request = new HTTP\Request($serverVars); + $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody(' @@ -127,15 +127,16 @@ class ServerMKCOLTest extends AbstractServer { $this->server->exec(); $this->assertEquals(array( - 'Content-Type' => 'application/xml; charset=utf-8', - ),$this->response->headers); + 'X-Sabre-Version' => [Version::VERSION], + 'Content-Type' => ['application/xml; charset=utf-8'], + ),$this->response->getHeaders()); - $this->assertEquals('HTTP/1.1 400 Bad request',$this->response->status,'Wrong statuscode received. Full response body: ' .$this->response->body); + $this->assertEquals(400, $this->response->status, 'Wrong statuscode received. Full response body: ' .$this->response->body); } /** - * @depends testMKCOLNoResourceType + * @depends testMkcol */ function testMKCOLIncorrectResourceType() { @@ -145,38 +146,7 @@ class ServerMKCOLTest extends AbstractServer { 'HTTP_CONTENT_TYPE' => 'application/xml', ); - $request = new HTTP\Request($serverVars); - $request->setBody(' - - - - - - -'); - $this->server->httpRequest = ($request); - $this->server->exec(); - - $this->assertEquals(array( - 'Content-Type' => 'application/xml; charset=utf-8', - ),$this->response->headers); - - $this->assertEquals('HTTP/1.1 403 Forbidden',$this->response->status,'Wrong statuscode received. Full response body: ' .$this->response->body); - - } - - /** - * @depends testMKCOLIncorrectResourceType - */ - function testMKCOLIncorrectResourceType2() { - - $serverVars = array( - 'REQUEST_URI' => '/testcol', - 'REQUEST_METHOD' => 'MKCOL', - 'HTTP_CONTENT_TYPE' => 'application/xml', - ); - - $request = new HTTP\Request($serverVars); + $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody(' @@ -189,15 +159,16 @@ class ServerMKCOLTest extends AbstractServer { $this->server->exec(); $this->assertEquals(array( - 'Content-Type' => 'application/xml; charset=utf-8', - ),$this->response->headers); + 'X-Sabre-Version' => [Version::VERSION], + 'Content-Type' => ['application/xml; charset=utf-8'], + ),$this->response->getHeaders()); - $this->assertEquals('HTTP/1.1 403 Forbidden',$this->response->status,'Wrong statuscode received. Full response body: ' .$this->response->body); + $this->assertEquals(403, $this->response->status, 'Wrong statuscode received. Full response body: ' .$this->response->body); } /** - * @depends testMKCOLIncorrectResourceType2 + * @depends testMKCOLIncorrectResourceType */ function testMKCOLSuccess() { @@ -207,7 +178,7 @@ class ServerMKCOLTest extends AbstractServer { 'HTTP_CONTENT_TYPE' => 'application/xml', ); - $request = new HTTP\Request($serverVars); + $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody(' @@ -220,15 +191,16 @@ class ServerMKCOLTest extends AbstractServer { $this->server->exec(); $this->assertEquals(array( - 'Content-Length' => '0', - ),$this->response->headers); + 'X-Sabre-Version' => [Version::VERSION], + 'Content-Length' => ['0'], + ),$this->response->getHeaders()); - $this->assertEquals('HTTP/1.1 201 Created',$this->response->status,'Wrong statuscode received. Full response body: ' .$this->response->body); + $this->assertEquals(201, $this->response->status, 'Wrong statuscode received. Full response body: ' .$this->response->body); } /** - * @depends testMKCOLIncorrectResourceType2 + * @depends testMKCOLIncorrectResourceType */ function testMKCOLWhiteSpaceResourceType() { @@ -238,7 +210,7 @@ class ServerMKCOLTest extends AbstractServer { 'HTTP_CONTENT_TYPE' => 'application/xml', ); - $request = new HTTP\Request($serverVars); + $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody(' @@ -253,15 +225,16 @@ class ServerMKCOLTest extends AbstractServer { $this->server->exec(); $this->assertEquals(array( - 'Content-Length' => '0', - ),$this->response->headers); + 'X-Sabre-Version' => [Version::VERSION], + 'Content-Length' => ['0'], + ),$this->response->getHeaders()); - $this->assertEquals('HTTP/1.1 201 Created',$this->response->status,'Wrong statuscode received. Full response body: ' .$this->response->body); + $this->assertEquals(201, $this->response->status, 'Wrong statuscode received. Full response body: ' .$this->response->body); } /** - * @depends testMKCOLIncorrectResourceType2 + * @depends testMKCOLIncorrectResourceType */ function testMKCOLNoParent() { @@ -270,22 +243,23 @@ class ServerMKCOLTest extends AbstractServer { 'REQUEST_METHOD' => 'MKCOL', ); - $request = new HTTP\Request($serverVars); + $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody(''); $this->server->httpRequest = ($request); $this->server->exec(); $this->assertEquals(array( - 'Content-Type' => 'application/xml; charset=utf-8', - ),$this->response->headers); + 'X-Sabre-Version' => [Version::VERSION], + 'Content-Type' => ['application/xml; charset=utf-8'], + ),$this->response->getHeaders()); - $this->assertEquals('HTTP/1.1 409 Conflict',$this->response->status,'Wrong statuscode received. Full response body: ' .$this->response->body); + $this->assertEquals(409, $this->response->status, 'Wrong statuscode received. Full response body: ' .$this->response->body); } /** - * @depends testMKCOLIncorrectResourceType2 + * @depends testMKCOLIncorrectResourceType */ function testMKCOLParentIsNoCollection() { @@ -294,22 +268,23 @@ class ServerMKCOLTest extends AbstractServer { 'REQUEST_METHOD' => 'MKCOL', ); - $request = new HTTP\Request($serverVars); + $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody(''); $this->server->httpRequest = ($request); $this->server->exec(); $this->assertEquals(array( - 'Content-Type' => 'application/xml; charset=utf-8', - ),$this->response->headers); + 'X-Sabre-Version' => [Version::VERSION], + 'Content-Type' => ['application/xml; charset=utf-8'], + ),$this->response->getHeaders()); - $this->assertEquals('HTTP/1.1 409 Conflict',$this->response->status,'Wrong statuscode received. Full response body: ' .$this->response->body); + $this->assertEquals(409, $this->response->status, 'Wrong statuscode received. Full response body: ' .$this->response->body); } /** - * @depends testMKCOLIncorrectResourceType2 + * @depends testMKCOLIncorrectResourceType */ function testMKCOLAlreadyExists() { @@ -318,18 +293,19 @@ class ServerMKCOLTest extends AbstractServer { 'REQUEST_METHOD' => 'MKCOL', ); - $request = new HTTP\Request($serverVars); + $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody(''); $this->server->httpRequest = ($request); $this->server->exec(); $this->assertEquals(array( - 'Content-Type' => 'application/xml; charset=utf-8', - 'Allow' => 'OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT', - ),$this->response->headers); + 'X-Sabre-Version' => [Version::VERSION], + 'Content-Type' => ['application/xml; charset=utf-8'], + 'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT'], + ),$this->response->getHeaders()); - $this->assertEquals('HTTP/1.1 405 Method Not Allowed',$this->response->status,'Wrong statuscode received. Full response body: ' .$this->response->body); + $this->assertEquals(405, $this->response->status, 'Wrong statuscode received. Full response body: ' .$this->response->body); } @@ -345,7 +321,7 @@ class ServerMKCOLTest extends AbstractServer { 'HTTP_CONTENT_TYPE' => 'application/xml', ); - $request = new HTTP\Request($serverVars); + $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody(' @@ -358,13 +334,12 @@ class ServerMKCOLTest extends AbstractServer { $this->server->httpRequest = ($request); $this->server->exec(); - $this->assertEquals('HTTP/1.1 207 Multi-Status',$this->response->status,'Wrong statuscode received. Full response body: ' .$this->response->body); + $this->assertEquals(207, $this->response->status, 'Wrong statuscode received. Full response body: ' .$this->response->body); $this->assertEquals(array( - 'Content-Type' => 'application/xml; charset=utf-8', - ),$this->response->headers); - - + 'X-Sabre-Version' => [Version::VERSION], + 'Content-Type' => ['application/xml; charset=utf-8'], + ),$this->response->getHeaders()); } -- cgit v1.2.3