mirror of
https://github.com/kevin-DL/LaravelShoppingcart.git
synced 2026-01-23 15:41:24 +00:00
Update CartTest.php
This commit is contained in:
@@ -586,25 +586,6 @@ class CartTest extends TestCase
|
|||||||
$this->assertEquals(60.00, $cart->subtotal());
|
$this->assertEquals(60.00, $cart->subtotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function it_can_return_a_formatted_total()
|
|
||||||
{
|
|
||||||
$cart = $this->getCart();
|
|
||||||
|
|
||||||
$cart->add(new BuyableProduct([
|
|
||||||
'name' => 'First item',
|
|
||||||
'price' => 1000.00,
|
|
||||||
]));
|
|
||||||
$cart->add(new BuyableProduct([
|
|
||||||
'id' => 2,
|
|
||||||
'name' => 'Second item',
|
|
||||||
'price' => 2500.00,
|
|
||||||
]), 2);
|
|
||||||
|
|
||||||
$this->assertItemsInCart(3, $cart);
|
|
||||||
$this->assertEquals('6.000,00', $cart->subtotal(2, ',', '.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
/** @test */
|
||||||
public function it_can_search_the_cart_for_a_specific_item()
|
public function it_can_search_the_cart_for_a_specific_item()
|
||||||
{
|
{
|
||||||
@@ -746,21 +727,6 @@ class CartTest extends TestCase
|
|||||||
$this->assertEquals(29.97, $cartItem->subtotal);
|
$this->assertEquals(29.97, $cartItem->subtotal);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function it_can_return_a_formatted_subtotal()
|
|
||||||
{
|
|
||||||
$cart = $this->getCart();
|
|
||||||
|
|
||||||
$cart->add(new BuyableProduct([
|
|
||||||
'name' => 'Some title',
|
|
||||||
'price' => 500,
|
|
||||||
]), 3);
|
|
||||||
|
|
||||||
$cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da');
|
|
||||||
|
|
||||||
$this->assertEquals('1.500,00', $cartItem->subtotal(2, ',', '.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
/** @test */
|
||||||
public function it_can_calculate_tax_based_on_the_default_tax_rate_in_the_config()
|
public function it_can_calculate_tax_based_on_the_default_tax_rate_in_the_config()
|
||||||
{
|
{
|
||||||
@@ -791,21 +757,6 @@ class CartTest extends TestCase
|
|||||||
$this->assertEquals(1.90, $cartItem->tax);
|
$this->assertEquals(1.90, $cartItem->tax);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function it_can_return_the_calculated_tax_formatted()
|
|
||||||
{
|
|
||||||
$cart = $this->getCart();
|
|
||||||
|
|
||||||
$cart->add(new BuyableProduct([
|
|
||||||
'name' => 'Some title',
|
|
||||||
'price' => 10000.00,
|
|
||||||
]), 1);
|
|
||||||
|
|
||||||
$cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da');
|
|
||||||
|
|
||||||
$this->assertEquals('2.100,00', $cartItem->tax(2, ',', '.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
/** @test */
|
||||||
public function it_can_calculate_the_total_tax_for_all_cart_items()
|
public function it_can_calculate_the_total_tax_for_all_cart_items()
|
||||||
{
|
{
|
||||||
@@ -823,24 +774,6 @@ class CartTest extends TestCase
|
|||||||
$this->assertEquals(10.50, $cart->tax);
|
$this->assertEquals(10.50, $cart->tax);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function it_can_return_formatted_total_tax()
|
|
||||||
{
|
|
||||||
$cart = $this->getCart();
|
|
||||||
|
|
||||||
$cart->add(new BuyableProduct([
|
|
||||||
'name' => 'Some title',
|
|
||||||
'price' => 1000.00,
|
|
||||||
]), 1);
|
|
||||||
$cart->add(new BuyableProduct([
|
|
||||||
'id' => 2,
|
|
||||||
'name' => 'Some title',
|
|
||||||
'price' => 2000.00,
|
|
||||||
]), 2);
|
|
||||||
|
|
||||||
$this->assertEquals('1.050,00', $cart->tax(2, ',', '.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
/** @test */
|
||||||
public function it_can_access_tax_as_percentage()
|
public function it_can_access_tax_as_percentage()
|
||||||
{
|
{
|
||||||
@@ -871,22 +804,6 @@ class CartTest extends TestCase
|
|||||||
$this->assertEquals(50.00, $cart->subtotal);
|
$this->assertEquals(50.00, $cart->subtotal);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function it_can_return_formatted_subtotal()
|
|
||||||
{
|
|
||||||
$cart = $this->getCart();
|
|
||||||
|
|
||||||
$cart->add(new BuyableProduct([
|
|
||||||
'price' => 1000.00,
|
|
||||||
]), 1);
|
|
||||||
$cart->add(new BuyableProduct([
|
|
||||||
'id' => 2,
|
|
||||||
'price' => 2000.00,
|
|
||||||
]), 2);
|
|
||||||
|
|
||||||
$this->assertEquals('5000,00', $cart->subtotal(2, ',', ''));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
/** @test */
|
||||||
public function it_can_return_cart_formated_numbers_by_config_values()
|
public function it_can_return_cart_formated_numbers_by_config_values()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user