public function serve(ConnectionInterface $conn, RequestInterface $request = null, array $parameters) { try { $application = $this->applications->get($parameters['application']); $conn->send((string) $application->execute($parameters['module'], $request)); $conn->close(); } catch (ApplicationNotFoundException $e) { $response = new Response(404, null, $e->getMessage()); $conn->send((string) $response); $conn->close(); } catch (\Exception $e) { $response = new Response(500, null, $e->getMessage()); $conn->send((string) $response); $conn->close(); } }
/** * @expectedException \RuntimeException * @expectedExceptionMessage You cannot have two main applications. */ public function testRegisterMainApplicationTwice() { $this->mainApplication->expects($this->once())->method('getName')->will($this->returnValue('foo')); $this->mainApplication->expects($this->once())->method('buildContainer'); $repository = new ApplicationRepository($this->dispatcher); $repository->register($this->mainApplication); $repository->register($this->mainApplication); }