Skip to content

Commit

Permalink
SP-126 Add a few basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbrodie committed Aug 13, 2024
1 parent 8a418e4 commit e0349cb
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/BitPaySDK/Util/RESTcli/RESTcli.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@ class RESTcli
* @var GuzzleHttpClient
*/
protected GuzzleHttpClient $client;

/**
* @var string
*/
protected string $baseUrl;

/**
* @var PrivateKey
*/
protected PrivateKey $ecKey;

/**
* @var string
*/
Expand Down
45 changes: 45 additions & 0 deletions test/unit/BitPaySDK/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,24 @@ public function testWithData()
self::assertInstanceOf(Client::class, $result);
}

/**
* @throws BitPayApiException
*/
public function testWithDataAndXBitPayPlatformInfoHeader()
{
$tokens = $this->createMock(Tokens::class);
$result = $this->getTestedClassInstance()::createWithData(
Env::TEST,
__DIR__ . '/bitpay_private_test.key',
$tokens,
'YourMasterPassword',
null,
'MyPlatform_v1.0.0'
);

self::assertInstanceOf(Client::class, $result);
}

public function testWithDataException()
{
$instance = $this->getTestedClassInstance();
Expand All @@ -135,6 +153,20 @@ public function testWithFileJsonConfig(): Client
return $result;
}

/**
* @throws BitPayApiException
*/
public function testWithFileJsonConfigAndXBitPayPlatformInfoHeader(): Client
{
$instance = $this->getTestedClassInstance();
$result = $instance::createWithFile(
__DIR__ . '/BitPay.config-unit.json',
'MyPlatform_v1.0.0'
);
self::assertInstanceOf(Client::class, $result);
return $result;
}

/**
* @throws BitPayGenericException
*/
Expand All @@ -145,6 +177,19 @@ public function testWithFileYmlConfig()
self::assertInstanceOf(Client::class, $result);
}

/**
* @throws BitPayGenericException
*/
public function testWithFileYmlConfigAndXBitPayPlatformInfoHeader()
{
$instance = $this->getTestedClassInstance();
$result = $instance::createWithFile(
__DIR__ . '/BitPay.config-unit.yml',
'MyPlatform_v1.0.0'
);
self::assertInstanceOf(Client::class, $result);
}

public function testWithFileException()
{
$instance = $this->getTestedClassInstance();
Expand Down

0 comments on commit e0349cb

Please sign in to comment.