public function testApiHandleError_ClosesConnection_WhenConnectionIsRegisteredButIsNotEstablished()
{
$ex = new Exception();
$conn = $this->getMock(NetworkConnectionInterface::class, [], [], '', false);
$upgraded = $this->getMock(NetworkConnectionInterface::class, [], [], '', false);
$conn->expects($this->once())->method('close');
$conn->WebSocket = new StdClass();
$conn->WebSocket->established = false;
$aware = $this->createAware();
$component = $this->createComponent();
$component->expects($this->never())->method('handleError');
$server = $this->createServer($aware, $component);
$storage = $this->getProtectedProperty($server, 'connCollection');
$storage->attach($conn, $upgraded);
$server->handleError($conn, $ex);
}