public function testDispatcherErrorCallsListenerIndex() { $dispatcherExceptionListener = $this->prophesize(DispatcherExceptionListener::class); $response = $this->prophesize(Response::class); $request = (new Request())->withUri(new Uri('/pnf'))->withMethod('GET'); $container = App::buildContainer(Loader::load()); $container->set(DispatcherExceptionListener::class, $dispatcherExceptionListener->reveal()); $app = new App(null, $container); $app->run($request, $response->reveal()); $dispatcherExceptionListener->onError(Argument::any())->shouldHaveBeenCalled(); }
public function testCorrectInjectionWithExternalContainer() { $builder = new ContainerBuilder(); $builder->addDefinitions(Loader::load()); $builder->useAnnotations(true); $app = new App($this->router, $builder->build()); $request = (new Request())->withUri(new Uri('/load'))->withMethod('GET'); $response = new Response(); $response = $app->run($request, $response); $this->assertEquals(200, $response->getStatusCode()); $this->assertEquals('eureka', $response->getBody()->__toString()); }
/** * Application initialization. * * @param mixed $router Routing system. * @param ContainerInterface $container Dependency Injection container. */ public function __construct($router = null, ContainerInterface $container = null) { $this->container = $container ?: $this->buildContainer(Loader::load()); $container =& $this->container; $this->response = new Response(); $this->request = ServerRequestFactory::fromGlobals(); if ($router == null && $container->has('router') == false) { throw new Exception('Define router config'); } if ($container->has('router') == false) { $container->set('router', $router); } $container->set('event_manager', DI\object('Zend\\EventManager\\EventManager')); $container->set('dispatcher', DI\object('GianArb\\Penny\\Dispatcher')->constructor($container->get('router'))); $container->set('di', $container); }
public function testLoadsByCustomPath() { $config = Loader::load('./config/custom/{{*}}{{,*.local}}.php'); $this->assertTrue($config['nine']); }