コード例 #1
0
 public function test_getting_formatted_prices()
 {
     CurrencySettings::set('symbol', '$');
     CurrencySettings::set('decimal_character', '.');
     CurrencySettings::set('thousands_seperator', ',');
     $product = Factory::create(new Product(), ['base_price' => 1234.56]);
     Factory::create(new Price(), ['product_id' => $product->id, 'discount_id' => 1, 'price' => 78.90000000000001]);
     $this->assertEquals('$1,234.56', $product->getFormattedBasePrice());
     $this->assertEquals('$78.90', $product->getFormattedPrice());
 }
コード例 #2
0
 public function test_getting_the_formatted_amount()
 {
     CurrencySettings::set('symbol', '$');
     CurrencySettings::set('decimal_character', '.');
     CurrencySettings::set('thousands_seperator', ',');
     $discount1 = Factory::create(new Discount(), ['amount_percentage' => 50, 'is_percentage' => true]);
     $discount2 = Factory::create(new Discount(), ['amount_exact' => 1.23, 'is_percentage' => false]);
     $this->assertEquals('50%', $discount1->getFormattedAmount());
     $this->assertEquals('$1.23', $discount2->getFormattedAmount());
 }