| @@ 105-125 (lines=21) @@ | ||
| 102 | $this->assertEquals($expected, $result); |
|
| 103 | } |
|
| 104 | ||
| 105 | public function testConvertNumberFormatting() |
|
| 106 | { |
|
| 107 | $amount = 20.123456; |
|
| 108 | $fromCurrency = 'EUR'; |
|
| 109 | $toCurrency = 'EUR'; |
|
| 110 | ||
| 111 | $result = $this->CurrencyConverter->convert($amount, $fromCurrency, $toCurrency); |
|
| 112 | $expected = 20.12; |
|
| 113 | $this->assertEquals($expected, $result); |
|
| 114 | ||
| 115 | $amount = 20.123456; |
|
| 116 | $fromCurrency = 'EUR'; |
|
| 117 | $toCurrency = 'EUR'; |
|
| 118 | ||
| 119 | $this->CurrencyConverter = new CurrencyConverterComponent($this->Registry, [ |
|
| 120 | 'decimal' => 3 |
|
| 121 | ]); |
|
| 122 | $result = $this->CurrencyConverter->convert($amount, $fromCurrency, $toCurrency); |
|
| 123 | $expected = 20.123; |
|
| 124 | $this->assertEquals($expected, $result); |
|
| 125 | } |
|
| 126 | ||
| 127 | public function testConvertUsingDatabaseWhenRateDoNotExistInDatabase() |
|
| 128 | { |
|
| @@ 105-125 (lines=21) @@ | ||
| 102 | $this->assertEquals($expected, $result); |
|
| 103 | } |
|
| 104 | ||
| 105 | public function testConvertNumberFormatting() |
|
| 106 | { |
|
| 107 | $amount = 20.123456; |
|
| 108 | $fromCurrency = 'EUR'; |
|
| 109 | $toCurrency = 'EUR'; |
|
| 110 | ||
| 111 | $result = $this->CurrencyConverter->convert($amount, $fromCurrency, $toCurrency); |
|
| 112 | $expected = 20.12; |
|
| 113 | $this->assertEquals($expected, $result); |
|
| 114 | ||
| 115 | $amount = 20.123456; |
|
| 116 | $fromCurrency = 'EUR'; |
|
| 117 | $toCurrency = 'EUR'; |
|
| 118 | ||
| 119 | $this->CurrencyConverter = new CurrencyConverterHelper($this->View, [ |
|
| 120 | 'decimal' => 3 |
|
| 121 | ]); |
|
| 122 | $result = $this->CurrencyConverter->convert($amount, $fromCurrency, $toCurrency); |
|
| 123 | $expected = 20.123; |
|
| 124 | $this->assertEquals($expected, $result); |
|
| 125 | } |
|
| 126 | ||
| 127 | public function testConvertUsingDatabaseWhenRateDoNotExistInDatabase() |
|
| 128 | { |
|