public function it_should_able_handle_exception(ContainerInterface $container, ResponseInterface $response, StreamInterface $stream, ServerResponderInterface $serverResponder, ConfigurationInterface $config, StreamInterface $stream, LoggerInterface $logger, \Exception $e)
 {
     $container->offsetGet('Response')->willReturn($response);
     $container->offsetGet('ServerResponder')->willReturn($serverResponder);
     $container->offsetGet('Logger')->willReturn($logger);
     $container->offsetGet('Config')->willReturn($config);
     $response->getBody()->willReturn($stream);
     $response->withHeader('Content-Type', 'text/html')->willReturn($response);
     $response->withStatus('500')->willReturn($response);
     $this->handleException($e);
 }
 public function it_should_throw_exception_when_given_invalid_middleware_dispatcher(\swoole_http_request $swoole_req, \swoole_http_response $swoole_res, ServerRequestInterface $request, ResponseInterface $response, RelayBuilder $relayBuilder, ContainerInterface $container)
 {
     unset($GLOBALS['_COOKIE']);
     unset($GLOBALS['_GET']);
     unset($GLOBALS['_POST']);
     unset($GLOBALS['_FILES']);
     $container->offsetSet('SwooleResponder', $swoole_res)->shouldBeCalled();
     $container->offsetGet('Request')->willReturn($request);
     $container->offsetGet('Response')->willReturn($response);
     $container->offsetGet('RelayBuilder')->willReturn($relayBuilder);
     $container->offsetGet('Middlewares')->willReturn([]);
     $relayBuilder->newInstance([])->willReturn(null);
     $this->shouldThrow('\\RuntimeException')->duringHandleRequest($swoole_req, $swoole_res);
 }
 public function it_should_able_send_output_to_client(ContainerInterface $container, ResponseInterface $response, \swoole_http_response $swoole_res, ConfigurationInterface $config)
 {
     $response->getHeaders()->willReturn(['Content-Type' => ['text/html']]);
     $container->offsetGet('SwooleResponder')->willReturn($swoole_res);
     $swoole_res->header('Content-Type', 'text/html')->shouldBeCalled();
     $container->offsetGet('Config')->willReturn($config);
     $config->offsetExists('server.gzip')->willReturn(true);
     $config->offsetGet('server.gzip')->willReturn(3);
     $swoole_res->gzip(3)->shouldBeCalled();
     $swoole_res->status(200)->shouldBeCalled();
     $swoole_res->header('Server', 'vinnige-app-server')->shouldBeCalled();
     $response->getBody()->willReturn('hello world');
     $response->getStatusCode()->willReturn(200);
     $swoole_res->end('hello world')->shouldBeCalled();
     $this->send($response);
 }
 public function it_should_handle_class_when_route_is_match(ServerRequestInterface $request, UriInterface $uri, ResponseInterface $response, GroupCountBased $dispatcher, ContainerInterface $container)
 {
     $request->getMethod()->willReturn('GET');
     $request->getUri()->willReturn($uri);
     $uri->getPath()->willReturn('/');
     $dispatcher->dispatch('GET', '/')->willReturn([Dispatcher::FOUND, 'Controller', []]);
     $request->withAttribute('param', [])->willReturn($request);
     $container->offsetGet('Controller')->willReturn(new Controller());
     $this->__invoke($request, $response, function ($request, $response) {
         return $response;
     })->shouldReturn($response);
 }
 public function it_should_able_to_run(ContainerInterface $container, RouteCollector $collector, ServerInterface $server, EventDispatcherInterface $event)
 {
     /**
      * predictions
      */
     $container->offsetSet('Middlewares', [])->shouldBeCalled();
     $container->offsetSet('ServiceProviders', [])->shouldBeCalled();
     $container->offsetSet('Routes', [])->shouldBeCalled();
     $collector->addRoute('GET', '/', 'test')->shouldBeCalled();
     $server->run()->shouldBeCalled();
     /**
      * mocks
      */
     $container->offsetGet('Routes')->willReturn([['method' => 'GET', 'route' => '/', 'handler' => 'test']]);
     $container->offsetGet('Server')->willReturn($server);
     $container->offsetGet('RouteCollector')->willReturn($collector);
     $container->offsetGet('EventDispatcher')->willReturn($event);
     /**
      * test method
      */
     $this->run();
 }
Example #6
0
 /**
  * {@inheritdoc}
  */
 public function offsetGet($offset)
 {
     return $this->container->offsetGet($offset);
 }