ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
HttpGetTest.php
Go to the documentation of this file.
1<?php
2
3namespace Sabre\DAV;
4
6use Sabre\HTTP;
7
16
22 function setUpTree() {
23
24 $this->tree = new Mock\Collection('root', [
25 'file1' => 'foo',
26 new Mock\Collection('dir', []),
27 new Mock\StreamingFile('streaming', 'stream')
28 ]);
29
30 }
31
32 function testGet() {
33
34 $request = new HTTP\Request('GET', '/file1');
35 $response = $this->request($request);
36
37 $this->assertEquals(200, $response->getStatus());
38
39 // Removing Last-Modified because it keeps changing.
40 $response->removeHeader('Last-Modified');
41
42 $this->assertEquals(
43 [
44 'X-Sabre-Version' => [Version::VERSION],
45 'Content-Type' => ['application/octet-stream'],
46 'Content-Length' => [3],
47 'ETag' => ['"' . md5('foo') . '"'],
48 ],
49 $response->getHeaders()
50 );
51
52 $this->assertEquals('foo', $response->getBodyAsString());
53
54 }
55
56 function testGetHttp10() {
57
58 $request = new HTTP\Request('GET', '/file1');
59 $request->setHttpVersion('1.0');
60 $response = $this->request($request);
61
62 $this->assertEquals(200, $response->getStatus());
63
64 // Removing Last-Modified because it keeps changing.
65 $response->removeHeader('Last-Modified');
66
67 $this->assertEquals(
68 [
69 'X-Sabre-Version' => [Version::VERSION],
70 'Content-Type' => ['application/octet-stream'],
71 'Content-Length' => [3],
72 'ETag' => ['"' . md5('foo') . '"'],
73 ],
74 $response->getHeaders()
75 );
76
77 $this->assertEquals('1.0', $response->getHttpVersion());
78
79 $this->assertEquals('foo', $response->getBodyAsString());
80
81 }
82
83 function testGet404() {
84
85 $request = new HTTP\Request('GET', '/notfound');
86 $response = $this->request($request);
87
88 $this->assertEquals(404, $response->getStatus());
89
90 }
91
92 function testGet404_aswell() {
93
94 $request = new HTTP\Request('GET', '/file1/subfile');
95 $response = $this->request($request);
96
97 $this->assertEquals(404, $response->getStatus());
98
99 }
100
105
106 $request = new HTTP\Request('GET', '//file1');
107 $response = $this->request($request);
108
109 $this->assertEquals(200, $response->getStatus());
110
111 // Removing Last-Modified because it keeps changing.
112 $response->removeHeader('Last-Modified');
113
114 $this->assertEquals(
115 [
116 'X-Sabre-Version' => [Version::VERSION],
117 'Content-Type' => ['application/octet-stream'],
118 'Content-Length' => [3],
119 'ETag' => ['"' . md5('foo') . '"'],
120 ],
121 $response->getHeaders()
122 );
123
124 $this->assertEquals('foo', $response->getBodyAsString());
125
126 }
127
128 function testGetCollection() {
129
130 $request = new HTTP\Request('GET', '/dir');
131 $response = $this->request($request);
132
133 $this->assertEquals(501, $response->getStatus());
134
135 }
136
137 function testGetStreaming() {
138
139 $request = new HTTP\Request('GET', '/streaming');
140 $response = $this->request($request);
141
142 $this->assertEquals(200, $response->getStatus());
143
144 // Removing Last-Modified because it keeps changing.
145 $response->removeHeader('Last-Modified');
146
147 $this->assertEquals(
148 [
149 'X-Sabre-Version' => [Version::VERSION],
150 'Content-Type' => ['application/octet-stream'],
151 ],
152 $response->getHeaders()
153 );
154
155 $this->assertEquals('stream', $response->getBodyAsString());
156
157 }
158}
foreach($paths as $path) $request
Definition: asyncclient.php:32
An exception for terminatinating execution or to throw for unit testing.
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.
Collection class.
Definition: Collection.php:15
Tests related to the GET request.
Definition: HttpGetTest.php:15
setUpTree()
Sets up the DAV tree.
Definition: HttpGetTest.php:22
testGetDoubleSlash()
We automatically normalize double slashes.
const VERSION
Full version number.
Definition: Version.php:17
$response