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/HelpersTest.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests/Unit/HelpersTest.php') diff --git a/tests/Unit/HelpersTest.php b/tests/Unit/HelpersTest.php index 43c29c84..82030169 100644 --- a/tests/Unit/HelpersTest.php +++ b/tests/Unit/HelpersTest.php @@ -6,6 +6,7 @@ use Engelsystem\Application; use Engelsystem\Config\Config; use Engelsystem\Container\Container; use Engelsystem\Http\Request; +use Engelsystem\Http\Response; use Engelsystem\Renderer\Renderer; use Engelsystem\Routing\UrlGenerator; use PHPUnit\Framework\TestCase; @@ -126,6 +127,33 @@ class HelpersTest extends TestCase $this->assertEquals('requestValue', request('requestKey')); } + /** + * @covers \response + */ + public function testResponse() + { + /** @var MockObject|Response $response */ + $response = $this->getMockBuilder(Response::class)->getMock(); + $this->getAppMock('psr7.response', $response); + + $response->expects($this->once()) + ->method('withContent') + ->with('Lorem Ipsum?') + ->willReturn($response); + + $response->expects($this->once()) + ->method('withStatus') + ->with(501) + ->willReturn($response); + + $response->expects($this->exactly(2)) + ->method('withAddedHeader') + ->withConsecutive(['lor', 'em'], ['foo', 'bar']) + ->willReturn($response); + + $this->assertEquals($response, response('Lorem Ipsum?', 501, ['lor' => 'em', 'foo' => 'bar',])); + } + /** * @covers \session */ -- cgit v1.2.3-54-g00ecf