aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2019-12-04 10:25:11 +0000
committerMario <mario@mariovavti.com>2019-12-04 10:25:11 +0000
commitbde429cff649237984903a252ba1a718e6d74f53 (patch)
treeb2b2570159cfb37689e6ce3b96c3b1b988d676cc /vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php
parentcc9f41df5f83bcab435d6fb941b5a8f5b1457037 (diff)
parent4c8d33d1eb2a804aa70a7bc677d6c73d0d94816b (diff)
downloadvolse-hubzilla-bde429cff649237984903a252ba1a718e6d74f53.tar.gz
volse-hubzilla-bde429cff649237984903a252ba1a718e6d74f53.tar.bz2
volse-hubzilla-bde429cff649237984903a252ba1a718e6d74f53.zip
Merge branch '4.6RC'4.6
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php')
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/HTTPPreferParsingTest.php175
1 files changed, 81 insertions, 94 deletions
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 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\DAV;
use Sabre\HTTP;
-class HTTPPreferParsingTest extends \Sabre\DAVServerTest {
-
- function testParseSimple() {
-
- $httpRequest = HTTP\Sapi::createFromServerArray([
- 'HTTP_PREFER' => '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(<<<BLA
<?xml version="1.0"?>
@@ -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(<<<BLA
<?xml version="1.0"?>
@@ -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(<<<BLA
<?xml version="1.0"?>
@@ -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);
}
}