Skip to content
Snippets Groups Projects
Commit 72374924 authored by Michael Teddy's avatar Michael Teddy
Browse files

fix/clean-up-tests

parent df339d76
No related branches found
No related tags found
1 merge request!17fix/clean-up-and-refactoring-for-wraping-in-laravel
Pipeline #4144 failed
......@@ -19,14 +19,14 @@ class AdaUsdQuoteService
public array $ratesArray = [];
public function __construct(protected CurrencyEnum|null $base = null, protected CurrencyEnum|null $quote = null)
public function __construct(public CurrencyEnum|null $base = null, public CurrencyEnum|null $quote = null)
{
if (!is_null($base) && !is_null($quote)) {
$this->getHttpRate($base, $quote);
}
}
protected function getHttpRate()
public function getHttpRate()
{
$connector = new AdaUsdExchangeConnector();
......
......@@ -16,7 +16,7 @@ if (! function_exists('ada_to_usd')) {
}
if (! function_exists('usd_to_ada')) {
function usd_to_ada(int|float $amount = null): float|int
function usd_to_ada(int|float $amount = 1): float|int
{
$rateInstance = new AdaUsdQuoteService(CurrencyEnum::USD, CurrencyEnum::ADA);
......
<?php
use Lidonation\Adapayments\App\Enums\CurrencyEnum;
use Lidonation\Adapayments\App\Services\AdaUsdQuoteService;
it('can get exchange rates', function () {
$mock = mock(AdaUsdQuoteService::class)->makePartial();
$mock->rateApiProviders = ['coinapi', 'coinbase'];
$mock->shouldReceive('coinapi')
$mock->base = CurrencyEnum::ADA;
$mock->quote = CurrencyEnum::USD;
$mock->ratesArray = [0.44, 0.45, 0.46];
$mock->shouldReceive('resolveCoinapi')
->andReturn(0.44)
->getMock();
$mock->shouldReceive('resolveCoinbase')
->andReturn(0.45)
->getMock();
$mock->shouldReceive('coinbase')
$mock->shouldReceive('resolveCoinmarketcap')
->andReturn(0.46)
->getMock();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment