-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from lloc/add-di
Tests finished
- Loading branch information
Showing
12 changed files
with
121 additions
and
49 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,21 @@ | ||
*.log | ||
*.tgz | ||
*.zip | ||
.env | ||
.eslintcache | ||
.idea/ | ||
.npm | ||
.phpunit.result.cache | ||
build/ | ||
js/ | ||
composer.lock | ||
package-lock.json | ||
|
||
# Logs | ||
logs | ||
*.log | ||
node_modules/ | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Coverage directory | ||
package-lock.json | ||
reports/ | ||
|
||
# Compiled assets | ||
build/ | ||
|
||
# Dependency directories | ||
node_modules/ | ||
vendor/ | ||
wp-nowpayments-integration/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Output of `npm pack` | ||
*.tgz | ||
|
||
# Output of `wp-scripts plugin-zip` | ||
*.zip | ||
|
||
# dotenv environment variables file | ||
.env | ||
yarn-debug.log* | ||
yarn-error.log* |
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
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
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,38 @@ | ||
<?php | ||
|
||
namespace lloc\NowpaymentsTests\Services; | ||
|
||
use lloc\Nowpayments\Integration\ApiStatus; | ||
use lloc\Nowpayments\Rest\Api; | ||
use lloc\Nowpayments\Rest\Client; | ||
use lloc\Nowpayments\Rest\EndpointGetInterface; | ||
use lloc\Nowpayments\Rest\ResponseInterface; | ||
use lloc\Nowpayments\Services\ApiStatusService; | ||
use lloc\NowpaymentsTests\LlocTestCase; | ||
|
||
class TestApiStatusService extends LlocTestCase { | ||
|
||
public function test_get_data(): void { | ||
$service = \Mockery::mock( Api::class ); | ||
$service->shouldReceive( 'info' )->once()->andReturn( 'Sandbox' ); | ||
|
||
$client = \Mockery::mock( Client::class ); | ||
$client->shouldReceive( 'get_service' )->once()->andReturn( $service ); | ||
|
||
$response = \Mockery::mock( ResponseInterface::class ); | ||
$response->shouldReceive( 'get' )->once()->andReturn( array( 'status' => 'ok' ) ); | ||
|
||
$api_status = \Mockery::mock( ApiStatus::class ); | ||
$api_status->shouldReceive( 'get' )->once()->andReturn( $response ); | ||
$api_status->shouldReceive( 'get_client' )->once()->andReturn( $client ); | ||
|
||
$expected = array( | ||
'status' => 'ok', | ||
'info' => 'Sandbox', | ||
); | ||
|
||
$test = new ApiStatusService( $api_status ); | ||
|
||
$this->assertEquals( $expected, $test->get_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,41 @@ | ||
<?php | ||
|
||
namespace lloc\NowpaymentsTests\Services; | ||
|
||
use lloc\Nowpayments\Integration\AvailableCurrencies; | ||
use lloc\Nowpayments\Rest\ResponseInterface; | ||
use lloc\Nowpayments\Services\AvailableCurrenciesService; | ||
use lloc\NowpaymentsTests\LlocTestCase; | ||
use Brain\Monkey\Functions; | ||
|
||
class TestAvailableCurrenciesService extends LlocTestCase { | ||
|
||
private AvailableCurrenciesService $test; | ||
|
||
const RESULT = array( 'currencies' => array( 'BTC', 'ETH' ) ); | ||
|
||
protected function setUp(): void { | ||
parent::setUp(); | ||
|
||
$response = \Mockery::mock( ResponseInterface::class ); | ||
$response->shouldReceive( 'get' )->atLeast()->once()->andReturn( self::RESULT ); | ||
|
||
$available_currencies = \Mockery::mock( AvailableCurrencies::class ); | ||
$available_currencies->shouldReceive( 'get' )->atLeast()->once()->andReturn( $response ); | ||
|
||
Functions\expect( 'wp_cache_get' )->atLeast()->once()->andReturn( false ); | ||
Functions\expect( 'wp_cache_set' )->atLeast()->once(); | ||
|
||
$this->test = new AvailableCurrenciesService( $available_currencies ); | ||
} | ||
|
||
public function test_get_data(): void { | ||
$this->assertEquals( self::RESULT['currencies'], $this->test->get_data() ); | ||
} | ||
|
||
public function test_is_available(): void { | ||
$this->assertTrue( $this->test->is_available( 'BTC' ) ); | ||
$this->assertTrue( $this->test->is_available( 'ETH' ) ); | ||
$this->assertFalse( $this->test->is_available( 'LTC' ) ); | ||
} | ||
} |
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