Skip to content
This repository has been archived by the owner on Sep 12, 2022. It is now read-only.

Commit

Permalink
Fix the unit tests to handle the new behaviour for curl tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Dakumo committed Feb 10, 2017
1 parent 943c3e1 commit c49ee00
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions tests/AwsInspector/Helper/CurlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ public function getCurlObject(array $output = [], array $header = [], $returnVar
{
if (empty($output)) {
$output = [
'HTTP/1.1 301 Moved Permanently',
'Location: http://www.google.com/',
'Content-Type: text/html; charset=UTF-8',
'', // Implicit test of an empty line in parseHeader
'<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">',
'<TITLE>301 Moved</TITLE></HEAD><BODY>',
'<H1>301 Moved</H1>',
'The document has moved',
'<A HREF="http://www.google.com/">here</A>.',
'</BODY></HTML>',
'HTTP/1.1 301 Moved Permanently',
'Location: http://www.google.com/',
'Content-Type: text/html; charset=UTF-8',
' ' // Implicit test of an empty line in parseHeader
'</BODY></HTML>'
];
}

Expand All @@ -41,15 +41,15 @@ public function parseHeaderThrowsExceptionIfColonIsMissing()
{
$this->setExpectedException('Exception', "Header without colon found: Line without colon");
$curl = $this->getCurlObject([
'HTTP/1.1 301 Moved Permanently',
'Location: http://www.google.com/',
'Line without colon',
'<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">',
'<TITLE>301 Moved</TITLE></HEAD><BODY>',
'<H1>301 Moved</H1>',
'The document has moved',
'<A HREF="http://www.google.com/">here</A>.',
'</BODY></HTML>',
'HTTP/1.1 301 Moved Permanently',
'Location: http://www.google.com/',
'Line without colon'
'</BODY></HTML>'
]);
}

Expand Down Expand Up @@ -101,8 +101,8 @@ public function getResponseHeadersReturnsExpectedHeaderArray()
$curl = $this->getCurlObject();
$this->assertSame(
[
'Content-Type' => 'text/html; charset=UTF-8',
'Location' => 'http://www.google.com/',
'Content-Type' => 'text/html; charset=UTF-8',
],
$curl->getResponseHeaders()
);
Expand All @@ -114,23 +114,24 @@ public function getResponseHeadersReturnsExpectedHeaderArray()
public function getResponseHeadersReturnsExpectedHeaderArrayWithNestedArray()
{
$curl = $this->getCurlObject([
'HTTP/1.1 301 Moved Permanently',
'Location: http://www.google.com/',
'X-StackFormation: Test',
'X-StackFormation: Test2',
'X-StackFormation: Test3',
'',
'<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">',
'<TITLE>301 Moved</TITLE></HEAD><BODY>',
'<H1>301 Moved</H1>',
'The document has moved',
'<A HREF="http://www.google.com/">here</A>.',
'</BODY></HTML>',
'HTTP/1.1 301 Moved Permanently',
'Location: http://www.google.com/',
'X-StackFormation: Test',
'X-StackFormation: Test2',
'X-StackFormation: Test3'
]);

$this->assertSame(
[
'X-StackFormation' => ['Test3', 'Test2', 'Test'],
'Location' => 'http://www.google.com/'
'Location' => 'http://www.google.com/',
'X-StackFormation' => ['Test', 'Test2', 'Test3']
],
$curl->getResponseHeaders()
);
Expand Down Expand Up @@ -180,14 +181,15 @@ public function getResponseBodyReturnsExpectedValue()
public function getResponseBodyReturnsAlsoTheRestOfInvalidHeaderData()
{
$curl = $this->getCurlObject([
'StackFormationHTTP/1.1 301 Moved Permanently',
'Location: http://www.google.com/',
'',
'<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">',
'<TITLE>301 Moved</TITLE></HEAD><BODY>',
'<H1>301 Moved</H1>',
'The document has moved',
'<A HREF="http://www.google.com/">here</A>.',
'</BODY></HTML>',
'StackFormationHTTP/1.1 301 Moved Permanently',
'Location: http://www.google.com/'
'</BODY></HTML>'
]);
$this->assertContains('StackFormation', $curl->getResponseBody());
}
Expand Down

0 comments on commit c49ee00

Please sign in to comment.