Skip to content

Commit

Permalink
Merge pull request #2 from geekwright/testnoresp
Browse files Browse the repository at this point in the history
Improve coverage
  • Loading branch information
geekwright authored Jan 27, 2018
2 parents d146eb4 + 6bea205 commit ab6c331
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/unit/Panel/ClosureToMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Xoops\Test\Frame\Panel;

use Xoops\Frame\Panel\ClosureToMiddleware;
use Xoops\Frame\Rack;

class ClosureToMiddlewareTest extends \PHPUnit\Framework\TestCase
{
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}

0 comments on commit ab6c331

Please sign in to comment.