Skip to content
Permalink
Browse files

Adding more tests for the response class.

  • Loading branch information...
burzum committed Oct 17, 2016
1 parent 1c640b6 commit 605f3505c5f1afdd41951b515720583aa77a4b94
Showing with 50 additions and 2 deletions.
  1. +50 −2 tests/TestCase/Network/ResponseTest.php
@@ -2162,7 +2162,7 @@ public function testGetReasonPhrase()
}
/**
* Test with protocol.
* Test with body.
*
* @return void
*/
@@ -2201,6 +2201,30 @@ public function testGetBody()
$this->assertInstanceOf('Psr\Http\Message\StreamInterface', $stream);
}
/**
* Test with header.
*
* @return void
*/
public function testWithHeader()
{
$response = new Response();
$result = $response->getHeaders();
$this->assertEquals([], $result);
$response2 = $response->withHeader('Accept', 'application/json');
$result = $response2->getHeaders();
$expected = [
'Accept' => [
0 => 'application/json'
]
];
$this->assertEquals($expected, $result);
$result = $response->getHeaders();
$this->assertEquals([], $result);
}
/**
* Test get headers.
*
@@ -2228,6 +2252,29 @@ public function testGetHeaders()
$this->assertEquals($expected, $headers);
}
/**
* Test without header.
*
* @return void
*/
public function testWithoutHeader()
{
$response = new Response();
$response = $response->withAddedHeader('Location', 'localhost');
$response = $response->withAddedHeader('Accept', 'application/json');
$response2 = $response->withoutHeader('Location');
$headers = $response2->getHeaders();
$expected = [
'Accept' => [
0 => 'application/json'
]
];
$this->assertEquals($expected, $headers);
}
/**
* Test get header.
*
@@ -2252,7 +2299,7 @@ public function testGetHeader()
}
/**
* Test get header.
* Test get header line.
*
* @return void
*/
@@ -2291,4 +2338,5 @@ public function testHasHeader()
$this->assertFalse($response->hasHeader('Accept'));
$this->assertFalse($response->hasHeader('accept'));
}
}

0 comments on commit 605f350

Please sign in to comment.
You can’t perform that action at this time.