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

Public Member Functions

 testGet ()
 
 testHEAD ()
 
 testPut ()
 
 testPutAlreadyExists ()
 
 testMkcol ()
 
 testPutUpdate ()
 
 testDelete ()
 
 testDeleteDirectory ()
 
 testOptions ()
 
 testMove ()
 
 testMoveOtherObject ()
 This test checks if it's possible to move a non-FSExt collection into a FSExt collection. More...
 
- Public Member Functions inherited from Sabre\DAV\AbstractServer
 setUp ()
 
 tearDown ()
 

Protected Member Functions

 getRootNode ()
 
- Protected Member Functions inherited from Sabre\DAV\AbstractServer
 getRootNode ()
 

Additional Inherited Members

- Protected Attributes inherited from Sabre\DAV\AbstractServer
 $response
 
 $request
 
 $server
 
 $tempDir = SABRE_TEMPDIR
 

Detailed Description

Definition at line 10 of file ServerTest.php.

Member Function Documentation

◆ getRootNode()

Sabre\DAV\FSExt\ServerTest::getRootNode ( )
protected

Definition at line 12 of file ServerTest.php.

12  {
13 
14  return new Directory($this->tempDir);
15 
16  }

◆ testDelete()

Sabre\DAV\FSExt\ServerTest::testDelete ( )

Definition at line 132 of file ServerTest.php.

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

132  {
133 
134  $request = new HTTP\Request('DELETE', '/test.txt');
135  $this->server->httpRequest = ($request);
136  $this->server->exec();
137 
138  $this->assertEquals([
139  'X-Sabre-Version' => [DAV\Version::VERSION],
140  'Content-Length' => ['0'],
141  ], $this->response->getHeaders());
142 
143  $this->assertEquals(204, $this->response->status);
144  $this->assertEquals('', $this->response->body);
145  $this->assertFalse(file_exists($this->tempDir . '/test.txt'));
146 
147  }
const VERSION
Full version number.
Definition: Version.php:17

◆ testDeleteDirectory()

Sabre\DAV\FSExt\ServerTest::testDeleteDirectory ( )

Definition at line 149 of file ServerTest.php.

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

149  {
150 
151  mkdir($this->tempDir . '/testcol');
152  file_put_contents($this->tempDir . '/testcol/test.txt', 'Hi! I\'m a file with a short lifespan');
153 
154  $request = new HTTP\Request('DELETE', '/testcol');
155  $this->server->httpRequest = ($request);
156  $this->server->exec();
157 
158  $this->assertEquals([
159  'X-Sabre-Version' => [DAV\Version::VERSION],
160  'Content-Length' => ['0'],
161  ], $this->response->getHeaders());
162  $this->assertEquals(204, $this->response->status);
163  $this->assertEquals('', $this->response->body);
164  $this->assertFalse(file_exists($this->tempDir . '/testcol'));
165 
166  }
const VERSION
Full version number.
Definition: Version.php:17

◆ testGet()

Sabre\DAV\FSExt\ServerTest::testGet ( )

Definition at line 18 of file ServerTest.php.

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

18  {
19 
20  $request = new HTTP\Request('GET', '/test.txt');
21  $filename = $this->tempDir . '/test.txt';
22  $this->server->httpRequest = $request;
23  $this->server->exec();
24 
25  $this->assertEquals(200, $this->response->getStatus(), 'Invalid status code received.');
26  $this->assertEquals([
27  'X-Sabre-Version' => [DAV\Version::VERSION],
28  'Content-Type' => ['application/octet-stream'],
29  'Content-Length' => [13],
30  'Last-Modified' => [HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($filename)))],
31  'ETag' => ['"' . sha1(fileinode($filename) . filesize($filename) . filemtime($filename)) . '"'],
32  ],
33  $this->response->getHeaders()
34  );
35 
36 
37  $this->assertEquals('Test contents', stream_get_contents($this->response->body));
38 
39  }
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
+ Here is the call graph for this function:

◆ testHEAD()

Sabre\DAV\FSExt\ServerTest::testHEAD ( )

Definition at line 41 of file ServerTest.php.

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

41  {
42 
43  $request = new HTTP\Request('HEAD', '/test.txt');
44  $filename = $this->tempDir . '/test.txt';
45  $this->server->httpRequest = ($request);
46  $this->server->exec();
47 
48  $this->assertEquals([
49  'X-Sabre-Version' => [DAV\Version::VERSION],
50  'Content-Type' => ['application/octet-stream'],
51  'Content-Length' => [13],
52  'Last-Modified' => [HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($this->tempDir . '/test.txt')))],
53  'ETag' => ['"' . sha1(fileinode($filename) . filesize($filename) . filemtime($filename)) . '"'],
54  ],
55  $this->response->getHeaders()
56  );
57 
58  $this->assertEquals(200, $this->response->status);
59  $this->assertEquals('', $this->response->body);
60 
61  }
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
+ Here is the call graph for this function:

◆ testMkcol()

Sabre\DAV\FSExt\ServerTest::testMkcol ( )

Definition at line 100 of file ServerTest.php.

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

100  {
101 
102  $request = new HTTP\Request('MKCOL', '/testcol');
103  $this->server->httpRequest = ($request);
104  $this->server->exec();
105 
106  $this->assertEquals([
107  'X-Sabre-Version' => [DAV\Version::VERSION],
108  'Content-Length' => ['0'],
109  ], $this->response->getHeaders());
110 
111  $this->assertEquals(201, $this->response->status);
112  $this->assertEquals('', $this->response->body);
113  $this->assertTrue(is_dir($this->tempDir . '/testcol'));
114 
115  }
const VERSION
Full version number.
Definition: Version.php:17

◆ testMove()

Sabre\DAV\FSExt\ServerTest::testMove ( )

Definition at line 188 of file ServerTest.php.

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

188  {
189 
190  mkdir($this->tempDir . '/testcol');
191 
192  $request = new HTTP\Request('MOVE', '/test.txt', ['Destination' => '/testcol/test2.txt']);
193  $this->server->httpRequest = ($request);
194  $this->server->exec();
195 
196  $this->assertEquals(201, $this->response->status);
197  $this->assertEquals('', $this->response->body);
198 
199  $this->assertEquals([
200  'Content-Length' => ['0'],
201  'X-Sabre-Version' => [DAV\Version::VERSION],
202  ], $this->response->getHeaders());
203 
204  $this->assertTrue(
205  is_file($this->tempDir . '/testcol/test2.txt')
206  );
207 
208 
209  }
const VERSION
Full version number.
Definition: Version.php:17

◆ testMoveOtherObject()

Sabre\DAV\FSExt\ServerTest::testMoveOtherObject ( )

This test checks if it's possible to move a non-FSExt collection into a FSExt collection.

The moveInto function should ignore the object and let sabredav itself execute the slow move.

Definition at line 218 of file ServerTest.php.

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

218  {
219 
220  mkdir($this->tempDir . '/tree1');
221  mkdir($this->tempDir . '/tree2');
222 
223  $tree = new DAV\Tree(new DAV\SimpleCollection('root', [
224  new DAV\FS\Directory($this->tempDir . '/tree1'),
225  new DAV\FSExt\Directory($this->tempDir . '/tree2'),
226  ]));
227  $this->server->tree = $tree;
228 
229  $request = new HTTP\Request('MOVE', '/tree1', ['Destination' => '/tree2/tree1']);
230  $this->server->httpRequest = ($request);
231  $this->server->exec();
232 
233  $this->assertEquals(201, $this->response->status);
234  $this->assertEquals('', $this->response->body);
235 
236  $this->assertEquals([
237  'Content-Length' => ['0'],
238  'X-Sabre-Version' => [DAV\Version::VERSION],
239  ], $this->response->getHeaders());
240 
241  $this->assertTrue(
242  is_dir($this->tempDir . '/tree2/tree1')
243  );
244 
245  }
const VERSION
Full version number.
Definition: Version.php:17

◆ testOptions()

Sabre\DAV\FSExt\ServerTest::testOptions ( )

Definition at line 168 of file ServerTest.php.

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

168  {
169 
170  $request = new HTTP\Request('OPTIONS', '/');
171  $this->server->httpRequest = ($request);
172  $this->server->exec();
173 
174  $this->assertEquals([
175  'DAV' => ['1, 3, extended-mkcol'],
176  'MS-Author-Via' => ['DAV'],
177  'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT'],
178  'Accept-Ranges' => ['bytes'],
179  'Content-Length' => ['0'],
180  'X-Sabre-Version' => [DAV\Version::VERSION],
181  ], $this->response->getHeaders());
182 
183  $this->assertEquals(200, $this->response->status);
184  $this->assertEquals('', $this->response->body);
185 
186  }
const VERSION
Full version number.
Definition: Version.php:17

◆ testPut()

Sabre\DAV\FSExt\ServerTest::testPut ( )

Definition at line 63 of file ServerTest.php.

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

63  {
64 
65  $request = new HTTP\Request('PUT', '/testput.txt');
66  $filename = $this->tempDir . '/testput.txt';
67  $request->setBody('Testing new file');
68  $this->server->httpRequest = ($request);
69  $this->server->exec();
70 
71  $this->assertEquals([
72  'X-Sabre-Version' => [DAV\Version::VERSION],
73  'Content-Length' => ['0'],
74  'ETag' => ['"' . sha1(fileinode($filename) . filesize($filename) . filemtime($filename)) . '"'],
75  ], $this->response->getHeaders());
76 
77  $this->assertEquals(201, $this->response->status);
78  $this->assertEquals('', $this->response->body);
79  $this->assertEquals('Testing new file', file_get_contents($filename));
80 
81  }
const VERSION
Full version number.
Definition: Version.php:17
$filename
Definition: buildRTE.php:89

◆ testPutAlreadyExists()

Sabre\DAV\FSExt\ServerTest::testPutAlreadyExists ( )

Definition at line 83 of file ServerTest.php.

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

83  {
84 
85  $request = new HTTP\Request('PUT', '/test.txt', ['If-None-Match' => '*']);
86  $request->setBody('Testing new file');
87  $this->server->httpRequest = ($request);
88  $this->server->exec();
89 
90  $this->assertEquals([
91  'X-Sabre-Version' => [DAV\Version::VERSION],
92  'Content-Type' => ['application/xml; charset=utf-8'],
93  ], $this->response->getHeaders());
94 
95  $this->assertEquals(412, $this->response->status);
96  $this->assertNotEquals('Testing new file', file_get_contents($this->tempDir . '/test.txt'));
97 
98  }
const VERSION
Full version number.
Definition: Version.php:17

◆ testPutUpdate()

Sabre\DAV\FSExt\ServerTest::testPutUpdate ( )

Definition at line 117 of file ServerTest.php.

References Sabre\DAV\AbstractServer\$request.

117  {
118 
119  $request = new HTTP\Request('PUT', '/test.txt');
120  $request->setBody('Testing updated file');
121  $this->server->httpRequest = ($request);
122  $this->server->exec();
123 
124  $this->assertEquals('0', $this->response->getHeader('Content-Length'));
125 
126  $this->assertEquals(204, $this->response->status);
127  $this->assertEquals('', $this->response->body);
128  $this->assertEquals('Testing updated file', file_get_contents($this->tempDir . '/test.txt'));
129 
130  }

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