Skip to content

Commit e912bdf

Browse files
committed
Updated tests
1 parent 9db1f83 commit e912bdf

File tree

6 files changed

+58
-163
lines changed

6 files changed

+58
-163
lines changed

lib/internal/Magento/Framework/HTTP/Test/Unit/Client/CurlTest.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,57 @@ public function testInvalidProtocol()
2626
$client = new Curl();
2727
$client->get('telnet://127.0.0.1/test');
2828
}
29+
30+
/**
31+
* Check the HTTP client ability to parse headers case-insensitive.
32+
*/
33+
public function testParseHeaders()
34+
{
35+
// Prepare protected parseHeaders method
36+
$curl = new Curl();
37+
$parseHeaders = new \ReflectionMethod(
38+
$curl,
39+
'parseHeaders'
40+
);
41+
$parseHeaders->setAccessible(true);
42+
43+
// Parse headers
44+
foreach ($this->headersDataProvider() as $header) {
45+
$parseHeaders->invoke($curl, null, $header);
46+
}
47+
48+
// Validate headers
49+
$headers = $curl->getHeaders();
50+
$this->assertIsArray($headers);
51+
$this->assertEquals([
52+
'Content-Type' => 'text/html; charset=utf-8',
53+
'Set-Cookie' => [
54+
'Normal=OK',
55+
'Uppercase=OK',
56+
'Lowercase=OK',
57+
]
58+
], $headers);
59+
60+
// Validate status
61+
$status = $curl->getStatus();
62+
$this->assertIsInt($status);
63+
$this->assertEquals(200, $status);
64+
65+
// Validate cookies
66+
$cookies = $curl->getCookies();
67+
$this->assertIsArray($cookies);
68+
$this->assertEquals([
69+
'Normal' => 'OK',
70+
'Uppercase' => 'OK',
71+
'Lowercase' => 'OK',
72+
], $cookies);
73+
}
74+
75+
/**
76+
* @return array
77+
*/
78+
public function headersDataProvider()
79+
{
80+
return array_filter(explode(PHP_EOL, file_get_contents(__DIR__ . '/_files/curl_headers.txt')));
81+
}
2982
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Status: 200 OK
2+
Content-Type: text/html; charset=utf-8
3+
Set-Cookie: Normal=OK
4+
SET-COOKIE: Uppercase=OK
5+
set-cookie: Lowercase=OK

lib/internal/Magento/Framework/HTTP/Test/Unit/ClientMock/CurlMockTest.php

Lines changed: 0 additions & 86 deletions
This file was deleted.

lib/internal/Magento/Framework/HTTP/Test/Unit/ClientMock/Mock/CurlMock.php

Lines changed: 0 additions & 41 deletions
This file was deleted.

lib/internal/Magento/Framework/HTTP/Test/Unit/ClientMock/_files/curl_exec_mock.php

Lines changed: 0 additions & 22 deletions
This file was deleted.

lib/internal/Magento/Framework/HTTP/Test/Unit/ClientMock/_files/curl_response_cookies.txt

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)