Ejemplo n.º 1
0
 public function testIntercept()
 {
     $request = $this->prophesizeServerRequest()->reveal();
     $response = $this->prophesizeResponse()->reveal();
     $response2 = $this->prophesizeResponse()->reveal();
     $stack = new MiddlewareStack();
     $interceptor = function (ServerRequestInterface $req, ResponseInterface $res, callable $next) use($response2) {
         return $response2;
     };
     $failMiddleware = function () {
         $this->fail('this middleware should not be runned');
     };
     $stack->append($interceptor);
     $stack->append($failMiddleware);
     $returnValue = call_user_func($stack, $request, $response, $failMiddleware);
     $this->assertSame($response2, $returnValue);
 }
Ejemplo n.º 2
0
 /**
  * prepend $middleware before this one, return the new $middlewareStack
  *
  * @param $middleware
  * @return MiddlewareStack
  */
 public function prepend($middleware)
 {
     $stack = new MiddlewareStack();
     return $stack->prepend($this)->prepend($middleware);
 }