Fix IHTTPResult::getHeader/s()
- Split functionality "getHeader()" and "getHeaders()" analog to IMessageInterface::getHeader/s() - Fix functionality at various places - Adapt CurlResultTest
This commit is contained in:
@@ -53,6 +53,7 @@ class CurlResultTest extends TestCase
|
||||
public function testNormal()
|
||||
{
|
||||
$header = file_get_contents(__DIR__ . '/../../datasets/curl/about.head');
|
||||
$headerArray = include(__DIR__ . '/../../datasets/curl/about.head.php');
|
||||
$body = file_get_contents(__DIR__ . '/../../datasets/curl/about.body');
|
||||
|
||||
|
||||
@@ -65,7 +66,7 @@ class CurlResultTest extends TestCase
|
||||
$this->assertTrue($curlResult->isSuccess());
|
||||
$this->assertFalse($curlResult->isTimeout());
|
||||
$this->assertFalse($curlResult->isRedirectUrl());
|
||||
$this->assertSame($header, $curlResult->getHeader());
|
||||
$this->assertSame($headerArray, $curlResult->getHeaders());
|
||||
$this->assertSame($body, $curlResult->getBody());
|
||||
$this->assertSame('text/html; charset=utf-8', $curlResult->getContentType());
|
||||
$this->assertSame('https://test.local', $curlResult->getUrl());
|
||||
@@ -80,6 +81,7 @@ class CurlResultTest extends TestCase
|
||||
public function testRedirect()
|
||||
{
|
||||
$header = file_get_contents(__DIR__ . '/../../datasets/curl/about.head');
|
||||
$headerArray = include(__DIR__ . '/../../datasets/curl/about.head.php');
|
||||
$body = file_get_contents(__DIR__ . '/../../datasets/curl/about.body');
|
||||
|
||||
|
||||
@@ -93,7 +95,7 @@ class CurlResultTest extends TestCase
|
||||
$this->assertTrue($curlResult->isSuccess());
|
||||
$this->assertFalse($curlResult->isTimeout());
|
||||
$this->assertTrue($curlResult->isRedirectUrl());
|
||||
$this->assertSame($header, $curlResult->getHeader());
|
||||
$this->assertSame($headerArray, $curlResult->getHeaders());
|
||||
$this->assertSame($body, $curlResult->getBody());
|
||||
$this->assertSame('text/html; charset=utf-8', $curlResult->getContentType());
|
||||
$this->assertSame('https://test.local/test/it', $curlResult->getUrl());
|
||||
@@ -106,6 +108,7 @@ class CurlResultTest extends TestCase
|
||||
public function testTimeout()
|
||||
{
|
||||
$header = file_get_contents(__DIR__ . '/../../datasets/curl/about.head');
|
||||
$headerArray = include(__DIR__ . '/../../datasets/curl/about.head.php');
|
||||
$body = file_get_contents(__DIR__ . '/../../datasets/curl/about.body');
|
||||
|
||||
|
||||
@@ -119,7 +122,7 @@ class CurlResultTest extends TestCase
|
||||
$this->assertFalse($curlResult->isSuccess());
|
||||
$this->assertTrue($curlResult->isTimeout());
|
||||
$this->assertFalse($curlResult->isRedirectUrl());
|
||||
$this->assertSame($header, $curlResult->getHeader());
|
||||
$this->assertSame($headerArray, $curlResult->getHeaders());
|
||||
$this->assertSame($body, $curlResult->getBody());
|
||||
$this->assertSame('text/html; charset=utf-8', $curlResult->getContentType());
|
||||
$this->assertSame('https://test.local/test/it', $curlResult->getRedirectUrl());
|
||||
@@ -134,6 +137,7 @@ class CurlResultTest extends TestCase
|
||||
public function testRedirectHeader()
|
||||
{
|
||||
$header = file_get_contents(__DIR__ . '/../../datasets/curl/about.redirect');
|
||||
$headerArray = include(__DIR__ . '/../../datasets/curl/about.redirect.php');
|
||||
$body = file_get_contents(__DIR__ . '/../../datasets/curl/about.body');
|
||||
|
||||
|
||||
@@ -146,7 +150,7 @@ class CurlResultTest extends TestCase
|
||||
$this->assertTrue($curlResult->isSuccess());
|
||||
$this->assertFalse($curlResult->isTimeout());
|
||||
$this->assertTrue($curlResult->isRedirectUrl());
|
||||
$this->assertSame($header, $curlResult->getHeader());
|
||||
$this->assertSame($headerArray, $curlResult->getHeaders());
|
||||
$this->assertSame($body, $curlResult->getBody());
|
||||
$this->assertSame('text/html; charset=utf-8', $curlResult->getContentType());
|
||||
$this->assertSame('https://test.local/test/it?key=value', $curlResult->getUrl());
|
||||
@@ -204,7 +208,7 @@ class CurlResultTest extends TestCase
|
||||
'url' => 'https://test.local'
|
||||
]);
|
||||
|
||||
$this->assertNotEmpty($curlResult->getHeader());
|
||||
$this->assertNotEmpty($curlResult->getHeaders());
|
||||
$this->assertEmpty($curlResult->getHeader('wrongHeader'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user