Skip to content

Commit dca78bc

Browse files
authored
Added name to the response and wrote test accordingly. (#6)
* Added name to the response and wrote test accordingly. * fix the issue with pull request * fix the issue with pull request * Revert back as getRates() has no effect * Fix for styleci
1 parent 047019f commit dca78bc

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/CBAR.php

+1
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ private function getRatesFromCBAR()
237237
$this->rates[$this->date][(string) $currency->attributes()['Code']] = [
238238
'rate' => (float) $currency->Value,
239239
'nominal' => (int) $currency->Nominal,
240+
'name' => (string) $currency->Name,
240241
];
241242
}
242243
}

tests/Unit/CBARTest.php

+15-4
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ public function test_magic_get_method_returns_currency_rate()
8585
'01.05.2019' => [
8686
'USD' => [
8787
'nominal' => 1,
88-
'rate' => 1.7053,
88+
'name' => '1 ABŞ dolları',
89+
'rate' => 1.7053,
8990
],
9091
],
9192
]);
@@ -102,7 +103,8 @@ public function test_magic_get_method_throws_exception_if_currency_is_not_availa
102103
'01.05.2019' => [
103104
'USD' => [
104105
'nominal' => 1,
105-
'rate' => 1.7053,
106+
'name' => '1 ABŞ dolları',
107+
'rate' => 1.7053,
106108
],
107109
],
108110
]);
@@ -147,7 +149,8 @@ public function test_magic_set_method_throws_exception_if_currency_is_not_availa
147149
'01.05.2019' => [
148150
'USD' => [
149151
'nominal' => 1,
150-
'rate' => 1.7053,
152+
'name' => '1 ABŞ dolları',
153+
'rate' => 1.7053,
151154
],
152155
],
153156
]);
@@ -175,12 +178,20 @@ public function test_azn_method_returns_azn_to_other_currency_conversion_with_gi
175178
'01.05.2019' => [
176179
'EUR' => [
177180
'nominal' => 1,
178-
'rate' => 2,
181+
'name' => '1 ABŞ dolları',
182+
'rate' => 2,
179183
],
180184
],
181185
]);
182186

183187
$this->assertEquals(0.5, $cbar->AZN()->EUR);
184188
$this->assertEquals(5, $cbar->AZN(10)->EUR);
185189
}
190+
191+
public function test_method_returns_name_in_body()
192+
{
193+
$cbar = new CBAR();
194+
$rates = $cbar->for('01.05.2019')->getRates()['01.05.2019'];
195+
$this->assertEquals("1 ABŞ dolları", $rates["USD"]["name"]);
196+
}
186197
}

0 commit comments

Comments
 (0)