diff options
author | root <root@v22013111044215586.yourvserver.net> | 2014-06-29 18:30:59 +0200 |
---|---|---|
committer | root <root@v22013111044215586.yourvserver.net> | 2014-06-29 18:30:59 +0200 |
commit | 5df50c4a0bf80f3697c7088c9c4a3815206fe97d (patch) | |
tree | ad3f2b4df700dae971683265c9a83d5bbee0eb31 /vendor/sabre/dav/tests/Sabre/DAV/HttpDeleteTest.php | |
parent | 79dc4b83701f73bdece2b4d78a73698fbbc538c6 (diff) | |
parent | 628f1218049715c8acf953dbda8f902b3902cc2f (diff) | |
download | volse-hubzilla-5df50c4a0bf80f3697c7088c9c4a3815206fe97d.tar.gz volse-hubzilla-5df50c4a0bf80f3697c7088c9c4a3815206fe97d.tar.bz2 volse-hubzilla-5df50c4a0bf80f3697c7088c9c4a3815206fe97d.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAV/HttpDeleteTest.php')
-rw-r--r-- | vendor/sabre/dav/tests/Sabre/DAV/HttpDeleteTest.php | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/HttpDeleteTest.php b/vendor/sabre/dav/tests/Sabre/DAV/HttpDeleteTest.php new file mode 100644 index 000000000..da28b6979 --- /dev/null +++ b/vendor/sabre/dav/tests/Sabre/DAV/HttpDeleteTest.php @@ -0,0 +1,149 @@ +<?php + +namespace Sabre\DAV; + +use Sabre\DAVServerTest; +use Sabre\HTTP; + +/** + * Tests related to the PUT request. + * + * @copyright Copyright (C) 2007-2014 fruux GmbH. All rights reserved. + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License + */ +class HttpDeleteTest extends DAVServerTest { + + /** + * Sets up the DAV tree. + * + * @return void + */ + public function setUpTree() { + + $this->tree = new Mock\Collection('root', array( + 'file1' => 'foo', + 'dir' => array( + 'subfile' => 'bar', + 'subfile2' => 'baz', + ), + )); + + } + + /** + * A successful DELETE + */ + public function testDelete() { + + $request = new HTTP\Request(array( + 'REQUEST_URI' => '/file1', + 'REQUEST_METHOD' => 'DELETE', + )); + + $response = $this->request($request); + + $this->assertEquals( + 'HTTP/1.1 204 No Content', + $response->status, + "Incorrect status code. Response body: " . $response->body + ); + + $this->assertEquals( + array( + 'Content-Length' => '0', + ), + $response->headers + ); + + } + + /** + * Deleting a Directory + */ + public function testDeleteDirectory() { + + $request = new HTTP\Request(array( + 'REQUEST_URI' => '/dir', + 'REQUEST_METHOD' => 'DELETE', + )); + + $response = $this->request($request); + + $this->assertEquals( + 'HTTP/1.1 204 No Content', + $response->status, + "Incorrect status code. Response body: " . $response->body + ); + + $this->assertEquals( + array( + 'Content-Length' => '0', + ), + $response->headers + ); + + } + + /** + * DELETE on a node that does not exist + */ + public function testDeleteNotFound() { + + $request = new HTTP\Request(array( + 'REQUEST_URI' => '/file2', + 'REQUEST_METHOD' => 'DELETE', + )); + + $response = $this->request($request); + + $this->assertEquals( + 'HTTP/1.1 404 Not Found', + $response->status, + "Incorrect status code. Response body: " . $response->body + ); + + } + + /** + * DELETE with preconditions + */ + public function testDeletePreconditions() { + + $request = new HTTP\Request(array( + 'REQUEST_URI' => '/file1', + 'REQUEST_METHOD' => 'DELETE', + 'HTTP_IF_MATCH' => '"' . md5('foo') . '"', + )); + + $response = $this->request($request); + + $this->assertEquals( + 'HTTP/1.1 204 No Content', + $response->status, + "Incorrect status code. Response body: " . $response->body + ); + + } + + /** + * DELETE with incorrect preconditions + */ + public function testDeletePreconditionsFailed() { + + $request = new HTTP\Request(array( + 'REQUEST_URI' => '/file1', + 'REQUEST_METHOD' => 'DELETE', + 'HTTP_IF_MATCH' => '"' . md5('bar') . '"', + )); + + $response = $this->request($request); + + $this->assertEquals( + 'HTTP/1.1 412 Precondition failed', + $response->status, + "Incorrect status code. Response body: " . $response->body + ); + + } +} |