Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Unit/UtilsTest.php
Show First 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | class UtilsTest extends TestCase | ||||
} | } | ||||
/** | /** | ||||
* Test for Utils::exchangeRate() | * Test for Utils::exchangeRate() | ||||
*/ | */ | ||||
public function testExchangeRate(): void | public function testExchangeRate(): void | ||||
{ | { | ||||
$this->assertSame(1.0, Utils::exchangeRate("DUMMY", "dummy")); | $this->assertSame(1.0, Utils::exchangeRate("DUMMY", "dummy")); | ||||
$this->assertEqualsWithDelta(0.90503424978382, Utils::exchangeRate("CHF", "EUR"), PHP_FLOAT_EPSILON); | |||||
$this->assertEqualsWithDelta(1.1049305595217682, Utils::exchangeRate("EUR", "CHF"), PHP_FLOAT_EPSILON); | // Exchange rates are volatile, can't test with high accuracy. | ||||
$this->assertTrue(Utils::exchangeRate("CHF", "EUR") >= 0.88); | |||||
//$this->assertEqualsWithDelta(0.90503424978382, Utils::exchangeRate("CHF", "EUR"), PHP_FLOAT_EPSILON); | |||||
$this->assertTrue(Utils::exchangeRate("EUR", "CHF") <= 1.12); | |||||
//$this->assertEqualsWithDelta(1.1049305595217682, Utils::exchangeRate("EUR", "CHF"), PHP_FLOAT_EPSILON); | |||||
$this->expectException(\Exception::class); | $this->expectException(\Exception::class); | ||||
$this->assertSame(1.0, Utils::exchangeRate("CHF", "FOO")); | $this->assertSame(1.0, Utils::exchangeRate("CHF", "FOO")); | ||||
$this->expectException(\Exception::class); | $this->expectException(\Exception::class); | ||||
$this->assertSame(1.0, Utils::exchangeRate("FOO", "CHF")); | $this->assertSame(1.0, Utils::exchangeRate("FOO", "CHF")); | ||||
} | } | ||||
} | } |