diff --git a/tests/Mocks/InvocationStrategyTest.php b/tests/Mocks/InvocationStrategyTest.php new file mode 100644 index 000000000..49b37db56 --- /dev/null +++ b/tests/Mocks/InvocationStrategyTest.php @@ -0,0 +1,39 @@ +routeFactory(); @@ -384,4 +384,28 @@ public function testInvokeWhenDisablingOutputBuffer() $output = ob_get_clean(); $this->assertEquals('foo', $output); } + + /** + * Ensure that `foundHandler` is called on actual callable + */ + public function testInvokeDeferredCallable() + { + $container = new Container(); + $container['CallableTest'] = new CallableTest; + $container['foundHandler'] = function () { + return new InvocationStrategyTest(); + }; + + $route = new Route(['GET'], '/', 'CallableTest:toCall'); + $route->setContainer($container); + + $uri = Uri::createFromString('https://example.com:80'); + $body = new Body(fopen('php://temp', 'r+')); + $request = new Request('GET', $uri, new Headers(), [], Environment::mock()->all(), $body); + + $result = $route->callMiddlewareStack($request, new Response); + + $this->assertInstanceOf('Slim\Http\Response', $result); + $this->assertEquals([$container['CallableTest'], 'toCall'], InvocationStrategyTest::$LastCalledFor); + } }