16 $this->assertEquals(
$nodes[0],
$server->tree->getNodeForPath(
'hello'));
45 $request =
new HTTP\Request(
'OPTIONS',
'/');
46 $this->server->httpRequest =
$request;
47 $this->server->exec();
50 'DAV' => [
'1, 3, extended-mkcol'],
51 'MS-Author-Via' => [
'DAV'],
52 'Allow' => [
'OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT'],
53 'Accept-Ranges' => [
'bytes'],
54 'Content-Length' => [
'0'],
56 ], $this->response->getHeaders());
58 $this->assertEquals(200, $this->response->status);
59 $this->assertEquals(
'', $this->response->body);
65 $request =
new HTTP\Request(
'OPTIONS',
'/unmapped');
66 $this->server->httpRequest =
$request;
68 $this->server->exec();
71 'DAV' => [
'1, 3, extended-mkcol'],
72 'MS-Author-Via' => [
'DAV'],
73 'Allow' => [
'OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT, MKCOL'],
74 'Accept-Ranges' => [
'bytes'],
75 'Content-Length' => [
'0'],
77 ], $this->response->getHeaders());
79 $this->assertEquals(200, $this->response->status);
80 $this->assertEquals(
'', $this->response->body);
88 'REQUEST_METHOD' =>
'BLABLA',
92 $this->server->httpRequest = (
$request);
93 $this->server->exec();
97 'Content-Type' => [
'application/xml; charset=utf-8'],
98 ], $this->response->getHeaders());
100 $this->assertEquals(501, $this->response->status);
108 'REQUEST_URI' =>
'/blabla/test.txt',
109 'REQUEST_METHOD' =>
'GET',
111 $filename = $this->tempDir .
'/test.txt';
114 $this->server->setBaseUri(
'/blabla/');
115 $this->assertEquals(
'/blabla/', $this->server->getBaseUri());
116 $this->server->httpRequest = (
$request);
117 $this->server->exec();
119 $this->assertEquals([
121 'Content-Type' => [
'application/octet-stream'],
122 'Content-Length' => [13],
126 $this->response->getHeaders()
129 $this->assertEquals(200, $this->response->status);
130 $this->assertEquals(
'Test contents', stream_get_contents($this->response->body));
140 '/foo/bar' =>
'/foo/bar/',
141 '/foo/bar/' =>
'/foo/bar/',
145 $this->server->setBaseUri(
$test);
147 $this->assertEquals(
$result, $this->server->getBaseUri());
156 'http://www.example.org/root/somepath',
161 $this->server->setBaseUri(
'/root/');
163 foreach ($uris as $uri) {
165 $this->assertEquals(
'somepath', $this->server->calculateUri($uri));
169 $this->server->setBaseUri(
'/root');
171 foreach ($uris as $uri) {
173 $this->assertEquals(
'somepath', $this->server->calculateUri($uri));
177 $this->assertEquals(
'', $this->server->calculateUri(
'/root'));
184 'http://www.example.org/root/%C3%A0fo%C3%B3',
185 '/root/%C3%A0fo%C3%B3',
186 '/root/%C3%A0fo%C3%B3/' 189 $this->server->setBaseUri(
'/root/');
191 foreach ($uris as $uri) {
193 $this->assertEquals(
"\xc3\xa0fo\xc3\xb3", $this->server->calculateUri($uri));
197 $this->server->setBaseUri(
'/root');
199 foreach ($uris as $uri) {
201 $this->assertEquals(
"\xc3\xa0fo\xc3\xb3", $this->server->calculateUri($uri));
205 $this->server->setBaseUri(
'/');
207 foreach ($uris as $uri) {
209 $this->assertEquals(
"root/\xc3\xa0fo\xc3\xb3", $this->server->calculateUri($uri));
222 $this->server->setBaseUri(
'/path2/');
223 $this->server->calculateUri($uri);
232 'REQUEST_URI' =>
'/index.php/root',
233 'PATH_INFO' =>
'/root',
238 $server->httpRequest = $httpRequest;
240 $this->assertEquals(
'/index.php/',
$server->guessBaseUri());
250 'REQUEST_URI' =>
'/index.php/dir/path2/path%20with%20spaces',
251 'PATH_INFO' =>
'/dir/path2/path with spaces',
256 $server->httpRequest = $httpRequest;
258 $this->assertEquals(
'/index.php/',
$server->guessBaseUri());
285 'REQUEST_URI' =>
'/index.php/root/',
286 'PATH_INFO' =>
'/root/',
291 $server->httpRequest = $httpRequest;
293 $this->assertEquals(
'/index.php/',
$server->guessBaseUri());
300 'REQUEST_URI' =>
'/index.php/root',
305 $server->httpRequest = $httpRequest;
307 $this->assertEquals(
'/',
$server->guessBaseUri());
314 'REQUEST_URI' =>
'/a/b/c/test.php',
319 $server->httpRequest = $httpRequest;
321 $this->assertEquals(
'/',
$server->guessBaseUri());
332 'REQUEST_URI' =>
'/index.php/root?query_string=blabla',
333 'PATH_INFO' =>
'/root',
338 $server->httpRequest = $httpRequest;
340 $this->assertEquals(
'/index.php/',
$server->guessBaseUri());
351 'REQUEST_URI' =>
'/index.php/root/heyyy',
352 'PATH_INFO' =>
'/root',
357 $server->httpRequest = $httpRequest;
366 'REQUEST_URI' =>
'/',
367 'REQUEST_METHOD' =>
'FOO',
371 $this->server->httpRequest = $httpRequest;
372 $this->server->on(
'beforeMethod', [$this,
'exceptionTrigger']);
373 $this->server->exec();
375 $this->assertEquals([
376 'Content-Type' => [
'application/xml; charset=utf-8'],
377 ], $this->response->getHeaders());
379 $this->assertEquals(500, $this->response->status);
392 'REQUEST_URI' =>
'/',
393 'REQUEST_METHOD' =>
'REPORT',
397 $this->server->httpRequest = (
$request);
398 $this->server->httpRequest->setBody(
'<?xml version="1.0"?><bla:myreport xmlns:bla="http://www.rooftopsolutions.nl/NS"></bla:myreport>');
399 $this->server->exec();
401 $this->assertEquals([
403 'Content-Type' => [
'application/xml; charset=utf-8'],
405 $this->response->getHeaders()
408 $this->assertEquals(415, $this->response->status,
'We got an incorrect status back. Full response body follows: ' . $this->response->body);
415 'REQUEST_URI' =>
'/',
416 'REQUEST_METHOD' =>
'REPORT',
420 $this->server->httpRequest = (
$request);
421 $this->server->httpRequest->setBody(
'<?xml version="1.0"?><bla:myreport xmlns:bla="http://www.rooftopsolutions.nl/NS"></bla:myreport>');
422 $this->server->on(
'report', [$this,
'reportHandler']);
423 $this->server->exec();
425 $this->assertEquals([
427 'testheader' => [
'testvalue'],
429 $this->response->getHeaders()
432 $this->assertEquals(418, $this->response->status,
'We got an incorrect status back. Full response body follows: ' . $this->response->body);
438 if ($reportName ==
'{http://www.rooftopsolutions.nl/NS}myreport') {
439 $this->server->httpResponse->setStatus(418);
440 $this->server->httpResponse->setHeader(
'testheader',
'testvalue');
449 $result = $this->server->getPropertiesForChildren(
'', [
450 '{DAV:}getcontentlength',
454 'test.txt' => [
'{DAV:}getcontentlength' => 13],
458 $this->assertEquals($expected,
$result);
468 $this->server->on(
'method:GET',
function() {
return false; }, 1);
469 $this->server->httpRequest =
new HTTP\Request(
'GET',
'/');
470 $this->server->exec();
471 $this->assertEquals(500, $this->response->getStatus());
testGuessBaseUriNoPathInfo2()
testGuessBaseUriNoPathInfo()
testGuessBaseUriQueryString()
testGuessBaseUri
testConstructInvalidArg()
Sabre
static toHTTPDate(\DateTime $dateTime)
Transforms a DateTime object to HTTP's most common date format.
reportHandler($reportName, $result, $path)
const VERSION
Full version number.
testGuessBaseUriBadConfig()
testGuessBaseUri
testNoHTTPStatusSet()
There are certain cases where no HTTP status may be set.
testCalculateUriBreakout()
exceptionTrigger($request, $response)
testGetPropertiesForChildren()
testGuessBaseUri2()
testGuessBaseUri
testCalculateUriSpecialChars()
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
testConstructIncorrectObj()
Sabre
testGuessBaseUriPercentEncoding()
testGuessBaseUri