From 6bea205809c28e3905d7132d76d43f451bb1a8ee Mon Sep 17 00:00:00 2001 From: geekwright Date: Fri, 26 Jan 2018 21:07:53 -0600 Subject: [PATCH] Improve coverage --- tests/unit/Panel/ClosureToMiddlewareTest.php | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/unit/Panel/ClosureToMiddlewareTest.php b/tests/unit/Panel/ClosureToMiddlewareTest.php index d40111d..77fd27a 100644 --- a/tests/unit/Panel/ClosureToMiddlewareTest.php +++ b/tests/unit/Panel/ClosureToMiddlewareTest.php @@ -3,6 +3,7 @@ namespace Xoops\Test\Frame\Panel; use Xoops\Frame\Panel\ClosureToMiddleware; +use Xoops\Frame\Rack; class ClosureToMiddlewareTest extends \PHPUnit\Framework\TestCase { @@ -11,6 +12,8 @@ class ClosureToMiddlewareTest extends \PHPUnit\Framework\TestCase protected $response; + protected $weWereHere; + /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. @@ -39,6 +42,12 @@ protected function mockResponse(\Psr\Http\Message\ServerRequestInterface $reques return $this->response; } + protected function setWeWereHere(...$test) + { + $this->weWereHere = true; + return; + } + /** * generate an empty ResponseInterface object * @return \Psr\Http\Message\ResponseInterface @@ -79,4 +88,17 @@ public function testProcess() $actual = $this->object->process($request, $handler); $this->assertSame($this->response, $actual); } + + public function testProcess_noResponse() + { + $this->weWereHere = false; + $middleware1 = new ClosureToMiddleware(\Closure::fromCallable([$this, 'setWeWereHere'])); + $middleware2 = new ClosureToMiddleware(\Closure::fromCallable([$this, 'mockResponse'])); + $rack = new Rack(); + $request = $this->generateMockServerRequestInterface(); + $actual = $rack->add($middleware1)->add($middleware2)->run($request); + + $this->assertSame($this->response, $actual); + $this->assertTrue($this->weWereHere); + } }