summaryrefslogtreecommitdiffstats
path: root/tests/ControllerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ControllerTest.php')
-rw-r--r--tests/ControllerTest.php40
1 files changed, 39 insertions, 1 deletions
diff --git a/tests/ControllerTest.php b/tests/ControllerTest.php
index 3e3b39c..04323a1 100644
--- a/tests/ControllerTest.php
+++ b/tests/ControllerTest.php
@@ -20,12 +20,12 @@ class ControllerTest extends \PHPUnit_Framework_TestCase
public function testInvoke()
{
$test = $this;
- $controller = $this->getController();
$request = $this->createMock(ServerRequestInterface::class);
$response = $this->createMock(ResponseInterface::class);
$finalResponse = $this->createMock(ResponseInterface::class);
+ $controller = $this->getController();
$controller->expects($this->once())->method('run')
->willReturnCallback(\Closure::bind(function() use ($test, $request, $response, $finalResponse) {
$test->assertSame($request, $this->getRequest());
@@ -38,4 +38,42 @@ class ControllerTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($finalResponse, $result);
}
+
+ public function testSetResponse()
+ {
+ $response = $this->createMock(ResponseInterface::class);
+
+ $controller = $this->getController();
+ $controller->setResponse($response);
+
+ $this->assertSame($response, $controller->getResponse());
+ }
+
+ /**
+ * @expectedException LogicException
+ */
+ public function testGetRequestUninvoked()
+ {
+ $this->getController()->getRequest();
+ }
+
+ /**
+ * @expectedException LogicException
+ */
+ public function testGetResponseUninvoked()
+ {
+ $this->getController()->getResponse();
+ }
+
+
+ public function testUseSession()
+ {
+ $request = $this->createMock(ServerRequestInterface::class);
+ $response = $this->createMock(ResponseInterface::class);
+
+ $controller = $this->getController(['useSession']);
+ $controller->expects($this->once())->method('useSession');
+
+ $controller($request, $response);
+ }
}