ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
HttpDeleteTest.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\DAV;
4 
6 use Sabre\HTTP;
7 
16 
22  function setUpTree() {
23 
24  $this->tree = new Mock\Collection('root', [
25  'file1' => 'foo',
26  'dir' => [
27  'subfile' => 'bar',
28  'subfile2' => 'baz',
29  ],
30  ]);
31 
32  }
33 
37  function testDelete() {
38 
39  $request = new HTTP\Request('DELETE', '/file1');
40 
41  $response = $this->request($request);
42 
43  $this->assertEquals(
44  204,
45  $response->getStatus(),
46  "Incorrect status code. Response body: " . $response->getBodyAsString()
47  );
48 
49  $this->assertEquals(
50  [
51  'X-Sabre-Version' => [Version::VERSION],
52  'Content-Length' => ['0'],
53  ],
54  $response->getHeaders()
55  );
56 
57  }
58 
62  function testDeleteDirectory() {
63 
64  $request = new HTTP\Request('DELETE', '/dir');
65 
66  $response = $this->request($request);
67 
68  $this->assertEquals(
69  204,
70  $response->getStatus(),
71  "Incorrect status code. Response body: " . $response->getBodyAsString()
72  );
73 
74  $this->assertEquals(
75  [
76  'X-Sabre-Version' => [Version::VERSION],
77  'Content-Length' => ['0'],
78  ],
79  $response->getHeaders()
80  );
81 
82  }
83 
87  function testDeleteNotFound() {
88 
89  $request = new HTTP\Request('DELETE', '/file2');
90  $response = $this->request($request);
91 
92  $this->assertEquals(
93  404,
94  $response->getStatus(),
95  "Incorrect status code. Response body: " . $response->getBodyAsString()
96  );
97 
98  }
99 
104 
105  $request = new HTTP\Request('DELETE', '/file1', [
106  'If-Match' => '"' . md5('foo') . '"',
107  ]);
108 
109  $response = $this->request($request);
110 
111  $this->assertEquals(
112  204,
113  $response->getStatus(),
114  "Incorrect status code. Response body: " . $response->getBodyAsString()
115  );
116 
117  }
118 
123 
124  $request = new HTTP\Request('DELETE', '/file1', [
125  'If-Match' => '"' . md5('bar') . '"',
126  ]);
127 
128  $response = $this->request($request);
129 
130  $this->assertEquals(
131  412,
132  $response->getStatus(),
133  "Incorrect status code. Response body: " . $response->getBodyAsString()
134  );
135 
136  }
137 }
testDeleteNotFound()
DELETE on a node that does not exist.
testDeletePreconditionsFailed()
DELETE with incorrect preconditions.
foreach($paths as $path) $request
Definition: asyncclient.php:32
testDeletePreconditions()
DELETE with preconditions.
testDeleteDirectory()
Deleting a Directory.
const VERSION
Full version number.
Definition: Version.php:17
Collection class.
Definition: Collection.php:15
Tests related to the PUT request.
This class may be used as a basis for other webdav-related unittests.
request($request, $expectedStatus=null)
Makes a request, and returns a response object.
testDelete()
A successful DELETE.
$response
setUpTree()
Sets up the DAV tree.