From f3f05f6cc4bef3338dbfb6eb340da4fb1c5ba1e1 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Sat, 11 Aug 2018 15:05:55 +0200 Subject: Make Engelsystem\Http\Response PSR-7 compatible --- tests/Unit/Http/ResponseTest.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'tests/Unit/Http/ResponseTest.php') diff --git a/tests/Unit/Http/ResponseTest.php b/tests/Unit/Http/ResponseTest.php index 6bedf5c1..f6c24767 100644 --- a/tests/Unit/Http/ResponseTest.php +++ b/tests/Unit/Http/ResponseTest.php @@ -4,6 +4,7 @@ namespace Engelsystem\Test\Unit\Http; use Engelsystem\Http\Response; use PHPUnit\Framework\TestCase; +use Psr\Http\Message\ResponseInterface; use Symfony\Component\HttpFoundation\Response as SymfonyResponse; class ResponseTest extends TestCase @@ -15,5 +16,34 @@ class ResponseTest extends TestCase { $response = new Response(); $this->assertInstanceOf(SymfonyResponse::class, $response); + $this->assertInstanceOf(ResponseInterface::class, $response); + } + + /** + * @covers \Engelsystem\Http\Response::withStatus + * @covers \Engelsystem\Http\Response::getReasonPhrase + */ + public function testWithStatus() + { + $response = new Response(); + $newResponse = $response->withStatus(503); + $this->assertNotEquals($response, $newResponse); + $this->assertNotEquals('', $newResponse->getReasonPhrase()); + $this->assertEquals(503, $newResponse->getStatusCode()); + + $newResponse = $response->withStatus(503, 'Foo'); + $this->assertEquals('Foo', $newResponse->getReasonPhrase()); + } + + /** + * @covers \Engelsystem\Http\Response::withContent + */ + public function testWithContent() + { + $response = new Response(); + $newResponse = $response->withContent('Lorem Ipsum?'); + + $this->assertNotEquals($response, $newResponse); + $this->assertEquals('Lorem Ipsum?', $newResponse->getContent()); } } -- cgit v1.2.3-70-g09d2