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

Public Member Functions

 testConstructFromServerArray ()
 
 testConstructPHPAuth ()
 
 testConstructPHPAuthDigest ()
 
 testConstructRedirectAuth ()
 
 testSend ()
 @runInSeparateProcess More...
 
 testSendLimitedByContentLengthString ()
 @runInSeparateProcess @depends testSend More...
 
 testSendLimitedByContentLengthStream ()
 @runInSeparateProcess @depends testSend More...
 

Detailed Description

Definition at line 5 of file SapiTest.php.

Member Function Documentation

◆ testConstructFromServerArray()

Sabre\HTTP\SapiTest::testConstructFromServerArray ( )

Definition at line 7 of file SapiTest.php.

7 {
8
10 'REQUEST_URI' => '/foo',
11 'REQUEST_METHOD' => 'GET',
12 'HTTP_USER_AGENT' => 'Evert',
13 'CONTENT_TYPE' => 'text/xml',
14 'CONTENT_LENGTH' => '400',
15 'SERVER_PROTOCOL' => 'HTTP/1.0',
16 ]);
17
18 $this->assertEquals('GET', $request->getMethod());
19 $this->assertEquals('/foo', $request->getUrl());
20 $this->assertEquals([
21 'User-Agent' => ['Evert'],
22 'Content-Type' => ['text/xml'],
23 'Content-Length' => ['400'],
24 ], $request->getHeaders());
25
26 $this->assertEquals('1.0', $request->getHttpVersion());
27
28 $this->assertEquals('400', $request->getRawServerValue('CONTENT_LENGTH'));
29 $this->assertNull($request->getRawServerValue('FOO'));
30
31 }
foreach($paths as $path) $request
Definition: asyncclient.php:32
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107

References $request, and Sabre\HTTP\Sapi\createFromServerArray().

+ Here is the call graph for this function:

◆ testConstructPHPAuth()

Sabre\HTTP\SapiTest::testConstructPHPAuth ( )

Definition at line 33 of file SapiTest.php.

33 {
34
36 'REQUEST_URI' => '/foo',
37 'REQUEST_METHOD' => 'GET',
38 'PHP_AUTH_USER' => 'user',
39 'PHP_AUTH_PW' => 'pass',
40 ]);
41
42 $this->assertEquals('GET', $request->getMethod());
43 $this->assertEquals('/foo', $request->getUrl());
44 $this->assertEquals([
45 'Authorization' => ['Basic ' . base64_encode('user:pass')],
46 ], $request->getHeaders());
47
48 }

References $request, and Sabre\HTTP\Sapi\createFromServerArray().

+ Here is the call graph for this function:

◆ testConstructPHPAuthDigest()

Sabre\HTTP\SapiTest::testConstructPHPAuthDigest ( )

Definition at line 50 of file SapiTest.php.

50 {
51
53 'REQUEST_URI' => '/foo',
54 'REQUEST_METHOD' => 'GET',
55 'PHP_AUTH_DIGEST' => 'blabla',
56 ]);
57
58 $this->assertEquals('GET', $request->getMethod());
59 $this->assertEquals('/foo', $request->getUrl());
60 $this->assertEquals([
61 'Authorization' => ['Digest blabla'],
62 ], $request->getHeaders());
63
64 }

References $request, and Sabre\HTTP\Sapi\createFromServerArray().

+ Here is the call graph for this function:

◆ testConstructRedirectAuth()

Sabre\HTTP\SapiTest::testConstructRedirectAuth ( )

Definition at line 66 of file SapiTest.php.

66 {
67
69 'REQUEST_URI' => '/foo',
70 'REQUEST_METHOD' => 'GET',
71 'REDIRECT_HTTP_AUTHORIZATION' => 'Basic bla',
72 ]);
73
74 $this->assertEquals('GET', $request->getMethod());
75 $this->assertEquals('/foo', $request->getUrl());
76 $this->assertEquals([
77 'Authorization' => ['Basic bla'],
78 ], $request->getHeaders());
79
80 }

References $request, and Sabre\HTTP\Sapi\createFromServerArray().

+ Here is the call graph for this function:

◆ testSend()

Sabre\HTTP\SapiTest::testSend ( )

@runInSeparateProcess

Unfortunately we have no way of testing if the HTTP response code got changed.

Definition at line 88 of file SapiTest.php.

88 {
89
90 if (!function_exists('xdebug_get_headers')) {
91 $this->markTestSkipped('XDebug needs to be installed for this test to run');
92 }
93
94 $response = new Response(204, ['Content-Type' => 'text/xml;charset=UTF-8']);
95
96 // Second Content-Type header. Normally this doesn't make sense.
97 $response->addHeader('Content-Type', 'application/xml');
98 $response->setBody('foo');
99
100 ob_start();
101
103 $headers = xdebug_get_headers();
104
105 $result = ob_get_clean();
106 header_remove();
107
108 $this->assertEquals(
109 [
110 "Content-Type: text/xml;charset=UTF-8",
111 "Content-Type: application/xml",
112 ],
113 $headers
114 );
115
116 $this->assertEquals('foo', $result);
117
118 }
$result
static sendResponse(ResponseInterface $response)
Sends the HTTP response back to a HTTP client.
Definition: Sapi.php:56
$response

References $response, $result, and Sabre\HTTP\Sapi\sendResponse().

+ Here is the call graph for this function:

◆ testSendLimitedByContentLengthStream()

Sabre\HTTP\SapiTest::testSendLimitedByContentLengthStream ( )

@runInSeparateProcess @depends testSend

Definition at line 146 of file SapiTest.php.

146 {
147
148 $response = new Response(200, ['Content-Length' => 19]);
149
150 $body = fopen('php://memory', 'w');
151 fwrite($body, 'Ignore this. Send this sentence. Ignore this too.');
152 rewind($body);
153 fread($body, 13);
154 $response->setBody($body);
155
156 ob_start();
157
159
160 $result = ob_get_clean();
161 header_remove();
162
163 $this->assertEquals('Send this sentence.', $result);
164
165 }

References $response, $result, and Sabre\HTTP\Sapi\sendResponse().

+ Here is the call graph for this function:

◆ testSendLimitedByContentLengthString()

Sabre\HTTP\SapiTest::testSendLimitedByContentLengthString ( )

@runInSeparateProcess @depends testSend

Definition at line 124 of file SapiTest.php.

124 {
125
126 $response = new Response(200);
127
128 $response->addHeader('Content-Length', 19);
129 $response->setBody('Send this sentence. Ignore this one.');
130
131 ob_start();
132
134
135 $result = ob_get_clean();
136 header_remove();
137
138 $this->assertEquals('Send this sentence.', $result);
139
140 }

References $response, $result, and Sabre\HTTP\Sapi\sendResponse().

+ Here is the call graph for this function:

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