From 2eed7b082f83630301e51f57ca8394de228a8605 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs?= Date: Sun, 18 Aug 2019 21:14:58 -0500 Subject: first commit --- .../opencart/system/library/CurrencyTest.php | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 tests/phpunit/opencart/system/library/CurrencyTest.php (limited to 'tests/phpunit/opencart/system/library/CurrencyTest.php') diff --git a/tests/phpunit/opencart/system/library/CurrencyTest.php b/tests/phpunit/opencart/system/library/CurrencyTest.php new file mode 100644 index 0000000..fbb7352 --- /dev/null +++ b/tests/phpunit/opencart/system/library/CurrencyTest.php @@ -0,0 +1,59 @@ +db->query("DELETE FROM " . DB_PREFIX . "currency"); + + $this->db->query("INSERT INTO " . DB_PREFIX . "currency SET currency_id = '1', title = 'Pound Sterling', code = 'GBP', symbol_left = '£', symbol_right = '', decimal_place = '2', value = '0.61979997', status = '1', date_modified = '2011-07-16 10:30:52'"); + $this->db->query("INSERT INTO " . DB_PREFIX . "currency SET currency_id = '2', title = 'US Dollar', code = 'USD', symbol_left = '$', symbol_right = '', decimal_place = '2', value = '1.00000000', status = '1', date_modified = '2011-07-16 16:55:46'"); + $this->db->query("INSERT INTO " . DB_PREFIX . "currency SET currency_id = '3', title = 'Euro', code = 'EUR', symbol_left = '', symbol_right = '€', decimal_place = '2', value = '0.70660001', status = '1', date_modified = '2011-07-16 10:30:52'"); + } + + /* + public function testCurrencySet() { + $this->currency->set('EUR'); + $this->assertEquals('EUR', $this->session->data['currency']); + } + */ + + public function testCurrencyFormat() { + $this->assertEquals('7.06€', $this->currency->format('9.99', 'EUR')); + } + + public function testCurrencyConvert() { + $value = $this->currency->convert('7.06', 'EUR', 'USD'); + + // 9.9915084914872843 + $this->assertEquals(9.9915, round($value, 4)); + } + + public function testCurrencyGetId() { + $this->assertEquals(3, $this->currency->getId('EUR')); + } + + public function testCurrencyGetSymbolLeft() { + $this->assertEquals('£', $this->currency->getSymbolLeft('GBP')); + } + + public function testCurrencyGetSymbolRight() { + $this->assertEquals('€', $this->currency->getSymbolRight('EUR')); + } + + public function testCurrencyGetDecimalPlace() { + $this->assertEquals(2, $this->currency->getDecimalPlace('GBP')); + } + + /* + public function testCurrencyGetCode() { + $this->currency->set('GBP'); + $this->assertEquals('GBP', $this->currency->getCode()); + } + */ + + public function testCurrencyHas() { + $this->assertTrue($this->currency->has('USD')); + $this->assertFalse($this->currency->has('AUD')); + } +} \ No newline at end of file -- cgit v1.2.3