summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnold Daniels <arnold@jasny.net>2016-10-20 22:53:02 +0200
committerArnold Daniels <arnold@jasny.net>2016-10-20 22:53:02 +0200
commit66684e53daf18baf459ebdf3dd0616e6bc3bd1f9 (patch)
tree5ab4a350db80670cd13730f8312173ba390db4cd
parentef2167851c5e1a3a90ea9c053a352d421c8497a0 (diff)
downloadrouter-66684e53daf18baf459ebdf3dd0616e6bc3bd1f9.zip
router-66684e53daf18baf459ebdf3dd0616e6bc3bd1f9.tar.gz
router-66684e53daf18baf459ebdf3dd0616e6bc3bd1f9.tar.bz2
Test Runner\Callback RuntimeException
-rw-r--r--tests/Router/Runner/CallbackTest.php36
1 files changed, 35 insertions, 1 deletions
diff --git a/tests/Router/Runner/CallbackTest.php b/tests/Router/Runner/CallbackTest.php
index 365ba22..caeb5cb 100644
--- a/tests/Router/Runner/CallbackTest.php
+++ b/tests/Router/Runner/CallbackTest.php
@@ -22,7 +22,6 @@ class CallbackTest extends PHPUnit_Framework_TestCase
$request = $this->createMock(ServerRequestInterface::class);
$response = $this->createMock(ResponseInterface::class);
$finalResponse = $this->createMock(ResponseInterface::class);
- $finalResponse->foo = 10;
$route = $this->createMock(Route::class);
$route->fn = $this->createCallbackMock($this->once(), [$request, $response], $finalResponse);
@@ -34,4 +33,39 @@ class CallbackTest extends PHPUnit_Framework_TestCase
$this->assertSame($finalResponse, $result);
}
+
+ /**
+ * @expectedException RuntimeException
+ * @expectedExceptionMessage 'fn' property of route shoud be a callable
+ */
+ public function testNoCallback()
+ {
+ $request = $this->createMock(ServerRequestInterface::class);
+ $response = $this->createMock(ResponseInterface::class);
+
+ $route = $this->createMock(Route::class);
+
+ $request->expects($this->once())->method('getAttribute')->with('route')->willReturn($route);
+
+ $runner = new Callback($route);
+ $runner($request, $response);
+ }
+
+ /**
+ * @expectedException RuntimeException
+ * @expectedExceptionMessage 'fn' property of route shoud be a callable
+ */
+ public function testInvalidCallback()
+ {
+ $request = $this->createMock(ServerRequestInterface::class);
+ $response = $this->createMock(ResponseInterface::class);
+
+ $route = $this->createMock(Route::class);
+ $route->fn = 'foo bar zoo';
+
+ $request->expects($this->once())->method('getAttribute')->with('route')->willReturn($route);
+
+ $runner = new Callback($route);
+ $runner($request, $response);
+ }
}