ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\DAV\ServerSimpleTest Class Reference
+ Inheritance diagram for Sabre\DAV\ServerSimpleTest:
+ Collaboration diagram for Sabre\DAV\ServerSimpleTest:

Public Member Functions

 testConstructArray ()
 
 testConstructIncorrectObj ()
 Sabre More...
 
 testConstructInvalidArg ()
 Sabre More...
 
 testOptions ()
 
 testOptionsUnmapped ()
 
 testNonExistantMethod ()
 
 testBaseUri ()
 
 testBaseUriAddSlash ()
 
 testCalculateUri ()
 
 testCalculateUriSpecialChars ()
 
 testCalculateUriBreakout ()
 
 testGuessBaseUri ()
 
 testGuessBaseUriPercentEncoding ()
 testGuessBaseUri More...
 
 testGuessBaseUri2 ()
 testGuessBaseUri More...
 
 testGuessBaseUriNoPathInfo ()
 
 testGuessBaseUriNoPathInfo2 ()
 
 testGuessBaseUriQueryString ()
 testGuessBaseUri More...
 
 testGuessBaseUriBadConfig ()
 testGuessBaseUri More...
 
 testTriggerException ()
 
 exceptionTrigger ($request, $response)
 
 testReportNotFound ()
 
 testReportIntercepted ()
 
 reportHandler ($reportName, $result, $path)
 
 testGetPropertiesForChildren ()
 
 testNoHTTPStatusSet ()
 There are certain cases where no HTTP status may be set. More...
 
- Public Member Functions inherited from Sabre\DAV\AbstractServer
 setUp ()
 
 tearDown ()
 

Additional Inherited Members

- Protected Member Functions inherited from Sabre\DAV\AbstractServer
 getRootNode ()
 
- Protected Attributes inherited from Sabre\DAV\AbstractServer
 $response
 
 $request
 
 $server
 
 $tempDir = SABRE_TEMPDIR
 

Detailed Description

Definition at line 7 of file ServerSimpleTest.php.

Member Function Documentation

◆ exceptionTrigger()

Sabre\DAV\ServerSimpleTest::exceptionTrigger (   $request,
  $response 
)

Definition at line 383 of file ServerSimpleTest.php.

383  {
384 
385  throw new Exception('Hola');
386 
387  }

◆ reportHandler()

Sabre\DAV\ServerSimpleTest::reportHandler (   $reportName,
  $result,
  $path 
)

Definition at line 436 of file ServerSimpleTest.php.

436  {
437 
438  if ($reportName == '{http://www.rooftopsolutions.nl/NS}myreport') {
439  $this->server->httpResponse->setStatus(418);
440  $this->server->httpResponse->setHeader('testheader', 'testvalue');
441  return false;
442  }
443  else return;
444 
445  }

◆ testBaseUri()

Sabre\DAV\ServerSimpleTest::testBaseUri ( )

Definition at line 105 of file ServerSimpleTest.php.

References $filename, Sabre\DAV\AbstractServer\$request, Sabre\HTTP\Sapi\createFromServerArray(), Sabre\HTTP\Util\toHTTPDate(), and Sabre\DAV\Version\VERSION.

105  {
106 
107  $serverVars = [
108  'REQUEST_URI' => '/blabla/test.txt',
109  'REQUEST_METHOD' => 'GET',
110  ];
111  $filename = $this->tempDir . '/test.txt';
112 
114  $this->server->setBaseUri('/blabla/');
115  $this->assertEquals('/blabla/', $this->server->getBaseUri());
116  $this->server->httpRequest = ($request);
117  $this->server->exec();
118 
119  $this->assertEquals([
120  'X-Sabre-Version' => [Version::VERSION],
121  'Content-Type' => ['application/octet-stream'],
122  'Content-Length' => [13],
123  'Last-Modified' => [HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($filename)))],
124  'ETag' => ['"' . sha1(fileinode($filename) . filesize($filename) . filemtime($filename)) . '"'],
125  ],
126  $this->response->getHeaders()
127  );
128 
129  $this->assertEquals(200, $this->response->status);
130  $this->assertEquals('Test contents', stream_get_contents($this->response->body));
131 
132  }
static toHTTPDate(\DateTime $dateTime)
Transforms a DateTime object to HTTP's most common date format.
Definition: Util.php:69
const VERSION
Full version number.
Definition: Version.php:17
$filename
Definition: buildRTE.php:89
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
+ Here is the call graph for this function:

◆ testBaseUriAddSlash()

Sabre\DAV\ServerSimpleTest::testBaseUriAddSlash ( )

Definition at line 134 of file ServerSimpleTest.php.

References $result, $test, and $tests.

134  {
135 
136  $tests = [
137  '/' => '/',
138  '/foo' => '/foo/',
139  '/foo/' => '/foo/',
140  '/foo/bar' => '/foo/bar/',
141  '/foo/bar/' => '/foo/bar/',
142  ];
143 
144  foreach ($tests as $test => $result) {
145  $this->server->setBaseUri($test);
146 
147  $this->assertEquals($result, $this->server->getBaseUri());
148 
149  }
150 
151  }
$result
$tests
Definition: bench.php:104
$test
Definition: Utf8Test.php:84

◆ testCalculateUri()

Sabre\DAV\ServerSimpleTest::testCalculateUri ( )

Definition at line 153 of file ServerSimpleTest.php.

153  {
154 
155  $uris = [
156  'http://www.example.org/root/somepath',
157  '/root/somepath',
158  '/root/somepath/',
159  ];
160 
161  $this->server->setBaseUri('/root/');
162 
163  foreach ($uris as $uri) {
164 
165  $this->assertEquals('somepath', $this->server->calculateUri($uri));
166 
167  }
168 
169  $this->server->setBaseUri('/root');
170 
171  foreach ($uris as $uri) {
172 
173  $this->assertEquals('somepath', $this->server->calculateUri($uri));
174 
175  }
176 
177  $this->assertEquals('', $this->server->calculateUri('/root'));
178 
179  }

◆ testCalculateUriBreakout()

Sabre\DAV\ServerSimpleTest::testCalculateUriBreakout ( )

Definition at line 218 of file ServerSimpleTest.php.

218  {
219 
220  $uri = '/path1/';
221 
222  $this->server->setBaseUri('/path2/');
223  $this->server->calculateUri($uri);
224 
225  }

◆ testCalculateUriSpecialChars()

Sabre\DAV\ServerSimpleTest::testCalculateUriSpecialChars ( )

Definition at line 181 of file ServerSimpleTest.php.

181  {
182 
183  $uris = [
184  'http://www.example.org/root/%C3%A0fo%C3%B3',
185  '/root/%C3%A0fo%C3%B3',
186  '/root/%C3%A0fo%C3%B3/'
187  ];
188 
189  $this->server->setBaseUri('/root/');
190 
191  foreach ($uris as $uri) {
192 
193  $this->assertEquals("\xc3\xa0fo\xc3\xb3", $this->server->calculateUri($uri));
194 
195  }
196 
197  $this->server->setBaseUri('/root');
198 
199  foreach ($uris as $uri) {
200 
201  $this->assertEquals("\xc3\xa0fo\xc3\xb3", $this->server->calculateUri($uri));
202 
203  }
204 
205  $this->server->setBaseUri('/');
206 
207  foreach ($uris as $uri) {
208 
209  $this->assertEquals("root/\xc3\xa0fo\xc3\xb3", $this->server->calculateUri($uri));
210 
211  }
212 
213  }

◆ testConstructArray()

Sabre\DAV\ServerSimpleTest::testConstructArray ( )

Definition at line 9 of file ServerSimpleTest.php.

References $nodes, and Sabre\DAV\AbstractServer\$server.

9  {
10 
11  $nodes = [
12  new SimpleCollection('hello')
13  ];
14 
15  $server = new Server($nodes);
16  $this->assertEquals($nodes[0], $server->tree->getNodeForPath('hello'));
17 
18  }

◆ testConstructIncorrectObj()

Sabre\DAV\ServerSimpleTest::testConstructIncorrectObj ( )

Sabre

Definition at line 23 of file ServerSimpleTest.php.

References $nodes, and Sabre\DAV\AbstractServer\$server.

23  {
24 
25  $nodes = [
26  new SimpleCollection('hello'),
27  new \STDClass(),
28  ];
29 
30  $server = new Server($nodes);
31 
32  }

◆ testConstructInvalidArg()

Sabre\DAV\ServerSimpleTest::testConstructInvalidArg ( )

Sabre

Definition at line 37 of file ServerSimpleTest.php.

References Sabre\DAV\AbstractServer\$server.

37  {
38 
39  $server = new Server(1);
40 
41  }

◆ testGetPropertiesForChildren()

Sabre\DAV\ServerSimpleTest::testGetPropertiesForChildren ( )

Definition at line 447 of file ServerSimpleTest.php.

References $result.

447  {
448 
449  $result = $this->server->getPropertiesForChildren('', [
450  '{DAV:}getcontentlength',
451  ]);
452 
453  $expected = [
454  'test.txt' => ['{DAV:}getcontentlength' => 13],
455  'dir/' => [],
456  ];
457 
458  $this->assertEquals($expected, $result);
459 
460  }
$result

◆ testGuessBaseUri()

Sabre\DAV\ServerSimpleTest::testGuessBaseUri ( )

Definition at line 229 of file ServerSimpleTest.php.

References Sabre\DAV\AbstractServer\$server, and Sabre\HTTP\Sapi\createFromServerArray().

229  {
230 
231  $serverVars = [
232  'REQUEST_URI' => '/index.php/root',
233  'PATH_INFO' => '/root',
234  ];
235 
236  $httpRequest = HTTP\Sapi::createFromServerArray($serverVars);
237  $server = new Server();
238  $server->httpRequest = $httpRequest;
239 
240  $this->assertEquals('/index.php/', $server->guessBaseUri());
241 
242  }
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
+ Here is the call graph for this function:

◆ testGuessBaseUri2()

Sabre\DAV\ServerSimpleTest::testGuessBaseUri2 ( )

testGuessBaseUri

Definition at line 282 of file ServerSimpleTest.php.

References Sabre\DAV\AbstractServer\$server, and Sabre\HTTP\Sapi\createFromServerArray().

282  {
283 
284  $serverVars = [
285  'REQUEST_URI' => '/index.php/root/',
286  'PATH_INFO' => '/root/',
287  ];
288 
289  $httpRequest = HTTP\Sapi::createFromServerArray($serverVars);
290  $server = new Server();
291  $server->httpRequest = $httpRequest;
292 
293  $this->assertEquals('/index.php/', $server->guessBaseUri());
294 
295  }
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
+ Here is the call graph for this function:

◆ testGuessBaseUriBadConfig()

Sabre\DAV\ServerSimpleTest::testGuessBaseUriBadConfig ( )

testGuessBaseUri

Definition at line 348 of file ServerSimpleTest.php.

References Sabre\DAV\AbstractServer\$server, and Sabre\HTTP\Sapi\createFromServerArray().

348  {
349 
350  $serverVars = [
351  'REQUEST_URI' => '/index.php/root/heyyy',
352  'PATH_INFO' => '/root',
353  ];
354 
355  $httpRequest = HTTP\Sapi::createFromServerArray($serverVars);
356  $server = new Server();
357  $server->httpRequest = $httpRequest;
358 
359  $server->guessBaseUri();
360 
361  }
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
+ Here is the call graph for this function:

◆ testGuessBaseUriNoPathInfo()

Sabre\DAV\ServerSimpleTest::testGuessBaseUriNoPathInfo ( )

Definition at line 297 of file ServerSimpleTest.php.

References Sabre\DAV\AbstractServer\$server, and Sabre\HTTP\Sapi\createFromServerArray().

297  {
298 
299  $serverVars = [
300  'REQUEST_URI' => '/index.php/root',
301  ];
302 
303  $httpRequest = HTTP\Sapi::createFromServerArray($serverVars);
304  $server = new Server();
305  $server->httpRequest = $httpRequest;
306 
307  $this->assertEquals('/', $server->guessBaseUri());
308 
309  }
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
+ Here is the call graph for this function:

◆ testGuessBaseUriNoPathInfo2()

Sabre\DAV\ServerSimpleTest::testGuessBaseUriNoPathInfo2 ( )

Definition at line 311 of file ServerSimpleTest.php.

References Sabre\DAV\AbstractServer\$server, and Sabre\HTTP\Sapi\createFromServerArray().

311  {
312 
313  $serverVars = [
314  'REQUEST_URI' => '/a/b/c/test.php',
315  ];
316 
317  $httpRequest = HTTP\Sapi::createFromServerArray($serverVars);
318  $server = new Server();
319  $server->httpRequest = $httpRequest;
320 
321  $this->assertEquals('/', $server->guessBaseUri());
322 
323  }
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
+ Here is the call graph for this function:

◆ testGuessBaseUriPercentEncoding()

Sabre\DAV\ServerSimpleTest::testGuessBaseUriPercentEncoding ( )

testGuessBaseUri

Definition at line 247 of file ServerSimpleTest.php.

References Sabre\DAV\AbstractServer\$server, and Sabre\HTTP\Sapi\createFromServerArray().

247  {
248 
249  $serverVars = [
250  'REQUEST_URI' => '/index.php/dir/path2/path%20with%20spaces',
251  'PATH_INFO' => '/dir/path2/path with spaces',
252  ];
253 
254  $httpRequest = HTTP\Sapi::createFromServerArray($serverVars);
255  $server = new Server();
256  $server->httpRequest = $httpRequest;
257 
258  $this->assertEquals('/index.php/', $server->guessBaseUri());
259 
260  }
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
+ Here is the call graph for this function:

◆ testGuessBaseUriQueryString()

Sabre\DAV\ServerSimpleTest::testGuessBaseUriQueryString ( )

testGuessBaseUri

Definition at line 329 of file ServerSimpleTest.php.

References Sabre\DAV\AbstractServer\$server, and Sabre\HTTP\Sapi\createFromServerArray().

329  {
330 
331  $serverVars = [
332  'REQUEST_URI' => '/index.php/root?query_string=blabla',
333  'PATH_INFO' => '/root',
334  ];
335 
336  $httpRequest = HTTP\Sapi::createFromServerArray($serverVars);
337  $server = new Server();
338  $server->httpRequest = $httpRequest;
339 
340  $this->assertEquals('/index.php/', $server->guessBaseUri());
341 
342  }
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
+ Here is the call graph for this function:

◆ testNoHTTPStatusSet()

Sabre\DAV\ServerSimpleTest::testNoHTTPStatusSet ( )

There are certain cases where no HTTP status may be set.

We need to intercept these and set it to a default error message.

Definition at line 466 of file ServerSimpleTest.php.

466  {
467 
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());
472 
473  }

◆ testNonExistantMethod()

Sabre\DAV\ServerSimpleTest::testNonExistantMethod ( )

Definition at line 84 of file ServerSimpleTest.php.

References Sabre\DAV\AbstractServer\$request, Sabre\HTTP\Sapi\createFromServerArray(), and Sabre\DAV\Version\VERSION.

84  {
85 
86  $serverVars = [
87  'REQUEST_URI' => '/',
88  'REQUEST_METHOD' => 'BLABLA',
89  ];
90 
92  $this->server->httpRequest = ($request);
93  $this->server->exec();
94 
95  $this->assertEquals([
96  'X-Sabre-Version' => [Version::VERSION],
97  'Content-Type' => ['application/xml; charset=utf-8'],
98  ], $this->response->getHeaders());
99 
100  $this->assertEquals(501, $this->response->status);
101 
102 
103  }
const VERSION
Full version number.
Definition: Version.php:17
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
+ Here is the call graph for this function:

◆ testOptions()

Sabre\DAV\ServerSimpleTest::testOptions ( )

Definition at line 43 of file ServerSimpleTest.php.

References Sabre\DAV\AbstractServer\$request, and Sabre\DAV\Version\VERSION.

43  {
44 
45  $request = new HTTP\Request('OPTIONS', '/');
46  $this->server->httpRequest = $request;
47  $this->server->exec();
48 
49  $this->assertEquals([
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'],
55  'X-Sabre-Version' => [Version::VERSION],
56  ], $this->response->getHeaders());
57 
58  $this->assertEquals(200, $this->response->status);
59  $this->assertEquals('', $this->response->body);
60 
61  }
const VERSION
Full version number.
Definition: Version.php:17

◆ testOptionsUnmapped()

Sabre\DAV\ServerSimpleTest::testOptionsUnmapped ( )

Definition at line 63 of file ServerSimpleTest.php.

References Sabre\DAV\AbstractServer\$request, and Sabre\DAV\Version\VERSION.

63  {
64 
65  $request = new HTTP\Request('OPTIONS', '/unmapped');
66  $this->server->httpRequest = $request;
67 
68  $this->server->exec();
69 
70  $this->assertEquals([
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'],
76  'X-Sabre-Version' => [Version::VERSION],
77  ], $this->response->getHeaders());
78 
79  $this->assertEquals(200, $this->response->status);
80  $this->assertEquals('', $this->response->body);
81 
82  }
const VERSION
Full version number.
Definition: Version.php:17

◆ testReportIntercepted()

Sabre\DAV\ServerSimpleTest::testReportIntercepted ( )

Definition at line 412 of file ServerSimpleTest.php.

References Sabre\DAV\AbstractServer\$request, Sabre\HTTP\Sapi\createFromServerArray(), and Sabre\DAV\Version\VERSION.

412  {
413 
414  $serverVars = [
415  'REQUEST_URI' => '/',
416  'REQUEST_METHOD' => 'REPORT',
417  ];
418 
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();
424 
425  $this->assertEquals([
426  'X-Sabre-Version' => [Version::VERSION],
427  'testheader' => ['testvalue'],
428  ],
429  $this->response->getHeaders()
430  );
431 
432  $this->assertEquals(418, $this->response->status, 'We got an incorrect status back. Full response body follows: ' . $this->response->body);
433 
434  }
const VERSION
Full version number.
Definition: Version.php:17
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
+ Here is the call graph for this function:

◆ testReportNotFound()

Sabre\DAV\ServerSimpleTest::testReportNotFound ( )

Definition at line 389 of file ServerSimpleTest.php.

References Sabre\DAV\AbstractServer\$request, Sabre\HTTP\Sapi\createFromServerArray(), and Sabre\DAV\Version\VERSION.

389  {
390 
391  $serverVars = [
392  'REQUEST_URI' => '/',
393  'REQUEST_METHOD' => 'REPORT',
394  ];
395 
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();
400 
401  $this->assertEquals([
402  'X-Sabre-Version' => [Version::VERSION],
403  'Content-Type' => ['application/xml; charset=utf-8'],
404  ],
405  $this->response->getHeaders()
406  );
407 
408  $this->assertEquals(415, $this->response->status, 'We got an incorrect status back. Full response body follows: ' . $this->response->body);
409 
410  }
const VERSION
Full version number.
Definition: Version.php:17
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
+ Here is the call graph for this function:

◆ testTriggerException()

Sabre\DAV\ServerSimpleTest::testTriggerException ( )

Definition at line 363 of file ServerSimpleTest.php.

References Sabre\HTTP\Sapi\createFromServerArray().

363  {
364 
365  $serverVars = [
366  'REQUEST_URI' => '/',
367  'REQUEST_METHOD' => 'FOO',
368  ];
369 
370  $httpRequest = HTTP\Sapi::createFromServerArray($serverVars);
371  $this->server->httpRequest = $httpRequest;
372  $this->server->on('beforeMethod', [$this, 'exceptionTrigger']);
373  $this->server->exec();
374 
375  $this->assertEquals([
376  'Content-Type' => ['application/xml; charset=utf-8'],
377  ], $this->response->getHeaders());
378 
379  $this->assertEquals(500, $this->response->status);
380 
381  }
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: