diff options
author | Klaus Weidenbach <Klaus.Weidenbach@gmx.net> | 2014-06-28 22:28:08 +0200 |
---|---|---|
committer | Klaus Weidenbach <Klaus.Weidenbach@gmx.net> | 2014-06-29 01:17:07 +0200 |
commit | 03b31d113ea316c8384a4cbf3d27ca22bb528eac (patch) | |
tree | 92ed87436b09ab806f9effff08145408044d77f4 /vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate | |
parent | f49b74c5f6ebe57937fb6dfea7d2e917f4680ce9 (diff) | |
download | volse-hubzilla-03b31d113ea316c8384a4cbf3d27ca22bb528eac.tar.gz volse-hubzilla-03b31d113ea316c8384a4cbf3d27ca22bb528eac.tar.bz2 volse-hubzilla-03b31d113ea316c8384a4cbf3d27ca22bb528eac.zip |
Update SabreDAV from 1.8.9 to 1.8.10.
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate')
-rw-r--r-- | vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/PluginTest.php | 24 | ||||
-rw-r--r-- | vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/SpecificationTest.php | 89 |
2 files changed, 111 insertions, 2 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/PluginTest.php b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/PluginTest.php index 7b90429d4..32f7e4e2c 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/PluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/PluginTest.php @@ -103,7 +103,7 @@ class PluginTest extends \Sabre\DAVServerTest { ); $response = $this->request($request); - $this->assertEquals('HTTP/1.1 416 Requested Range Not Satisfiable', $response->status, 'Full response body:' . $response->body); + $this->assertEquals('HTTP/1.1 411 Length Required', $response->status, 'Full response body:' . $response->body); } @@ -123,7 +123,27 @@ class PluginTest extends \Sabre\DAVServerTest { $response = $this->request($request); $this->assertEquals('HTTP/1.1 204 No Content', $response->status, 'Full response body:' . $response->body); - $this->assertEquals('00111000', $this->node->get()); + $this->assertEquals('00011100', $this->node->get()); + + } + + public 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, + )); + $request->setBody( + '111' + ); + $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()); } diff --git a/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/SpecificationTest.php b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/SpecificationTest.php new file mode 100644 index 000000000..7abe69c55 --- /dev/null +++ b/vendor/sabre/dav/tests/Sabre/DAV/PartialUpdate/SpecificationTest.php @@ -0,0 +1,89 @@ +<?php + +namespace Sabre\DAV\PartialUpdate; + +use Sabre\DAV\FSExt\File; +use Sabre\DAV\Server; +use Sabre\HTTP; + +/** + * This test is an end-to-end sabredav test that goes through all + * the cases in the specification. + * + * See: http://sabre.io/dav/http-patch/ + */ +class SpecificationTest extends \PHPUnit_Framework_TestCase { + + protected $server; + + public function setUp() { + + $tree = array( + new File(SABRE_TEMPDIR . '/foobar.txt') + ); + $server = new Server($tree); + $server->debugExceptions = true; + $server->addPlugin(new Plugin()); + + $tree[0]->put('1234567890'); + + $this->server = $server; + + } + + public function tearDown() { + + \Sabre\TestUtil::clearTempDir(); + + } + + /** + * @dataProvider data + */ + public function testUpdateRange($headerValue, $httpStatus, $endResult, $contentLength = 4) { + + $vars = array( + 'REQUEST_METHOD' => 'PATCH', + 'HTTP_CONTENT_TYPE' => 'application/x-sabredav-partialupdate', + 'HTTP_X_UPDATE_RANGE' => $headerValue, + 'REQUEST_URI' => '/foobar.txt', + ); + if ($contentLength) { + $vars['HTTP_CONTENT_LENGTH'] = (string)$contentLength; + } + + $request = new HTTP\Request($vars); + + $request->setBody('----'); + $this->server->httpRequest = $request; + $this->server->httpResponse = new HTTP\ResponseMock(); + $this->server->exec(); + + $this->assertEquals($httpStatus, $this->server->httpResponse->status, 'Incorrect http status received: ' . $this->server->httpResponse->body); + if (!is_null($endResult)) { + $this->assertEquals($endResult, file_get_contents(SABRE_TEMPDIR . '/foobar.txt')); + } + + } + + public function data() { + + return array( + // Problems + array('foo', 'HTTP/1.1 400 Bad request', null), + array('bytes=0-3', 'HTTP/1.1 411 Length Required', null, 0), + array('bytes=4-1', 'HTTP/1.1 416 Requested Range Not Satisfiable', null), + + array('bytes=0-3', 'HTTP/1.1 204 No Content', '----567890'), + array('bytes=1-4', 'HTTP/1.1 204 No Content', '1----67890'), + array('bytes=0-', 'HTTP/1.1 204 No Content', '----567890'), + array('bytes=-4', 'HTTP/1.1 204 No Content', '123456----'), + array('bytes=-2', 'HTTP/1.1 204 No Content', '12345678----'), + array('bytes=2-', 'HTTP/1.1 204 No Content', '12----7890'), + array('append', 'HTTP/1.1 204 No Content', '1234567890----'), + + ); + + } + +} |