How to test license validation via REST API

Please consider the following PHP code


static public function IsLicenseValid($domain)
{
    if (empty($domain)) {
        throw new Exception;
    }

    $licenseResponse = Curl::Post(['hostname' => $domain]);

        $Xml     = new XML();
        $xmlTree = $Xml->XMLToTree($licenseResponse);

        if ($xmlTree['is_valid'] == 'true') {
            return true;
        }
    }

    return false;
}

I am writing test case using PHPUnit to check the above method. I am able to cover all cases except one case in which a domain license should return true in is_valid xml node.

The REST API is so secured that it does not accept request from IPs that are not listed in their whitelist. And if someone is making a request from a non-whitelisted IP the API returns a false value for is_valid (and this is how I am covering the case for false)

I know this can be done using a mock object but I am not really sure how to write a mock object that can cover the case where a domain name is valid. Can someone please help?

Thanks in advance