Skip to content

Commit

Permalink
Change result structure
Browse files Browse the repository at this point in the history
  • Loading branch information
ksdev-pl committed Jul 4, 2015
1 parent 2ff657f commit c525236
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 21 deletions.
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@ catch (Exception $e) {
``` php
array(
'publication_date' => '2015-07-03',
'result' =>
array(
'amount' => '32.7246',
'currency' => 'USD',
),
'amount' => '32.7246',
'currency' => 'USD'
);
```

Expand Down
6 changes: 2 additions & 4 deletions src/NBPCurrencyConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,8 @@ public function convert($fromAmount, $fromCurrency, $toCurrency)

return [
'publication_date' => $rates['data_publikacji'],
'result' => [
'amount' => $roundedResult,
'currency' => $toCurrency
]
'amount' => $roundedResult,
'currency' => $toCurrency
];
}

Expand Down
24 changes: 12 additions & 12 deletions tests/NBPCurrencyConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ public function testConvert()

$converter = new NBPCurrencyConverter($guzzleMock, null, 0);

$this->assertEquals('123.4567', $converter->convert('123.4567', 'PLN', 'PLN')['result']['amount']);
$this->assertEquals('32.7246', $converter->convert('123.4567', 'PLN', 'USD')['result']['amount']);
$this->assertEquals('465.7527', $converter->convert('123.4567', 'USD', 'PLN')['result']['amount']);
$this->assertEquals('9265.0432', $converter->convert('123.4567', 'PLN', 'HUF')['result']['amount']);
$this->assertEquals('1.6451', $converter->convert('123.4567', 'HUF', 'PLN')['result']['amount']);
$this->assertEquals('137.1028', $converter->convert('123.4567', 'EUR', 'USD')['result']['amount']);
$this->assertEquals('111.1688', $converter->convert('123.4567', 'USD', 'EUR')['result']['amount']);
$this->assertEquals('34953.3018', $converter->convert('123.4567', 'USD', 'HUF')['result']['amount']);
$this->assertEquals('0.4361', $converter->convert('123.4567', 'HUF', 'USD')['result']['amount']);
$this->assertEquals('284.0662', $converter->convert('123.4567', 'JPY', 'HUF')['result']['amount']);
$this->assertEquals('53.6549', $converter->convert('123.4567', 'HUF', 'JPY')['result']['amount']);
$this->assertEquals('123.4567', $converter->convert('123.4567', 'JPY', 'JPY')['result']['amount']);
$this->assertEquals('123.4567', $converter->convert('123.4567', 'PLN', 'PLN')['amount']);
$this->assertEquals('32.7246', $converter->convert('123.4567', 'PLN', 'USD')['amount']);
$this->assertEquals('465.7527', $converter->convert('123.4567', 'USD', 'PLN')['amount']);
$this->assertEquals('9265.0432', $converter->convert('123.4567', 'PLN', 'HUF')['amount']);
$this->assertEquals('1.6451', $converter->convert('123.4567', 'HUF', 'PLN')['amount']);
$this->assertEquals('137.1028', $converter->convert('123.4567', 'EUR', 'USD')['amount']);
$this->assertEquals('111.1688', $converter->convert('123.4567', 'USD', 'EUR')['amount']);
$this->assertEquals('34953.3018', $converter->convert('123.4567', 'USD', 'HUF')['amount']);
$this->assertEquals('0.4361', $converter->convert('123.4567', 'HUF', 'USD')['amount']);
$this->assertEquals('284.0662', $converter->convert('123.4567', 'JPY', 'HUF')['amount']);
$this->assertEquals('53.6549', $converter->convert('123.4567', 'HUF', 'JPY')['amount']);
$this->assertEquals('123.4567', $converter->convert('123.4567', 'JPY', 'JPY')['amount']);
}

public function tearDown()
Expand Down

0 comments on commit c525236

Please sign in to comment.