public function testClosuresCanBeInvoked() { $command = new CompleteTaskCommand(); $closureWasExecuted = false; $handler = function () use(&$closureWasExecuted) { $closureWasExecuted = true; }; $this->methodNameInflector->shouldReceive('inflect')->andReturn('__invoke'); $this->handlerLocator->shouldReceive('getHandlerForCommand')->andReturn($handler); $this->commandNameExtractor->shouldReceive('extract')->with($command); $this->middleware->execute($command, $this->mockNext()); $this->assertTrue($closureWasExecuted); }