Merge pull request #5 from kakaska/empty-btcpay-server-url
Throw BitpayException when BTCPAY server url is empty
This commit is contained in:
commit
c25d3d3c99
@ -659,9 +659,14 @@ class Client implements ClientInterface
|
||||
|
||||
/**
|
||||
* @return RequestInterface
|
||||
*
|
||||
* @throws BitpayException
|
||||
*/
|
||||
protected function createNewRequest()
|
||||
{
|
||||
if ($this->uri === null) {
|
||||
throw new BitpayException('You should provider the url of your BTCPAY server');
|
||||
}
|
||||
$request = new Request();
|
||||
$request->setUri($this->uri);
|
||||
$this->prepareRequestHeaders($request);
|
||||
|
||||
@ -22,6 +22,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||
public function setUp()
|
||||
{
|
||||
$this->client = new Client();
|
||||
$this->client->setUri('https://btcpay.server/');
|
||||
$this->client->setToken($this->getMockToken());
|
||||
$this->client->setPublicKey($this->getMockPublicKey());
|
||||
$this->client->setPrivateKey($this->getMockPrivateKey());
|
||||
@ -46,6 +47,16 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertNull($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Bitpay\Client\BitpayException
|
||||
* @expectedExceptionMessage You should provider the url of your BTCPAY server
|
||||
*/
|
||||
public function testBtcPayServerUrlNotProvided()
|
||||
{
|
||||
$client = new Client();
|
||||
$client->getTokens();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user