From 580c3f4ffe9608d2beb56d418c68b3b112420e76 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 10 Nov 2019 12:49:51 +0000 Subject: another bulk of composer updates (cherry picked from commit 6685381fd8db507493c3d7c1793f8c05c681bbce) --- .../dav/tests/Sabre/DAV/HTTPPreferParsingTest.php | 175 ++++++++++----------- 1 file changed, 81 insertions(+), 94 deletions(-) (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 index cd8bee968..d0ff77eb4 100644 --- a/vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php @@ -1,88 +1,85 @@ 'return-asynch', +class HTTPPreferParsingTest extends \Sabre\DAVServerTest +{ + public function assertParseResult($input, $expected) + { + $httpRequest = new HTTP\Request('GET', '/foo', [ + 'Prefer' => $input, ]); $server = new Server(); $server->httpRequest = $httpRequest; - $this->assertEquals([ - 'respond-async' => true, - 'return' => null, - 'handling' => null, - 'wait' => null, - ], $server->getHTTPPrefer()); - + $this->assertEquals( + $expected, + $server->getHTTPPrefer() + ); } - function testParseValue() { - - $httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_PREFER' => 'wait=10', - ]); - - $server = new Server(); - $server->httpRequest = $httpRequest; - - $this->assertEquals([ - 'respond-async' => false, - 'return' => null, - 'handling' => null, - 'wait' => '10', - ], $server->getHTTPPrefer()); - + public function testParseSimple() + { + $this->assertParseResult( + 'return-asynch', + [ + 'respond-async' => true, + 'return' => null, + 'handling' => null, + 'wait' => null, + ] + ); } - function testParseMultiple() { - - $httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_PREFER' => 'return-minimal, strict,lenient', - ]); - - $server = new Server(); - $server->httpRequest = $httpRequest; - - $this->assertEquals([ - 'respond-async' => false, - 'return' => 'minimal', - 'handling' => 'lenient', - 'wait' => null, - ], $server->getHTTPPrefer()); - + public function testParseValue() + { + $this->assertParseResult( + 'wait=10', + [ + 'respond-async' => false, + 'return' => null, + 'handling' => null, + 'wait' => '10', + ] + ); } - function testParseWeirdValue() { - - $httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_PREFER' => 'BOOOH', - ]); - - $server = new Server(); - $server->httpRequest = $httpRequest; - - $this->assertEquals([ - 'respond-async' => false, - 'return' => null, - 'handling' => null, - 'wait' => null, - 'boooh' => true, - ], $server->getHTTPPrefer()); - + public function testParseMultiple() + { + $this->assertParseResult( + 'return-minimal, strict,lenient', + [ + 'respond-async' => false, + 'return' => 'minimal', + 'handling' => 'lenient', + 'wait' => null, + ] + ); } - function testBrief() { + public function testParseWeirdValue() + { + $this->assertParseResult( + 'BOOOH', + [ + 'respond-async' => false, + 'return' => null, + 'handling' => null, + 'wait' => null, + 'boooh' => true, + ] + ); + } - $httpRequest = HTTP\Sapi::createFromServerArray([ - 'HTTP_BRIEF' => 't', + public function testBrief() + { + $httpRequest = new HTTP\Request('GET', '/foo', [ + 'Brief' => 't', ]); $server = new Server(); @@ -90,24 +87,19 @@ class HTTPPreferParsingTest extends \Sabre\DAVServerTest { $this->assertEquals([ 'respond-async' => false, - 'return' => 'minimal', - 'handling' => null, - 'wait' => null, + 'return' => 'minimal', + 'handling' => null, + 'wait' => null, ], $server->getHTTPPrefer()); - } /** - * propfindMinimal - * - * @return void + * propfindMinimal. */ - function testpropfindMinimal() { - - $request = HTTP\Sapi::createFromServerArray([ - 'REQUEST_METHOD' => 'PROPFIND', - 'REQUEST_URI' => '/', - 'HTTP_PREFER' => 'return-minimal', + public function testpropfindMinimal() + { + $request = new HTTP\Request('PROPFIND', '/', [ + 'Prefer' => 'return-minimal', ]); $request->setBody(<< @@ -126,13 +118,12 @@ BLA $this->assertEquals(207, $response->getStatus(), $body); - $this->assertTrue(strpos($body, 'resourcetype') !== false, $body); - $this->assertTrue(strpos($body, 'something') === false, $body); - + $this->assertTrue(false !== strpos($body, 'resourcetype'), $body); + $this->assertTrue(false === strpos($body, 'something'), $body); } - function testproppatchMinimal() { - + public function testproppatchMinimal() + { $request = new HTTP\Request('PROPPATCH', '/', ['Prefer' => 'return-minimal']); $request->setBody(<< @@ -146,23 +137,20 @@ BLA BLA ); - $this->server->on('propPatch', function($path, PropPatch $propPatch) { - - $propPatch->handle('{DAV:}something', function($props) { + $this->server->on('propPatch', function ($path, PropPatch $propPatch) { + $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('', $response->getBodyAsString(), 'Expected empty body: '.$response->body); $this->assertEquals(204, $response->status); - } - function testproppatchMinimalError() { - + public function testproppatchMinimalError() + { $request = new HTTP\Request('PROPPATCH', '/', ['Prefer' => 'return-minimal']); $request->setBody(<< @@ -181,8 +169,7 @@ BLA $body = $response->getBodyAsString(); $this->assertEquals(207, $response->status); - $this->assertTrue(strpos($body, 'something') !== false); - $this->assertTrue(strpos($body, '403 Forbidden') !== false, $body); - + $this->assertTrue(false !== strpos($body, 'something')); + $this->assertTrue(false !== strpos($body, '403 Forbidden'), $body); } } -- cgit v1.2.3