From b35122f7a6ad42756c35bb60ba1f06c3dcd45c77 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 21 Oct 2013 15:46:31 -0700 Subject: add sabre (1.8.x) via composer in the !@#$ place it wants to be --- .../dav/tests/Sabre/DAV/HTTPPreferParsingTest.php | 200 +++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php (limited to 'vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php') diff --git a/vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php b/vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php new file mode 100644 index 000000000..45865b2a1 --- /dev/null +++ b/vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php @@ -0,0 +1,200 @@ + '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()); + + } + + function testParseValue() { + + $httpRequest = new HTTP\Request(array( + '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()); + + } + + function testParseMultiple() { + + $httpRequest = new HTTP\Request(array( + '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()); + + } + + function testParseWeirdValue() { + + $httpRequest = new HTTP\Request(array( + '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()); + + } + + function testBrief() { + + $httpRequest = new HTTP\Request(array( + '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()); + + } + + /** + * propfindMinimal + * + * @return void + */ + function testpropfindMinimal() { + + $request = new HTTP\Request(array( + 'REQUEST_METHOD' => 'PROPFIND', + 'REQUEST_URI' => '/', + 'HTTP_PREFER' => 'return-minimal', + )); + $request->setBody(<< + + + + + + +BLA + ); + + $response = $this->request($request); + + $this->assertTrue(strpos($response->body, 'resourcetype')!==false); + $this->assertTrue(strpos($response->body, 'something')===false); + + } + + function testproppatchMinimal() { + + $request = new HTTP\Request(array( + 'REQUEST_METHOD' => 'PROPPATCH', + 'REQUEST_URI' => '/', + 'HTTP_PREFER' => 'return-minimal', + )); + $request->setBody(<< + + + + nope! + + + +BLA + ); + + $this->server->subscribeEvent('updateProperties', function(&$props, &$result) { + + if (isset($props['{DAV:}something'])) { + unset($props['{DAV:}something']); + $result[200]['{DAV:}something'] = null; + } + + }); + + $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); + + } + + function testproppatchMinimalError() { + + $request = new HTTP\Request(array( + 'REQUEST_METHOD' => 'PROPPATCH', + 'REQUEST_URI' => '/', + 'HTTP_PREFER' => 'return-minimal', + )); + $request->setBody(<< + + + + nope! + + + +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); + + } +} -- cgit v1.2.3