Merge pull request #5 from kakaska/empty-btcpay-server-url

Throw BitpayException when BTCPAY server url is empty
This commit is contained in:
Nicolas Dorier 2019-02-17 13:16:14 +09:00 committed by GitHub
commit c25d3d3c99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -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);

View File

@ -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
*/