| @@ 152-166 (lines=15) @@ | ||
| 149 | $this->assertEquals($expected, $result); |
|
| 150 | } |
|
| 151 | ||
| 152 | public function testConvertUsingDatabaseWhenRateExistInDatabaseAndNeedToBeUpdated() |
|
| 153 | { |
|
| 154 | $amount = 20.00; |
|
| 155 | $fromCurrency = 'EUR'; |
|
| 156 | $toCurrency = 'GBP'; |
|
| 157 | ||
| 158 | $this->CurrencyConverter = new CurrencyConverterComponent($this->Registry, [ |
|
| 159 | 'refresh' => 0 |
|
| 160 | ]); |
|
| 161 | $result = $this->CurrencyConverter->convert($amount, $fromCurrency, $toCurrency); |
|
| 162 | $rate = $this->Table->find('all')->where(['from_currency' => 'EUR', 'to_currency' => 'GBP'])->first()->rate; |
|
| 163 | $expected = round(number_format($rate * 20.00, 2), 2); |
|
| 164 | ||
| 165 | $this->assertEquals($expected, $result); |
|
| 166 | } |
|
| 167 | ||
| 168 | public function testConvertNotUsingDatabse() |
|
| 169 | { |
|
| @@ 153-167 (lines=15) @@ | ||
| 150 | ||
| 151 | } |
|
| 152 | ||
| 153 | public function testConvertUsingDatabaseWhenRateExistInDatabaseAndNeedToBeUpdated() |
|
| 154 | { |
|
| 155 | $amount = 20.00; |
|
| 156 | $fromCurrency = 'EUR'; |
|
| 157 | $toCurrency = 'GBP'; |
|
| 158 | ||
| 159 | $this->CurrencyConverter = new CurrencyConverterHelper($this->View, [ |
|
| 160 | 'refresh' => 0 |
|
| 161 | ]); |
|
| 162 | $result = $this->CurrencyConverter->convert($amount, $fromCurrency, $toCurrency); |
|
| 163 | $rate = $this->Table->find('all')->where(['from_currency' => 'EUR', 'to_currency' => 'GBP'])->first()->rate; |
|
| 164 | $expected = round(number_format($rate * 20.00, 2), 2); |
|
| 165 | ||
| 166 | $this->assertEquals($expected, $result); |
|
| 167 | } |
|
| 168 | ||
| 169 | public function testConvertNotUsingDatabse() |
|
| 170 | { |
|