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_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(); }
/** * {@inheritdoc} */ public function offsetSet($offset, $value) { $this->container->offsetSet($offset, $value); }