Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
adapayments
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
lidonation
adapayments
Commits
72374924
Commit
72374924
authored
1 year ago
by
Michael Teddy
Browse files
Options
Downloads
Patches
Plain Diff
fix/clean-up-tests
parent
df339d76
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!17
fix/clean-up-and-refactoring-for-wraping-in-laravel
Pipeline
#4144
failed
1 year ago
Stage: build
Stage: test
Stage: review
Stage: performance
Stage: cleanup
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/App/Services/AdaUsdQuoteService.php
+2
-2
2 additions, 2 deletions
src/App/Services/AdaUsdQuoteService.php
src/helpers.php
+1
-1
1 addition, 1 deletion
src/helpers.php
tests/AdaUsdQuoteServiceTest.php
+11
-3
11 additions, 3 deletions
tests/AdaUsdQuoteServiceTest.php
with
14 additions
and
6 deletions
src/App/Services/AdaUsdQuoteService.php
+
2
−
2
View file @
72374924
...
...
@@ -19,14 +19,14 @@ class AdaUsdQuoteService
public
array
$ratesArray
=
[];
public
function
__construct
(
p
rotected
CurrencyEnum
|
null
$base
=
null
,
p
rotected
CurrencyEnum
|
null
$quote
=
null
)
public
function
__construct
(
p
ublic
CurrencyEnum
|
null
$base
=
null
,
p
ublic
CurrencyEnum
|
null
$quote
=
null
)
{
if
(
!
is_null
(
$base
)
&&
!
is_null
(
$quote
))
{
$this
->
getHttpRate
(
$base
,
$quote
);
}
}
p
rotected
function
getHttpRate
()
p
ublic
function
getHttpRate
()
{
$connector
=
new
AdaUsdExchangeConnector
();
...
...
This diff is collapsed.
Click to expand it.
src/helpers.php
+
1
−
1
View file @
72374924
...
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
tests/AdaUsdQuoteServiceTest.php
+
11
−
3
View file @
72374924
<?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
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment