8 require_once
'Sabre/DAV/AbstractServer.php';
20 $locksBackend =
new Backend\File(SABRE_TEMPDIR .
'/locksdb');
29 $this->assertArrayHasKey(
31 $this->locksPlugin->getPluginInfo()
38 $this->assertEquals([2], $this->locksPlugin->getFeatures());
44 $this->assertEquals([
'LOCK',
'UNLOCK'], $this->locksPlugin->getHTTPMethods(
''));
50 $request =
new HTTP\Request(
'LOCK',
'/test.txt');
51 $this->server->httpRequest =
$request;
52 $this->server->exec();
56 'Content-Type' => [
'application/xml; charset=utf-8'],
58 $this->response->getHeaders()
61 $this->assertEquals(400, $this->response->status);
67 $request =
new HTTP\Request(
'LOCK',
'/test.txt');
68 $request->setBody(
'<?xml version="1.0"?> 69 <D:lockinfo xmlns:D="DAV:"> 70 <D:lockscope><D:exclusive/></D:lockscope> 71 <D:locktype><D:write/></D:locktype> 73 <D:href>http://example.org/~ejw/contact.html</D:href> 77 $this->server->httpRequest =
$request;
78 $this->server->exec();
80 $this->assertEquals(
'application/xml; charset=utf-8', $this->response->getHeader(
'Content-Type'));
81 $this->assertTrue(preg_match(
'/^<opaquelocktoken:(.*)>$/', $this->response->getHeader(
'Lock-Token')) === 1,
'We did not get a valid Locktoken back (' . $this->response->getHeader(
'Lock-Token') .
')');
83 $this->assertEquals(200, $this->response->status,
'Got an incorrect status back. Response body: ' . $this->response->body);
85 $body = preg_replace(
"/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/",
"xmlns\\1=\"urn:DAV\"", $this->response->body);
86 $xml = simplexml_load_string($body);
87 $xml->registerXPathNamespace(
'd',
'urn:DAV');
91 '/d:prop/d:lockdiscovery',
92 '/d:prop/d:lockdiscovery/d:activelock',
93 '/d:prop/d:lockdiscovery/d:activelock/d:locktype',
94 '/d:prop/d:lockdiscovery/d:activelock/d:lockroot',
95 '/d:prop/d:lockdiscovery/d:activelock/d:lockroot/d:href',
96 '/d:prop/d:lockdiscovery/d:activelock/d:locktype/d:write',
97 '/d:prop/d:lockdiscovery/d:activelock/d:lockscope',
98 '/d:prop/d:lockdiscovery/d:activelock/d:lockscope/d:exclusive',
99 '/d:prop/d:lockdiscovery/d:activelock/d:depth',
100 '/d:prop/d:lockdiscovery/d:activelock/d:owner',
101 '/d:prop/d:lockdiscovery/d:activelock/d:timeout',
102 '/d:prop/d:lockdiscovery/d:activelock/d:locktoken',
103 '/d:prop/d:lockdiscovery/d:activelock/d:locktoken/d:href',
106 foreach ($elements as $elem) {
108 $this->assertEquals(1, count(
$data),
'We expected 1 match for the xpath expression "' . $elem .
'". ' . count(
$data) .
' were found. Full response body: ' . $this->response->body);
111 $depth =
$xml->xpath(
'/d:prop/d:lockdiscovery/d:activelock/d:depth');
112 $this->assertEquals(
'infinity', (
string)$depth[0]);
114 $token =
$xml->xpath(
'/d:prop/d:lockdiscovery/d:activelock/d:locktoken/d:href');
115 $this->assertEquals($this->response->getHeader(
'Lock-Token'),
'<' . (string)
$token[0] .
'>',
'Token in response body didn\'t match token in response header.');
124 $request =
new HTTP\Request(
'LOCK',
'/test.txt');
125 $request->setBody(
'<?xml version="1.0"?> 126 <D:lockinfo xmlns:D="DAV:"> 127 <D:lockscope><D:exclusive/></D:lockscope> 128 <D:locktype><D:write/></D:locktype> 130 <D:href>http://example.org/~ejw/contact.html</D:href> 134 $this->server->httpRequest =
$request;
135 $this->server->exec();
137 $this->response =
new HTTP\ResponseMock();
140 $this->server->exec();
142 $this->assertEquals(
'application/xml; charset=utf-8', $this->response->getHeader(
'Content-Type'));
144 $this->assertEquals(423, $this->response->status,
'Full response: ' . $this->response->body);
153 $request =
new HTTP\Request(
'LOCK',
'/test.txt');
154 $request->setBody(
'<?xml version="1.0"?> 155 <D:lockinfo xmlns:D="DAV:"> 156 <D:lockscope><D:exclusive/></D:lockscope> 157 <D:locktype><D:write/></D:locktype> 159 <D:href>http://example.org/~ejw/contact.html</D:href> 163 $this->server->httpRequest =
$request;
164 $this->server->exec();
166 $lockToken = $this->response->getHeader(
'Lock-Token');
168 $this->response =
new HTTP\ResponseMock();
171 $request =
new HTTP\Request(
'LOCK',
'/test.txt', [
'If' =>
'(' . $lockToken .
')']);
174 $this->server->httpRequest =
$request;
175 $this->server->exec();
177 $this->assertEquals(
'application/xml; charset=utf-8', $this->response->getHeader(
'Content-Type'));
179 $this->assertEquals(200, $this->response->status,
'We received an incorrect status code. Full response body: ' . $this->response->getBody());
188 $request =
new HTTP\Request(
'LOCK',
'/test.txt');
189 $request->setBody(
'<?xml version="1.0"?> 190 <D:lockinfo xmlns:D="DAV:"> 191 <D:lockscope><D:exclusive/></D:lockscope> 192 <D:locktype><D:write/></D:locktype> 194 <D:href>http://example.org/~ejw/contact.html</D:href> 198 $this->server->httpRequest =
$request;
199 $this->server->exec();
201 $lockToken = $this->response->getHeader(
'Lock-Token');
203 $this->response =
new HTTP\ResponseMock();
206 $request =
new HTTP\Request(
'LOCK',
'/test.txt', [
'If' =>
'(' . $lockToken .
'foobar) (<opaquelocktoken:anotherbadtoken>)']);
209 $this->server->httpRequest =
$request;
210 $this->server->exec();
212 $this->assertEquals(
'application/xml; charset=utf-8', $this->response->getHeader(
'Content-Type'));
214 $this->assertEquals(423, $this->response->getStatus(),
'We received an incorrect status code. Full response body: ' . $this->response->getBody());
223 $request =
new HTTP\Request(
'LOCK',
'/notfound.txt');
224 $request->setBody(
'<?xml version="1.0"?> 225 <D:lockinfo xmlns:D="DAV:"> 226 <D:lockscope><D:exclusive/></D:lockscope> 227 <D:locktype><D:write/></D:locktype> 229 <D:href>http://example.org/~ejw/contact.html</D:href> 233 $this->server->httpRequest =
$request;
234 $this->server->exec();
236 $this->assertEquals(
'application/xml; charset=utf-8', $this->response->getHeader(
'Content-Type'));
237 $this->assertTrue(preg_match(
'/^<opaquelocktoken:(.*)>$/', $this->response->getHeader(
'Lock-Token')) === 1,
'We did not get a valid Locktoken back (' . $this->response->getHeader(
'Lock-Token') .
')');
239 $this->assertEquals(201, $this->response->status);
248 $request =
new HTTP\Request(
'UNLOCK',
'/test.txt');
249 $this->server->httpRequest =
$request;
250 $this->server->exec();
252 $this->assertEquals([
254 'Content-Type' => [
'application/xml; charset=utf-8'],
256 $this->response->getHeaders()
259 $this->assertEquals(400, $this->response->status);
268 $request =
new HTTP\Request(
'UNLOCK',
'/test.txt', [
'Lock-Token' =>
'<opaquelocktoken:blablabla>']);
269 $this->server->httpRequest =
$request;
270 $this->server->exec();
272 $this->assertEquals([
274 'Content-Type' => [
'application/xml; charset=utf-8'],
276 $this->response->getHeaders()
279 $this->assertEquals(409, $this->response->status,
'Got an incorrect status code. Full response body: ' . $this->response->body);
288 $request =
new HTTP\Request(
'LOCK',
'/test.txt');
289 $request->setBody(
'<?xml version="1.0"?> 290 <D:lockinfo xmlns:D="DAV:"> 291 <D:lockscope><D:exclusive/></D:lockscope> 292 <D:locktype><D:write/></D:locktype> 294 <D:href>http://example.org/~ejw/contact.html</D:href> 298 $this->server->httpRequest =
$request;
299 $this->server->exec();
301 $this->assertEquals(
'application/xml; charset=utf-8', $this->response->getHeader(
'Content-Type'));
302 $this->assertTrue(preg_match(
'/^<opaquelocktoken:(.*)>$/', $this->response->getHeader(
'Lock-Token')) === 1,
'We did not get a valid Locktoken back (' . $this->response->getHeader(
'Lock-Token') .
')');
304 $this->assertEquals(200, $this->response->status);
306 $request =
new HTTP\Request(
'PUT',
'/test.txt');
308 $this->server->httpRequest =
$request;
309 $this->server->exec();
311 $this->assertEquals(
'application/xml; charset=utf-8', $this->response->getHeader(
'Content-Type'));
312 $this->assertTrue(preg_match(
'/^<opaquelocktoken:(.*)>$/', $this->response->getHeader(
'Lock-Token')) === 1,
'We did not get a valid Locktoken back (' . $this->response->getHeader(
'Lock-Token') .
')');
314 $this->assertEquals(423, $this->response->status);
323 $request =
new HTTP\Request(
'LOCK',
'/test.txt');
324 $this->server->httpRequest =
$request;
326 $request->setBody(
'<?xml version="1.0"?> 327 <D:lockinfo xmlns:D="DAV:"> 328 <D:lockscope><D:exclusive/></D:lockscope> 329 <D:locktype><D:write/></D:locktype> 331 <D:href>http://example.org/~ejw/contact.html</D:href> 335 $this->server->invokeMethod(
$request, $this->server->httpResponse);
336 $lockToken = $this->server->httpResponse->getHeader(
'Lock-Token');
338 $request =
new HTTP\Request(
'UNLOCK',
'/test.txt', [
'Lock-Token' => $lockToken]);
339 $this->server->httpRequest =
$request;
340 $this->server->httpResponse =
new HTTP\ResponseMock();
341 $this->server->invokeMethod(
$request, $this->server->httpResponse);
343 $this->assertEquals(204, $this->server->httpResponse->status,
'Got an incorrect status code. Full response body: ' . $this->response->body);
344 $this->assertEquals([
346 'Content-Length' => [
'0'],
348 $this->server->httpResponse->getHeaders()
359 $request =
new HTTP\Request(
'LOCK',
'/test.txt');
360 $this->server->httpRequest =
$request;
362 $request->setBody(
'<?xml version="1.0"?> 363 <D:lockinfo xmlns:D="DAV:"> 364 <D:lockscope><D:exclusive/></D:lockscope> 365 <D:locktype><D:write/></D:locktype> 367 <D:href>http://example.org/~ejw/contact.html</D:href> 371 $this->server->invokeMethod(
$request, $this->server->httpResponse);
372 $lockToken = $this->server->httpResponse->getHeader(
'Lock-Token');
375 $lockToken = trim($lockToken,
'<>');
377 $request =
new HTTP\Request(
'UNLOCK',
'/test.txt', [
'Lock-Token' => $lockToken]);
378 $this->server->httpRequest =
$request;
379 $this->server->httpResponse =
new HTTP\ResponseMock();
380 $this->server->invokeMethod(
$request, $this->server->httpResponse);
382 $this->assertEquals(204, $this->server->httpResponse->status,
'Got an incorrect status code. Full response body: ' . $this->response->body);
383 $this->assertEquals([
385 'Content-Length' => [
'0'],
387 $this->server->httpResponse->getHeaders()
399 'REQUEST_URI' =>
'/test.txt',
400 'REQUEST_METHOD' =>
'LOCK',
402 $this->server->httpRequest =
$request;
404 $request->setBody(
'<?xml version="1.0"?> 405 <D:lockinfo xmlns:D="DAV:"> 406 <D:lockscope><D:exclusive/></D:lockscope> 407 <D:locktype><D:write/></D:locktype> 408 <D:owner>Evert</D:owner> 411 $this->server->invokeMethod(
$request, $this->server->httpResponse);
412 $lockToken = $this->server->httpResponse->getHeader(
'Lock-Token');
414 $locks = $this->locksPlugin->getLocks(
'test.txt');
415 $this->assertEquals(1, count($locks));
416 $this->assertEquals(
'Evert', $locks[0]->owner);
427 'REQUEST_URI' =>
'/test.txt',
428 'REQUEST_METHOD' =>
'LOCK',
432 $request->setBody(
'<?xml version="1.0"?> 433 <D:lockinfo xmlns:D="DAV:"> 434 <D:lockscope><D:exclusive/></D:lockscope> 435 <D:locktype><D:write/></D:locktype> 437 <D:href>http://example.org/~ejw/contact.html</D:href> 441 $this->server->httpRequest =
$request;
442 $this->server->exec();
444 $this->assertEquals(
'application/xml; charset=utf-8', $this->response->getHeader(
'Content-Type'));
445 $this->assertTrue(preg_match(
'/^<opaquelocktoken:(.*)>$/', $this->response->getHeader(
'Lock-Token')) === 1,
'We did not get a valid Locktoken back (' . $this->response->getHeader(
'Lock-Token') .
')');
447 $this->assertEquals(200, $this->response->status);
450 'REQUEST_URI' =>
'/test.txt',
451 'REQUEST_METHOD' =>
'PUT',
452 'HTTP_IF' =>
'(<opaquelocktoken:token1>)',
457 $this->server->httpRequest =
$request;
458 $this->server->exec();
460 $this->assertEquals(
'application/xml; charset=utf-8', $this->response->getHeader(
'Content-Type'));
461 $this->assertTrue(preg_match(
'/^<opaquelocktoken:(.*)>$/', $this->response->getHeader(
'Lock-Token')) === 1,
'We did not get a valid Locktoken back (' . $this->response->getHeader(
'Lock-Token') .
')');
464 $this->assertEquals(423, $this->response->status);
474 'REQUEST_URI' =>
'/dir/child.txt',
475 'REQUEST_METHOD' =>
'LOCK',
479 $request->setBody(
'<?xml version="1.0"?> 480 <D:lockinfo xmlns:D="DAV:"> 481 <D:lockscope><D:exclusive/></D:lockscope> 482 <D:locktype><D:write/></D:locktype> 484 <D:href>http://example.org/~ejw/contact.html</D:href> 488 $this->server->httpRequest =
$request;
489 $this->server->exec();
491 $this->assertEquals(
'application/xml; charset=utf-8', $this->response->getHeader(
'Content-Type'));
492 $this->assertTrue(preg_match(
'/^<opaquelocktoken:(.*)>$/', $this->response->getHeader(
'Lock-Token')) === 1,
'We did not get a valid Locktoken back (' . $this->response->getHeader(
'Lock-Token') .
')');
494 $this->assertEquals(200, $this->response->status);
497 'REQUEST_URI' =>
'/dir',
498 'REQUEST_METHOD' =>
'DELETE',
502 $this->server->httpRequest =
$request;
503 $this->server->exec();
505 $this->assertEquals(423, $this->response->status);
506 $this->assertEquals(
'application/xml; charset=utf-8', $this->response->getHeader(
'Content-Type'));
515 'REQUEST_URI' =>
'/dir/child.txt',
516 'REQUEST_METHOD' =>
'LOCK',
520 $request->setBody(
'<?xml version="1.0"?> 521 <D:lockinfo xmlns:D="DAV:"> 522 <D:lockscope><D:exclusive/></D:lockscope> 523 <D:locktype><D:write/></D:locktype> 525 <D:href>http://example.org/~ejw/contact.html</D:href> 529 $this->server->httpRequest =
$request;
530 $this->server->exec();
532 $this->assertEquals(
'application/xml; charset=utf-8', $this->response->getHeader(
'Content-Type'));
533 $this->assertTrue(preg_match(
'/^<opaquelocktoken:(.*)>$/', $this->response->getHeader(
'Lock-Token')) === 1,
'We did not get a valid Locktoken back (' . $this->response->getHeader(
'Lock-Token') .
')');
535 $this->assertEquals(200, $this->response->status);
538 'REQUEST_URI' =>
'/dir/child.txt',
539 'REQUEST_METHOD' =>
'DELETE',
540 'HTTP_IF' =>
'(' . $this->response->getHeader(
'Lock-Token') .
')',
544 $this->server->httpRequest =
$request;
545 $this->server->exec();
547 $this->assertEquals(204, $this->response->status);
548 $this->assertEquals(
'application/xml; charset=utf-8', $this->response->getHeader(
'Content-Type'));
558 'REQUEST_URI' =>
'/dir/child.txt',
559 'REQUEST_METHOD' =>
'LOCK',
563 $request->setBody(
'<?xml version="1.0"?> 564 <D:lockinfo xmlns:D="DAV:"> 565 <D:lockscope><D:exclusive/></D:lockscope> 566 <D:locktype><D:write/></D:locktype> 568 <D:href>http://example.org/~ejw/contact.html</D:href> 572 $this->server->httpRequest =
$request;
573 $this->server->exec();
575 $this->assertEquals(
'application/xml; charset=utf-8', $this->response->getHeader(
'Content-Type'));
576 $this->assertTrue(preg_match(
'/^<opaquelocktoken:(.*)>$/', $this->response->getHeader(
'Lock-Token')) === 1,
'We did not get a valid Locktoken back (' . $this->response->getHeader(
'Lock-Token') .
')');
578 $this->assertEquals(200, $this->response->status);
581 'REQUEST_URI' =>
'/dir/child.txt',
582 'REQUEST_METHOD' =>
'COPY',
583 'HTTP_DESTINATION' =>
'/dir/child2.txt',
587 $this->server->httpRequest =
$request;
588 $this->server->exec();
590 $this->assertEquals(201, $this->response->status,
'Copy must succeed if only the source is locked, but not the destination');
591 $this->assertEquals(
'application/xml; charset=utf-8', $this->response->getHeader(
'Content-Type'));
600 'REQUEST_URI' =>
'/dir/child2.txt',
601 'REQUEST_METHOD' =>
'LOCK',
605 $request->setBody(
'<?xml version="1.0"?> 606 <D:lockinfo xmlns:D="DAV:"> 607 <D:lockscope><D:exclusive/></D:lockscope> 608 <D:locktype><D:write/></D:locktype> 610 <D:href>http://example.org/~ejw/contact.html</D:href> 614 $this->server->httpRequest =
$request;
615 $this->server->exec();
617 $this->assertEquals(
'application/xml; charset=utf-8', $this->response->getHeader(
'Content-Type'));
618 $this->assertTrue(preg_match(
'/^<opaquelocktoken:(.*)>$/', $this->response->getHeader(
'Lock-Token')) === 1,
'We did not get a valid Locktoken back (' . $this->response->getHeader(
'Lock-Token') .
')');
620 $this->assertEquals(201, $this->response->status);
623 'REQUEST_URI' =>
'/dir/child.txt',
624 'REQUEST_METHOD' =>
'COPY',
625 'HTTP_DESTINATION' =>
'/dir/child2.txt',
629 $this->server->httpRequest =
$request;
630 $this->server->exec();
632 $this->assertEquals(423, $this->response->status,
'Copy must succeed if only the source is locked, but not the destination');
633 $this->assertEquals(
'application/xml; charset=utf-8', $this->response->getHeader(
'Content-Type'));
643 'REQUEST_URI' =>
'/dir/child.txt',
644 'REQUEST_METHOD' =>
'LOCK',
648 $request->setBody(
'<?xml version="1.0"?> 649 <D:lockinfo xmlns:D="DAV:"> 650 <D:lockscope><D:exclusive/></D:lockscope> 651 <D:locktype><D:write/></D:locktype> 653 <D:href>http://example.org/~ejw/contact.html</D:href> 657 $this->server->httpRequest =
$request;
658 $this->server->exec();
660 $this->assertEquals(
'application/xml; charset=utf-8', $this->response->getHeader(
'Content-Type'));
661 $this->assertTrue(preg_match(
'/^<opaquelocktoken:(.*)>$/', $this->response->getHeader(
'Lock-Token')) === 1,
'We did not get a valid Locktoken back (' . $this->response->getHeader(
'Lock-Token') .
')');
663 $this->assertEquals(200, $this->response->status);
666 'REQUEST_URI' =>
'/dir/child.txt',
667 'REQUEST_METHOD' =>
'MOVE',
668 'HTTP_DESTINATION' =>
'/dir/child2.txt',
672 $this->server->httpRequest =
$request;
673 $this->server->exec();
675 $this->assertEquals(423, $this->response->status,
'Copy must succeed if only the source is locked, but not the destination');
676 $this->assertEquals(
'application/xml; charset=utf-8', $this->response->getHeader(
'Content-Type'));
686 'REQUEST_URI' =>
'/dir/child.txt',
687 'REQUEST_METHOD' =>
'LOCK',
691 $request->setBody(
'<?xml version="1.0"?> 692 <D:lockinfo xmlns:D="DAV:"> 693 <D:lockscope><D:exclusive/></D:lockscope> 694 <D:locktype><D:write/></D:locktype> 696 <D:href>http://example.org/~ejw/contact.html</D:href> 700 $this->server->httpRequest =
$request;
701 $this->server->exec();
703 $this->assertEquals(
'application/xml; charset=utf-8', $this->response->getHeader(
'Content-Type'));
704 $this->assertTrue(preg_match(
'/^<opaquelocktoken:(.*)>$/', $this->response->getHeader(
'Lock-Token')) === 1,
'We did not get a valid Locktoken back (' . $this->response->getHeader(
'Lock-Token') .
')');
706 $this->assertEquals(200, $this->response->status);
709 'REQUEST_URI' =>
'/dir/child.txt',
710 'REQUEST_METHOD' =>
'MOVE',
711 'HTTP_DESTINATION' =>
'/dir/child2.txt',
712 'HTTP_IF' =>
'(' . $this->response->getHeader(
'Lock-Token') .
')',
716 $this->server->httpRequest =
$request;
717 $this->server->exec();
719 $this->assertEquals(201, $this->response->status,
'A valid lock-token was provided for the source, so this MOVE operation must succeed. Full response body: ' . $this->response->body);
729 'REQUEST_URI' =>
'/dir/child2.txt',
730 'REQUEST_METHOD' =>
'LOCK',
734 $request->setBody(
'<?xml version="1.0"?> 735 <D:lockinfo xmlns:D="DAV:"> 736 <D:lockscope><D:exclusive/></D:lockscope> 737 <D:locktype><D:write/></D:locktype> 739 <D:href>http://example.org/~ejw/contact.html</D:href> 743 $this->server->httpRequest =
$request;
744 $this->server->exec();
746 $this->assertEquals(
'application/xml; charset=utf-8', $this->response->getHeader(
'Content-Type'));
747 $this->assertTrue(preg_match(
'/^<opaquelocktoken:(.*)>$/', $this->response->getHeader(
'Lock-Token')) === 1,
'We did not get a valid Locktoken back (' . $this->response->getHeader(
'Lock-Token') .
')');
749 $this->assertEquals(201, $this->response->status);
752 'REQUEST_URI' =>
'/dir/child.txt',
753 'REQUEST_METHOD' =>
'MOVE',
754 'HTTP_DESTINATION' =>
'/dir/child2.txt',
758 $this->server->httpRequest =
$request;
759 $this->server->exec();
761 $this->assertEquals(423, $this->response->status,
'Copy must succeed if only the source is locked, but not the destination');
762 $this->assertEquals(
'application/xml; charset=utf-8', $this->response->getHeader(
'Content-Type'));
771 'REQUEST_URI' =>
'/dir',
772 'REQUEST_METHOD' =>
'LOCK',
773 'HTTP_DEPTH' =>
'infinite',
777 $request->setBody(
'<?xml version="1.0"?> 778 <D:lockinfo xmlns:D="DAV:"> 779 <D:lockscope><D:exclusive/></D:lockscope> 780 <D:locktype><D:write/></D:locktype> 782 <D:href>http://example.org/~ejw/contact.html</D:href> 786 $this->server->httpRequest =
$request;
787 $this->server->exec();
789 $this->assertEquals(
'application/xml; charset=utf-8', $this->response->getHeader(
'Content-Type'));
790 $this->assertTrue(preg_match(
'/^<opaquelocktoken:(.*)>$/', $this->response->getHeader(
'Lock-Token')) === 1,
'We did not get a valid Locktoken back (' . $this->response->getHeader(
'Lock-Token') .
')');
792 $this->assertEquals(200, $this->response->status);
795 'REQUEST_URI' =>
'/dir/child.txt',
796 'REQUEST_METHOD' =>
'MOVE',
797 'HTTP_DESTINATION' =>
'/dir/child2.txt',
798 'HTTP_IF' =>
'</dir> (' . $this->response->getHeader(
'Lock-Token') .
')',
802 $this->server->httpRequest =
$request;
803 $this->server->exec();
805 $this->assertEquals(201, $this->response->status,
'We locked the parent of both the source and destination, but the move didn\'t succeed.');
806 $this->assertEquals(
'application/xml; charset=utf-8', $this->response->getHeader(
'Content-Type'));
816 'REQUEST_URI' =>
'/test.txt',
817 'REQUEST_METHOD' =>
'LOCK',
821 $request->setBody(
'<?xml version="1.0"?> 822 <D:lockinfo xmlns:D="DAV:"> 823 <D:lockscope><D:exclusive/></D:lockscope> 824 <D:locktype><D:write/></D:locktype> 826 <D:href>http://example.org/~ejw/contact.html</D:href> 830 $this->server->httpRequest =
$request;
831 $this->server->exec();
833 $this->assertEquals(
'application/xml; charset=utf-8', $this->response->getHeader(
'Content-Type'));
834 $this->assertTrue(preg_match(
'/^<opaquelocktoken:(.*)>$/', $this->response->getHeader(
'Lock-Token')) === 1,
'We did not get a valid Locktoken back (' . $this->response->getHeader(
'Lock-Token') .
')');
836 $this->assertEquals(200, $this->response->status);
839 'REQUEST_URI' =>
'/test.txt',
840 'REQUEST_METHOD' =>
'PUT',
841 'HTTP_IF' =>
'(' . $this->response->getHeader(
'Lock-Token') .
')',
846 $this->server->httpRequest =
$request;
847 $this->server->exec();
849 $this->assertEquals(
'application/xml; charset=utf-8', $this->response->getHeader(
'Content-Type'));
850 $this->assertTrue(preg_match(
'/^<opaquelocktoken:(.*)>$/', $this->response->getHeader(
'Lock-Token')) === 1,
'We did not get a valid Locktoken back (' . $this->response->getHeader(
'Lock-Token') .
')');
852 $this->assertEquals(204, $this->response->status);
861 $request =
new HTTP\Request(
'LOCK',
'/unrelated.txt');
862 $request->setBody(
'<?xml version="1.0"?> 863 <D:lockinfo xmlns:D="DAV:"> 864 <D:lockscope><D:exclusive/></D:lockscope> 865 <D:locktype><D:write/></D:locktype> 867 <D:href>http://example.org/~ejw/contact.html</D:href> 871 $this->server->httpRequest =
$request;
872 $this->server->exec();
874 $this->assertEquals(
'application/xml; charset=utf-8', $this->response->getHeader(
'Content-Type'));
875 $this->assertTrue(preg_match(
'/^<opaquelocktoken:(.*)>$/', $this->response->getHeader(
'Lock-Token')) === 1,
'We did not get a valid Locktoken back (' . $this->response->getHeader(
'Lock-Token') .
')');
877 $this->assertEquals(201, $this->response->getStatus());
882 [
'If' =>
'</unrelated.txt> (' . $this->response->getHeader(
'Lock-Token') .
')']
884 $request->setBody(
'newbody');
885 $this->server->httpRequest =
$request;
886 $this->server->exec();
888 $this->assertEquals(
'application/xml; charset=utf-8', $this->response->getHeader(
'Content-Type'));
889 $this->assertTrue(preg_match(
'/^<opaquelocktoken:(.*)>$/', $this->response->getHeader(
'Lock-Token')) === 1,
'We did not get a valid Locktoken back (' . $this->response->getHeader(
'Lock-Token') .
')');
891 $this->assertEquals(204, $this->response->status);
898 'REQUEST_URI' =>
'/test.txt',
899 'REQUEST_METHOD' =>
'PUT',
900 'HTTP_IF' =>
'(["etag1"])',
905 $this->server->httpRequest =
$request;
906 $this->server->exec();
907 $this->assertEquals(412, $this->response->status);
917 $tree =
new DAV\Tree(
new DAV\FSExt\Directory(SABRE_TEMPDIR));
918 $this->server->tree =
$tree;
927 'REQUEST_URI' =>
'/test.txt',
928 'REQUEST_METHOD' =>
'PUT',
929 'HTTP_IF' =>
'(["' . $etag .
'"])',
934 $this->server->httpRequest =
$request;
935 $this->server->exec();
936 $this->assertEquals(204, $this->response->status,
'Incorrect status received. Full response body:' . $this->response->body);
943 'REQUEST_URI' =>
'/dir',
944 'REQUEST_METHOD' =>
'DELETE',
945 'HTTP_IF' =>
'(["etag1"])',
949 $this->server->httpRequest =
$request;
950 $this->server->exec();
951 $this->assertEquals(412, $this->response->status);
958 'HTTP_TIMEOUT' =>
'second-100',
961 $this->server->httpRequest =
$request;
962 $this->assertEquals(100, $this->locksPlugin->getTimeoutHeader());
969 'HTTP_TIMEOUT' =>
'second-5, infinite',
972 $this->server->httpRequest =
$request;
973 $this->assertEquals(5, $this->locksPlugin->getTimeoutHeader());
980 'HTTP_TIMEOUT' =>
'infinite, second-5',
983 $this->server->httpRequest =
$request;
994 'HTTP_TIMEOUT' =>
'yourmom',
997 $this->server->httpRequest =
$request;
998 $this->locksPlugin->getTimeoutHeader();
testUnlockWindowsBug()
testLock
testLockRefresh()
testLock
testPutWithCorrectETag()
testPutWithIncorrectETag
testUnlockBadToken()
testLock
testPutWithIncorrectETag()
testLockPutGoodToken()
testLock
testLockMoveLockSourceLocked()
testLock
testLockDeleteSucceed()
testLock
testLockRetainOwner()
testLock
testUnlockNoToken()
testLock
const VERSION
Full version number.
testLockRefreshBadToken()
testLock
testGetTimeoutHeaderInvalid()
Sabre
testGetTimeoutHeaderTwoItems()
testLockMoveLockDestination()
testLock
testGetTimeoutHeaderInfinite()
testDeleteWithETagOnCollection()
testLockMoveLockParent()
testLock
testLockCopyLockSource()
testLock
testLockCopyLockDestination()
testLock
testLockPutUnrelatedToken()
testLock
testLockPutBadToken()
testLock
const TIMEOUT_INFINITE
A never expiring timeout.
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
testLockMoveLockSourceSucceed()
testLock
The tree object is responsible for basic tree operations.
testLockPutNoToken()
testLock
testLockDeleteParent()
testLock