public function testApiHandleError_ClosesConnectionWithCode500_WhenConnectionControllerDoesExistButThrowsException()
{
$ex = new Exception();
$conn = $this->getMock(NetworkConnection::class, [], [], '', false);
$conn->controller = $this->createComponent();
$conn->controller->expects($this->once())->method('handleError')->will($this->throwException(new Exception()));
$server = $this->createServer();
$router = $this->createRouter($server, ['close']);
$router->expects($this->once())->method('close')->with($conn, 500);
$router->handleError($conn, $ex);
}