| @@ 217-229 (lines=13) @@ | ||
| 214 | $this->assertEquals($expected, $result); |
|
| 215 | } |
|
| 216 | ||
| 217 | public function testRateUsingDatabaseWhenRateExistInDatabaseAndNeedToBeUpdated() |
|
| 218 | { |
|
| 219 | $fromCurrency = 'EUR'; |
|
| 220 | $toCurrency = 'GBP'; |
|
| 221 | ||
| 222 | $this->CurrencyConverter = new CurrencyConverterComponent($this->Registry, [ |
|
| 223 | 'refresh' => 0 |
|
| 224 | ]); |
|
| 225 | $result = $this->CurrencyConverter->rate($fromCurrency, $toCurrency); |
|
| 226 | $expected = $this->Table->find('all')->where(['from_currency' => 'EUR', 'to_currency' => 'GBP'])->first()->rate; |
|
| 227 | ||
| 228 | $this->assertEquals($expected, $result); |
|
| 229 | } |
|
| 230 | ||
| 231 | public function testRateNotUsingDatabse() |
|
| 232 | { |
|
| @@ 218-230 (lines=13) @@ | ||
| 215 | $this->assertEquals($expected, $result); |
|
| 216 | } |
|
| 217 | ||
| 218 | public function testRateUsingDatabaseWhenRateExistInDatabaseAndNeedToBeUpdated() |
|
| 219 | { |
|
| 220 | $fromCurrency = 'EUR'; |
|
| 221 | $toCurrency = 'GBP'; |
|
| 222 | ||
| 223 | $this->CurrencyConverter = new CurrencyConverterHelper($this->View, [ |
|
| 224 | 'refresh' => 0 |
|
| 225 | ]); |
|
| 226 | $result = $this->CurrencyConverter->rate($fromCurrency, $toCurrency); |
|
| 227 | $expected = $this->Table->find('all')->where(['from_currency' => 'EUR', 'to_currency' => 'GBP'])->first()->rate; |
|
| 228 | ||
| 229 | $this->assertEquals($expected, $result); |
|
| 230 | } |
|
| 231 | ||
| 232 | public function testRateNotUsingDatabse() |
|
| 233 | { |
|