/** * Handle the event * * @param MethodEvent $event */ public function __invoke(MethodEvent $event) { $methodModel = $event->getMethodModel(); $annotations = $event->getAnnotationCollection(); $annotationProvider = new AnnotationProvider($annotations, $methodModel); $body = new Body(); $stack = new HandlerStack(new HandlerContext($annotationProvider, $body, new ArrayPrinter())); $stack->push(new UrlHandler()); $stack->push(new HeaderHandler()); $stack->push(new BodyHandler()); $stack->push(new ResponseHandler()); $stack->push(new ReturnHandler()); $stack->execute(); $methodModel->setBody($body); }
public function testExecution() { $context = Mockery::mock(HandlerContext::class); $handler = Mockery::mock(Handler::class); $handler->shouldReceive('__invoke')->times(1)->with($context)->andReturn(); $stack = new HandlerStack($context); $stack->push($handler); $stack->execute(); }