3
3
namespace Orkhanahmadov \LaravelCurrencylayer \Tests ;
4
4
5
5
use Carbon \Carbon ;
6
+ use OceanApplications \currencylayer \client ;
7
+ use Orkhanahmadov \LaravelCurrencylayer \Currencylayer ;
6
8
use Orkhanahmadov \LaravelCurrencylayer \Models \Currency ;
7
9
use Orkhanahmadov \LaravelCurrencylayer \Models \Rate ;
8
10
9
11
class CurrencylayerTest extends TestCase
10
12
{
13
+ /**
14
+ * @var Currencylayer
15
+ */
16
+ private $ service ;
17
+
18
+ protected function setUp (): void
19
+ {
20
+ parent ::setUp ();
21
+
22
+ $ this ->app ->bind (client::class, function () {
23
+ return new FakeClient ();
24
+ });
25
+
26
+ $ this ->service = app (Currencylayer::class);
27
+ }
28
+
11
29
public function testLiveWithSingleTarget ()
12
30
{
13
31
$ this ->assertSame (0 , Currency::count ());
@@ -67,7 +85,7 @@ public function testRateForWithSingleTarget()
67
85
$ this ->assertSame (0 , Currency::count ());
68
86
$ this ->assertSame (0 , Rate::count ());
69
87
70
- $ rate = $ this ->service ->rateFor ('USD ' , Carbon::today (), 'AED ' );
88
+ $ rate = $ this ->service ->rate ('USD ' , Carbon::today (), 'AED ' );
71
89
72
90
$ this ->assertSame (3.67266 , $ rate );
73
91
}
@@ -77,7 +95,7 @@ public function testRateForWithMultipleTargets()
77
95
$ this ->assertSame (0 , Currency::count ());
78
96
$ this ->assertSame (0 , Rate::count ());
79
97
80
- $ rates = $ this ->service ->rateFor ('USD ' , Carbon::today ()->format ('Y-m-d ' ), 'AED ' , 'AMD ' );
98
+ $ rates = $ this ->service ->rate ('USD ' , Carbon::today ()->format ('Y-m-d ' ), 'AED ' , 'AMD ' );
81
99
82
100
$ this ->assertTrue (is_array ($ rates ));
83
101
$ this ->assertSame (3.67266 , $ rates ['AED ' ]);
0 commit comments