| @@ 127-138 (lines=12) @@ | ||
| 124 | $this->assertEquals($expected, $result); |
|
| 125 | } |
|
| 126 | ||
| 127 | public function testConvertUsingDatabaseWhenRateDoNotExistInDatabase() |
|
| 128 | { |
|
| 129 | $amount = 20.00; |
|
| 130 | $fromCurrency = 'EUR'; |
|
| 131 | $toCurrency = 'USD'; |
|
| 132 | ||
| 133 | $result = $this->CurrencyConverter->convert($amount, $fromCurrency, $toCurrency); |
|
| 134 | $rate = $this->Table->find('all')->where(['from_currency' => 'EUR', 'to_currency' => 'USD'])->first()->rate; |
|
| 135 | $expected = round(number_format($rate * 20.00, 2), 2); |
|
| 136 | ||
| 137 | $this->assertEquals($expected, $result); |
|
| 138 | } |
|
| 139 | ||
| 140 | public function testConvertUsingDatabaseWhenRateExistInDatabaseAndNoNeedToBeUpdated() |
|
| 141 | { |
|
| @@ 127-138 (lines=12) @@ | ||
| 124 | $this->assertEquals($expected, $result); |
|
| 125 | } |
|
| 126 | ||
| 127 | public function testConvertUsingDatabaseWhenRateDoNotExistInDatabase() |
|
| 128 | { |
|
| 129 | $amount = 20.00; |
|
| 130 | $fromCurrency = 'EUR'; |
|
| 131 | $toCurrency = 'USD'; |
|
| 132 | ||
| 133 | $result = $this->CurrencyConverter->convert($amount, $fromCurrency, $toCurrency); |
|
| 134 | $rate = $this->Table->find('all')->where(['from_currency' => 'EUR', 'to_currency' => 'USD'])->first()->rate; |
|
| 135 | $expected = round(number_format($rate * 20.00, 2), 2); |
|
| 136 | ||
| 137 | $this->assertEquals($expected, $result); |
|
| 138 | } |
|
| 139 | ||
| 140 | public function testConvertUsingDatabaseWhenRateExistInDatabaseAndNoNeedToBeUpdated() |
|
| 141 | { |
|