-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration tests to supported APIs(providers)
- Loading branch information
1 parent
7b1b057
commit ba23531
Showing
5 changed files
with
114 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Test\Integration; | ||
|
||
use GuzzleHttp\Client; | ||
use Jimmerioles\BitcoinCurrencyConverter\Provider\BitpayProvider; | ||
use Test\TestCase; | ||
|
||
class BitpayIntegrationTest extends TestCase | ||
{ | ||
private $client; | ||
|
||
protected function setUp() | ||
{ | ||
$this->client = new Client(); | ||
} | ||
|
||
public function test_api_returns_expected_json_structure() | ||
{ | ||
$response = $this->client->request( | ||
'GET', | ||
BitpayProvider::getApiEndpoint(), | ||
['headers' => ['Accept' => 'application/json']] | ||
); | ||
|
||
$body = $response->getBody(); | ||
$responseArray = json_decode($body, true); | ||
|
||
$this->assertEquals(200, $response->getStatusCode()); | ||
$this->assertNotEmpty($body); | ||
|
||
foreach ($responseArray as $currency) { | ||
$this->assertArrayHasKey('code', $currency); | ||
$this->assertArrayHasKey('rate', $currency); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Test\Integration; | ||
|
||
use GuzzleHttp\Client; | ||
use Jimmerioles\BitcoinCurrencyConverter\Provider\CoinbaseProvider; | ||
use Test\TestCase; | ||
|
||
class CoinbaseIntegrationTest extends TestCase | ||
{ | ||
private $client; | ||
|
||
protected function setUp() | ||
{ | ||
$this->client = new Client(); | ||
} | ||
|
||
public function test_api_returns_expected_json_structure() | ||
{ | ||
$response = $this->client->request( | ||
'GET', | ||
CoinbaseProvider::getApiEndpoint(), | ||
['headers' => ['Accept' => 'application/json']] | ||
); | ||
|
||
$body = $response->getBody(); | ||
$responseArray = json_decode($body, true); | ||
|
||
$this->assertEquals(200, $response->getStatusCode()); | ||
$this->assertNotEmpty($body); | ||
|
||
$this->assertArrayHasKey('data', $responseArray); | ||
$this->assertArrayHasKey('rates', $responseArray['data']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Test\Integration; | ||
|
||
use GuzzleHttp\Client; | ||
use Jimmerioles\BitcoinCurrencyConverter\Provider\CoindeskProvider; | ||
use Test\TestCase; | ||
|
||
class CoindeskIntegrationTest extends TestCase | ||
{ | ||
private $client; | ||
|
||
protected function setUp() | ||
{ | ||
$this->client = new Client(); | ||
} | ||
|
||
public function test_api_returns_expected_json_structure() | ||
{ | ||
$response = $this->client->request( | ||
'GET', | ||
CoindeskProvider::getApiEndpoint(), | ||
['headers' => ['Accept' => 'application/json']] | ||
); | ||
|
||
$body = $response->getBody(); | ||
$responseArray = json_decode($body, true); | ||
|
||
$this->assertEquals(200, $response->getStatusCode()); | ||
$this->assertNotEmpty($body); | ||
|
||
$this->assertArrayHasKey('bpi', $responseArray); | ||
|
||
foreach ($responseArray['bpi'] as $currency) { | ||
$this->assertArrayHasKey('code', $currency); | ||
$this->assertArrayHasKey('rate_float', $currency); | ||
} | ||
} | ||
} |