Skip to content

Commit efb3722

Browse files
authored
Merge pull request #3 from RunOpenCode/bugfix/wrong-rates-issue
Fixed issue with wrong rates used
2 parents 9315285 + 4ee770f commit efb3722

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

src/RunOpenCode/ExchangeRate/BancaIntesaSerbia/Source/ApiSource.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ final class ApiSource implements SourceInterface
3232
const URL = 'https://www.bancaintesa.rs/digitalServicesServlet/';
3333

3434
const API_RATE_TYPES = [
35-
RateType::FOREIGN_EXCHANGE_BUYING => 'buyRateCash',
36-
RateType::FOREIGN_CASH_BUYING => 'buyRate',
37-
RateType::FOREIGN_EXCHANGE_SELLING => 'sellingRateCash',
38-
RateType::FOREIGN_CASH_SELLING => 'sellingRate',
35+
RateType::FOREIGN_EXCHANGE_BUYING => 'buyRate',
36+
RateType::FOREIGN_CASH_BUYING => 'buyRateCash',
37+
RateType::FOREIGN_EXCHANGE_SELLING => 'sellingRate',
38+
RateType::FOREIGN_CASH_SELLING => 'sellingRateCash',
3939
RateType::MEDIAN => 'meanRate',
4040
];
4141

test/Source/ApiSourceTest.php

+30
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,36 @@ public function getDataForTestFetch()
4545
yield 'Test foreign cash selling type' => [RateType::FOREIGN_CASH_SELLING, 'GBP', 148.3312];
4646
}
4747

48+
/**
49+
* @test
50+
* @dataProvider getDataForTestFetchEur
51+
*
52+
* @return void
53+
*/
54+
public function testFetchEur(string $type, float $expectedValue)
55+
{
56+
$source = new ApiSource();
57+
58+
$result = $source->fetch('EUR', $type, new \DateTime('2024-01-01'));
59+
$this->assertSame($expectedValue, $result->getValue());
60+
$this->assertSame('banca_intesa_serbia', $result->getSourceName());
61+
$this->assertSame('EUR', $result->getCurrencyCode());
62+
$this->assertSame($type, $result->getRateType());
63+
$this->assertSame('RSD', $result->getBaseCurrencyCode());
64+
}
65+
66+
/**
67+
* @return iterable<string, array{string, float}>
68+
*/
69+
public function getDataForTestFetchEur()
70+
{
71+
yield 'Test median type' => [RateType::MEDIAN, 117.1737];
72+
yield 'Test foreign exchange buying type' => [RateType::FOREIGN_EXCHANGE_BUYING, 114.2444];
73+
yield 'Test foreign cash buying type' => [RateType::FOREIGN_CASH_BUYING, 114.2444];
74+
yield 'Test foreign exchange selling type' => [RateType::FOREIGN_EXCHANGE_SELLING, 120.103];
75+
yield 'Test foreign cash selling type' => [RateType::FOREIGN_CASH_SELLING, 118.6384];
76+
}
77+
4878
/**
4979
* @return void
5080
*/

0 commit comments

Comments
 (0)