diff options
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/PluginTest.php')
-rw-r--r-- | vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/PluginTest.php | 119 |
1 files changed, 52 insertions, 67 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/PluginTest.php index 32f7e4e2c..5bd696416 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/PluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/PluginTest.php @@ -12,7 +12,7 @@ class PluginTest extends \Sabre\DAVServerTest { protected $node; protected $plugin; - public function setUp() { + function setUp() { $this->node = new FileMock(); $this->tree[] = $this->node; @@ -26,124 +26,109 @@ class PluginTest extends \Sabre\DAVServerTest { } - public function testInit() { + function testInit() { $this->assertEquals('partialupdate', $this->plugin->getPluginName()); - $this->assertEquals(array('sabredav-partialupdate'), $this->plugin->getFeatures()); - $this->assertEquals(array( + $this->assertEquals(['sabredav-partialupdate'], $this->plugin->getFeatures()); + $this->assertEquals([ 'PATCH' - ), $this->plugin->getHTTPMethods('partial')); - $this->assertEquals(array( - ), $this->plugin->getHTTPMethods('')); - - $this->assertNull($this->plugin->unknownMethod('FOO','partial')); + ], $this->plugin->getHTTPMethods('partial')); + $this->assertEquals([ + ], $this->plugin->getHTTPMethods('')); } - public function testPatchNoRange() { + function testPatchNoRange() { - $this->node->put('00000000'); - $request = new HTTP\Request(array( + $this->node->put('aaaaaaaa'); + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PATCH', 'REQUEST_URI' => '/partial', - )); + ]); $response = $this->request($request); - $this->assertEquals('HTTP/1.1 400 Bad request', $response->status, 'Full response body:' . $response->body); + $this->assertEquals(400, $response->status, 'Full response body:' . $response->body); } - public function testPatchNotSupported() { - - $this->node->put('00000000'); - $request = new HTTP\Request(array( - 'REQUEST_METHOD' => 'PATCH', - 'REQUEST_URI' => '/', - 'X_UPDATE_RANGE' => '3-4', + function testPatchNotSupported() { - )); + $this->node->put('aaaaaaaa'); + $request = new HTTP\Request('PATCH', '/', ['X-Update-Range' => '3-4']); $request->setBody( - '111' + 'bbb' ); $response = $this->request($request); - $this->assertEquals('HTTP/1.1 405 Method Not Allowed', $response->status, 'Full response body:' . $response->body); + $this->assertEquals(405, $response->status, 'Full response body:' . $response->body); } - public function testPatchNoContentType() { + function testPatchNoContentType() { - $this->node->put('00000000'); - $request = new HTTP\Request(array( - 'REQUEST_METHOD' => 'PATCH', - 'REQUEST_URI' => '/partial', - 'HTTP_X_UPDATE_RANGE' => 'bytes=3-4', + $this->node->put('aaaaaaaa'); + $request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-4']); + $request->setBody( + 'bbb' + ); + $response = $this->request($request); - )); + $this->assertEquals(415, $response->status, 'Full response body:' . $response->body); + + } + + function testPatchBadRange() { + + $this->node->put('aaaaaaaa'); + $request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-4', 'Content-Type' => 'application/x-sabredav-partialupdate', 'Content-Length' => '3']); $request->setBody( - '111' + 'bbb' ); $response = $this->request($request); - $this->assertEquals('HTTP/1.1 415 Unsupported Media Type', $response->status, 'Full response body:' . $response->body); + $this->assertEquals(416, $response->status, 'Full response body:' . $response->body); } - public function testPatchBadRange() { + function testPatchNoLength() { - $this->node->put('00000000'); - $request = new HTTP\Request(array( - 'REQUEST_METHOD' => 'PATCH', - 'REQUEST_URI' => '/partial', - 'HTTP_X_UPDATE_RANGE' => 'bytes=3-4', - 'HTTP_CONTENT_TYPE' => 'application/x-sabredav-partialupdate', - )); + $this->node->put('aaaaaaaa'); + $request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-5', 'Content-Type' => 'application/x-sabredav-partialupdate']); $request->setBody( - '111' + 'bbb' ); $response = $this->request($request); - $this->assertEquals('HTTP/1.1 411 Length Required', $response->status, 'Full response body:' . $response->body); + $this->assertEquals(411, $response->status, 'Full response body:' . $response->body); } - public function testPatchSuccess() { + function testPatchSuccess() { - $this->node->put('00000000'); - $request = new HTTP\Request(array( - 'REQUEST_METHOD' => 'PATCH', - 'REQUEST_URI' => '/partial', - 'HTTP_X_UPDATE_RANGE' => 'bytes=3-5', - 'HTTP_CONTENT_TYPE' => 'application/x-sabredav-partialupdate', - 'HTTP_CONTENT_LENGTH' => 3, - )); + $this->node->put('aaaaaaaa'); + $request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-5', 'Content-Type' => 'application/x-sabredav-partialupdate', 'Content-Length' => 3]); $request->setBody( - '111' + 'bbb' ); $response = $this->request($request); - $this->assertEquals('HTTP/1.1 204 No Content', $response->status, 'Full response body:' . $response->body); - $this->assertEquals('00011100', $this->node->get()); + $this->assertEquals(204, $response->status, 'Full response body:' . $response->body); + $this->assertEquals('aaabbbaa', $this->node->get()); } - public function testPatchNoEndRange() { + function testPatchNoEndRange() { - $this->node->put('00000'); - $request = new HTTP\Request(array( - 'REQUEST_METHOD' => 'PATCH', - 'REQUEST_URI' => '/partial', - 'HTTP_X_UPDATE_RANGE' => 'bytes=3-', - 'HTTP_CONTENT_TYPE' => 'application/x-sabredav-partialupdate', - 'HTTP_CONTENT_LENGTH' => 3, - )); + $this->node->put('aaaaa'); + $request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-', 'Content-Type' => 'application/x-sabredav-partialupdate', 'Content-Length' => '3']); $request->setBody( - '111' + 'bbb' ); + $response = $this->request($request); - $this->assertEquals('HTTP/1.1 204 No Content', $response->status, 'Full response body:' . $response->body); - $this->assertEquals('00111', $this->node->get()); + $this->assertEquals(204, $response->getStatus(), 'Full response body:' . $response->getBodyAsString()); + $this->assertEquals('aaabbb', $this->node->get()); } |