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