diff options
author | Arnold Daniels <arnold@jasny.net> | 2016-10-20 22:53:02 +0200 |
---|---|---|
committer | Arnold Daniels <arnold@jasny.net> | 2016-10-20 22:53:02 +0200 |
commit | 66684e53daf18baf459ebdf3dd0616e6bc3bd1f9 (patch) | |
tree | 5ab4a350db80670cd13730f8312173ba390db4cd | |
parent | ef2167851c5e1a3a90ea9c053a352d421c8497a0 (diff) | |
download | router-66684e53daf18baf459ebdf3dd0616e6bc3bd1f9.zip router-66684e53daf18baf459ebdf3dd0616e6bc3bd1f9.tar.gz router-66684e53daf18baf459ebdf3dd0616e6bc3bd1f9.tar.bz2 |
Test Runner\Callback RuntimeException
-rw-r--r-- | tests/Router/Runner/CallbackTest.php | 36 |
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); + } } |