diff options
author | redmatrix <git@macgirvin.com> | 2016-05-10 17:26:44 -0700 |
---|---|---|
committer | redmatrix <git@macgirvin.com> | 2016-05-10 17:26:44 -0700 |
commit | 0b02a6d123b2014705998c94ddf3d460948d3eac (patch) | |
tree | 78ff2cab9944a4f5ab3f80ec93cbe1120de90bb2 /vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php | |
parent | 40b5b6e9d2da7ab65c8b4d38cdceac83a4d78deb (diff) | |
download | volse-hubzilla-0b02a6d123b2014705998c94ddf3d460948d3eac.tar.gz volse-hubzilla-0b02a6d123b2014705998c94ddf3d460948d3eac.tar.bz2 volse-hubzilla-0b02a6d123b2014705998c94ddf3d460948d3eac.zip |
initial sabre upgrade (needs lots of work - to wit: authentication, redo the browser interface, and rework event export/import)
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php')
-rw-r--r-- | vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php | 146 |
1 files changed, 67 insertions, 79 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php b/vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php index 45865b2a1..cd8bee968 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php @@ -4,105 +4,96 @@ namespace Sabre\DAV; use Sabre\HTTP; -class HTTPPReferParsingTest extends \Sabre\DAVServerTest { +class HTTPPreferParsingTest extends \Sabre\DAVServerTest { function testParseSimple() { - $httpRequest = new HTTP\Request(array( + $httpRequest = HTTP\Sapi::createFromServerArray([ 'HTTP_PREFER' => 'return-asynch', - )); + ]); $server = new Server(); $server->httpRequest = $httpRequest; - $this->assertEquals(array( - 'return-asynch' => true, - 'return-minimal' => false, - 'return-representation' => false, - 'strict' => false, - 'lenient' => false, - 'wait' => null, - ), $server->getHTTPPrefer()); + $this->assertEquals([ + 'respond-async' => true, + 'return' => null, + 'handling' => null, + 'wait' => null, + ], $server->getHTTPPrefer()); } function testParseValue() { - $httpRequest = new HTTP\Request(array( + $httpRequest = HTTP\Sapi::createFromServerArray([ 'HTTP_PREFER' => 'wait=10', - )); + ]); $server = new Server(); $server->httpRequest = $httpRequest; - $this->assertEquals(array( - 'return-asynch' => false, - 'return-minimal' => false, - 'return-representation' => false, - 'strict' => false, - 'lenient' => false, - 'wait' => 10, - ), $server->getHTTPPrefer()); + $this->assertEquals([ + 'respond-async' => false, + 'return' => null, + 'handling' => null, + 'wait' => '10', + ], $server->getHTTPPrefer()); } function testParseMultiple() { - $httpRequest = new HTTP\Request(array( + $httpRequest = HTTP\Sapi::createFromServerArray([ 'HTTP_PREFER' => 'return-minimal, strict,lenient', - )); + ]); $server = new Server(); $server->httpRequest = $httpRequest; - $this->assertEquals(array( - 'return-asynch' => false, - 'return-minimal' => true, - 'return-representation' => false, - 'strict' => true, - 'lenient' => true, - 'wait' => null, - ), $server->getHTTPPrefer()); + $this->assertEquals([ + 'respond-async' => false, + 'return' => 'minimal', + 'handling' => 'lenient', + 'wait' => null, + ], $server->getHTTPPrefer()); } function testParseWeirdValue() { - $httpRequest = new HTTP\Request(array( + $httpRequest = HTTP\Sapi::createFromServerArray([ 'HTTP_PREFER' => 'BOOOH', - )); + ]); $server = new Server(); $server->httpRequest = $httpRequest; - $this->assertEquals(array( - 'strict' => false, - 'lenient' => false, - 'wait' => null, - 'return-asynch' => false, - 'return-minimal' => false, - 'return-representation' => false, - ), $server->getHTTPPrefer()); + $this->assertEquals([ + 'respond-async' => false, + 'return' => null, + 'handling' => null, + 'wait' => null, + 'boooh' => true, + ], $server->getHTTPPrefer()); } function testBrief() { - $httpRequest = new HTTP\Request(array( + $httpRequest = HTTP\Sapi::createFromServerArray([ 'HTTP_BRIEF' => 't', - )); + ]); $server = new Server(); $server->httpRequest = $httpRequest; - $this->assertEquals(array( - 'strict' => false, - 'lenient' => false, - 'wait' => null, - 'return-asynch' => false, - 'return-minimal' => true, - 'return-representation' => false, - ), $server->getHTTPPrefer()); + $this->assertEquals([ + 'respond-async' => false, + 'return' => 'minimal', + 'handling' => null, + 'wait' => null, + ], $server->getHTTPPrefer()); } @@ -113,11 +104,11 @@ class HTTPPReferParsingTest extends \Sabre\DAVServerTest { */ function testpropfindMinimal() { - $request = new HTTP\Request(array( + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'PROPFIND', 'REQUEST_URI' => '/', - 'HTTP_PREFER' => 'return-minimal', - )); + 'HTTP_PREFER' => 'return-minimal', + ]); $request->setBody(<<<BLA <?xml version="1.0"?> <d:propfind xmlns:d="DAV:"> @@ -131,70 +122,67 @@ BLA $response = $this->request($request); - $this->assertTrue(strpos($response->body, 'resourcetype')!==false); - $this->assertTrue(strpos($response->body, 'something')===false); + $body = $response->getBodyAsString(); + + $this->assertEquals(207, $response->getStatus(), $body); + + $this->assertTrue(strpos($body, 'resourcetype') !== false, $body); + $this->assertTrue(strpos($body, 'something') === false, $body); } function testproppatchMinimal() { - $request = new HTTP\Request(array( - 'REQUEST_METHOD' => 'PROPPATCH', - 'REQUEST_URI' => '/', - 'HTTP_PREFER' => 'return-minimal', - )); + $request = new HTTP\Request('PROPPATCH', '/', ['Prefer' => 'return-minimal']); $request->setBody(<<<BLA <?xml version="1.0"?> -<d:proppatch xmlns:d="DAV:"> +<d:propertyupdate xmlns:d="DAV:"> <d:set> <d:prop> <d:something>nope!</d:something> </d:prop> </d:set> -</d:proppatch> +</d:propertyupdate> BLA ); - $this->server->subscribeEvent('updateProperties', function(&$props, &$result) { + $this->server->on('propPatch', function($path, PropPatch $propPatch) { - if (isset($props['{DAV:}something'])) { - unset($props['{DAV:}something']); - $result[200]['{DAV:}something'] = null; - } + $propPatch->handle('{DAV:}something', function($props) { + return true; + }); }); $response = $this->request($request); $this->assertEquals(0, strlen($response->body), 'Expected empty body: ' . $response->body); - $this->assertEquals('HTTP/1.1 204 No Content', $response->status); + $this->assertEquals(204, $response->status); } function testproppatchMinimalError() { - $request = new HTTP\Request(array( - 'REQUEST_METHOD' => 'PROPPATCH', - 'REQUEST_URI' => '/', - 'HTTP_PREFER' => 'return-minimal', - )); + $request = new HTTP\Request('PROPPATCH', '/', ['Prefer' => 'return-minimal']); $request->setBody(<<<BLA <?xml version="1.0"?> -<d:proppatch xmlns:d="DAV:"> +<d:propertyupdate xmlns:d="DAV:"> <d:set> <d:prop> <d:something>nope!</d:something> </d:prop> </d:set> -</d:proppatch> +</d:propertyupdate> BLA ); $response = $this->request($request); - $this->assertEquals('HTTP/1.1 207 Multi-Status', $response->status); - $this->assertTrue(strpos($response->body, 'something')!==false); - $this->assertTrue(strpos($response->body, 'HTTP/1.1 403 Forbidden')!==false); + $body = $response->getBodyAsString(); + + $this->assertEquals(207, $response->status); + $this->assertTrue(strpos($body, 'something') !== false); + $this->assertTrue(strpos($body, '403 Forbidden') !== false, $body); } } |