summaryrefslogtreecommitdiffstats
path: root/tests/ControllerTest.php
diff options
context:
space:
mode:
authorminstel <minstel@yandex.ru>2016-10-17 23:18:54 +0300
committerminstel <minstel@yandex.ru>2016-10-17 23:18:54 +0300
commitb51040901730a22c990c0f3a52baf8dcbefa0554 (patch)
tree4fe5c7a1687e3486a872e2a385b5d3581bfa9d42 /tests/ControllerTest.php
parent29d47e1885e4f51e8cdf6b1ce89ecbeb3301166a (diff)
downloadcontroller-b51040901730a22c990c0f3a52baf8dcbefa0554.zip
controller-b51040901730a22c990c0f3a52baf8dcbefa0554.tar.gz
controller-b51040901730a22c990c0f3a52baf8dcbefa0554.tar.bz2
Controller class
Diffstat (limited to 'tests/ControllerTest.php')
-rw-r--r--tests/ControllerTest.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/ControllerTest.php b/tests/ControllerTest.php
new file mode 100644
index 0000000..9a4caef
--- /dev/null
+++ b/tests/ControllerTest.php
@@ -0,0 +1,26 @@
+<?php
+
+use Jasny\Controller;
+use Psr\Http\Message\ServerRequestInterface;
+use Psr\Http\Message\ResponseInterface;
+
+class ControllerTest extends PHPUnit_Framework_TestCase
+{
+ /**
+ * Test running controller
+ */
+ public function testInvoke()
+ {
+ $controller = $this->getMockBuilder(Controller::class)->disableOriginalConstructor()->getMockForAbstractClass();
+ $request = $this->createMock(ServerRequestInterface::class);
+ $response = $this->createMock(ResponseInterface::class);
+
+ $controller->expects($this->once())->method('run')->will($this->returnValue($response));
+
+ $result = $controller($request, $response);
+
+ $this->assertEquals($response, $result, "Invoking controller should return 'ResponseInterface' instance");
+ $this->assertEquals($response, $controller->getResponse(), "Can not get 'ResponseInterface' instance from controller");
+ $this->assertEquals($request, $controller->getRequest(), "Can not get 'ServerRequestInterface' instance from controller");
+ }
+}