From bbf070318108fabaae61562c086c33f46c03fea0 Mon Sep 17 00:00:00 2001 From: = Date: Sun, 17 Jan 2021 22:06:16 +0100 Subject: [PATCH 01/37] Fixing InvalidArgumentException when adding buyable models to Cart on newer Laravel Versions. --- src/CanBeBought.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/CanBeBought.php b/src/CanBeBought.php index 62a08a39..b1c28b8e 100644 --- a/src/CanBeBought.php +++ b/src/CanBeBought.php @@ -21,15 +21,15 @@ public function getBuyableIdentifier($options = null) */ public function getBuyableDescription($options = null) { - if (property_exists($this, 'name')) { + if (isset($this->name)) { return $this->name; } - if (property_exists($this, 'title')) { + if (isset($this->title)) { return $this->title; } - if (property_exists($this, 'description')) { + if (isset($this->description)) { return $this->description; } } @@ -41,7 +41,7 @@ public function getBuyableDescription($options = null) */ public function getBuyablePrice($options = null) { - if (property_exists($this, 'price')) { + if (isset($this->price)) { return $this->price; } } @@ -53,7 +53,7 @@ public function getBuyablePrice($options = null) */ public function getBuyableWeight($options = null) { - if (property_exists($this, 'weight')) { + if (isset($this->weight)) { return $this->weight; } From 963be116b70169fb28c3d127d35c3067eda00a35 Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 21:30:44 +0100 Subject: [PATCH 02/37] Update CanBeBought.php Use getAttribute method from HasAttributes trait, --- src/CanBeBought.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/CanBeBought.php b/src/CanBeBought.php index b1c28b8e..e81831df 100644 --- a/src/CanBeBought.php +++ b/src/CanBeBought.php @@ -21,16 +21,16 @@ public function getBuyableIdentifier($options = null) */ public function getBuyableDescription($options = null) { - if (isset($this->name)) { - return $this->name; + if (($name = $this->getAttribute('name'))) { + return $name; } - if (isset($this->title)) { - return $this->title; + if (($title $this->getAttribute('title'))) { + return $ttle; } - if (isset($this->description)) { - return $this->description; + if (($description = $this->getAttribute('description')) { + return $description; } } @@ -41,8 +41,8 @@ public function getBuyableDescription($options = null) */ public function getBuyablePrice($options = null) { - if (isset($this->price)) { - return $this->price; + if (($price = $this->getAttribute('price'))) { + return $price; } } @@ -53,8 +53,8 @@ public function getBuyablePrice($options = null) */ public function getBuyableWeight($options = null) { - if (isset($this->weight)) { - return $this->weight; + if (($weight = $this->getAttribute('weight'))) { + return $weight; } return 0; From db5ad0b3e44e4d305bd2d2531157ff742f6073d7 Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 21:38:28 +0100 Subject: [PATCH 03/37] Update CanBeBought.php Add missing assignment operator --- src/CanBeBought.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CanBeBought.php b/src/CanBeBought.php index e81831df..d553c3ff 100644 --- a/src/CanBeBought.php +++ b/src/CanBeBought.php @@ -25,7 +25,7 @@ public function getBuyableDescription($options = null) return $name; } - if (($title $this->getAttribute('title'))) { + if (($title = $this->getAttribute('title'))) { return $ttle; } From c7b8291ce758945c41e254ba0852cd105e620813 Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 21:39:38 +0100 Subject: [PATCH 04/37] Update CanBeBought.php Add missing bracket --- src/CanBeBought.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CanBeBought.php b/src/CanBeBought.php index d553c3ff..949c3a67 100644 --- a/src/CanBeBought.php +++ b/src/CanBeBought.php @@ -29,7 +29,7 @@ public function getBuyableDescription($options = null) return $ttle; } - if (($description = $this->getAttribute('description')) { + if (($description = $this->getAttribute('description'))) { return $description; } } From 3837160f69d6a0c9402bacc031f69d835445c807 Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 21:42:50 +0100 Subject: [PATCH 05/37] Update BuyableProduct.php Extend Model --- tests/Fixtures/BuyableProduct.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Fixtures/BuyableProduct.php b/tests/Fixtures/BuyableProduct.php index 7ef6e5d2..34b6fb89 100644 --- a/tests/Fixtures/BuyableProduct.php +++ b/tests/Fixtures/BuyableProduct.php @@ -3,8 +3,9 @@ namespace Gloudemans\Tests\Shoppingcart\Fixtures; use Gloudemans\Shoppingcart\Contracts\Buyable; +use Illuminate\Database\Eloquent\Model; -class BuyableProduct implements Buyable +class BuyableProduct extends Model implements Buyable { /** * @var int|string From bda25d35e462539a15f95f129597b6827511d8dd Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 21:43:30 +0100 Subject: [PATCH 06/37] Update BuyableProductTrait.php Extend default Model --- tests/Fixtures/BuyableProductTrait.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Fixtures/BuyableProductTrait.php b/tests/Fixtures/BuyableProductTrait.php index 7d0c9884..4c7d5021 100644 --- a/tests/Fixtures/BuyableProductTrait.php +++ b/tests/Fixtures/BuyableProductTrait.php @@ -3,8 +3,9 @@ namespace Gloudemans\Tests\Shoppingcart\Fixtures; use Gloudemans\Shoppingcart\Contracts\Buyable; +use Illuminate\Database\Eloquent\Model; -class BuyableProductTrait implements Buyable +class BuyableProductTrait extends Model implements Buyable { use \Gloudemans\Shoppingcart\CanBeBought; From 7a0955fe1ab09a9de6f075bae7e3a1418f0f2dc5 Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 21:48:16 +0100 Subject: [PATCH 07/37] Update BuyableProduct.php --- tests/Fixtures/BuyableProduct.php | 35 ------------------------------- 1 file changed, 35 deletions(-) diff --git a/tests/Fixtures/BuyableProduct.php b/tests/Fixtures/BuyableProduct.php index 34b6fb89..47730dc4 100644 --- a/tests/Fixtures/BuyableProduct.php +++ b/tests/Fixtures/BuyableProduct.php @@ -7,41 +7,6 @@ class BuyableProduct extends Model implements Buyable { - /** - * @var int|string - */ - private $id; - - /** - * @var string - */ - private $name; - - /** - * @var float - */ - private $price; - - /** - * @var float - */ - private $weight; - - /** - * BuyableProduct constructor. - * - * @param int|string $id - * @param string $name - * @param float $price - */ - public function __construct($id = 1, $name = 'Item name', $price = 10.00, $weight = 0) - { - $this->id = $id; - $this->name = $name; - $this->price = $price; - $this->weight = $weight; - } - /** * Get the identifier of the Buyable item. * From 80631bab397b49af7c6d449fd2c3f2c930211bee Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 21:48:35 +0100 Subject: [PATCH 08/37] Update BuyableProductTrait.php --- tests/Fixtures/BuyableProductTrait.php | 35 -------------------------- 1 file changed, 35 deletions(-) diff --git a/tests/Fixtures/BuyableProductTrait.php b/tests/Fixtures/BuyableProductTrait.php index 4c7d5021..4386b9e2 100644 --- a/tests/Fixtures/BuyableProductTrait.php +++ b/tests/Fixtures/BuyableProductTrait.php @@ -8,39 +8,4 @@ class BuyableProductTrait extends Model implements Buyable { use \Gloudemans\Shoppingcart\CanBeBought; - - /** - * @var int|string - */ - private $id; - - /** - * @var string - */ - private $name; - - /** - * @var float - */ - private $price; - - /** - * @var float - */ - private $weight; - - /** - * BuyableProduct constructor. - * - * @param int|string $id - * @param string $name - * @param float $price - */ - public function __construct($id = 1, $name = 'Item name', $price = 10.00, $weight = 0) - { - $this->id = $id; - $this->name = $name; - $this->price = $price; - $this->weight = $weight; - } } From 4a60b7cda170c7e0c0c79950b4632e6d45f5c715 Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 21:52:18 +0100 Subject: [PATCH 09/37] Update BuyableProductTrait.php --- tests/Fixtures/BuyableProductTrait.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/Fixtures/BuyableProductTrait.php b/tests/Fixtures/BuyableProductTrait.php index 4386b9e2..aa2c701e 100644 --- a/tests/Fixtures/BuyableProductTrait.php +++ b/tests/Fixtures/BuyableProductTrait.php @@ -8,4 +8,11 @@ class BuyableProductTrait extends Model implements Buyable { use \Gloudemans\Shoppingcart\CanBeBought; + + protected $attributes = [ + 'id' => 1, + 'name' => 'Item name', + 'price' => 10.00, + 'weight' => 0, + ]; } From a3bfd21324cdff06e6edae5ffef44db00150ae5a Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 21:52:33 +0100 Subject: [PATCH 10/37] Update BuyableProduct.php --- tests/Fixtures/BuyableProduct.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/Fixtures/BuyableProduct.php b/tests/Fixtures/BuyableProduct.php index 47730dc4..be0c08ef 100644 --- a/tests/Fixtures/BuyableProduct.php +++ b/tests/Fixtures/BuyableProduct.php @@ -7,6 +7,13 @@ class BuyableProduct extends Model implements Buyable { + protected $attributes = [ + 'id' => 1, + 'name' => 'Item name', + 'price' => 10.00, + 'weight' => 0, + ]; + /** * Get the identifier of the Buyable item. * From a1d262ab663d1a4d8dacd21adef8214c3d7167cf Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 22:17:06 +0100 Subject: [PATCH 11/37] Update CartTest.php --- tests/CartTest.php | 324 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 252 insertions(+), 72 deletions(-) diff --git a/tests/CartTest.php b/tests/CartTest.php index ddb00fb5..0c5dea2f 100644 --- a/tests/CartTest.php +++ b/tests/CartTest.php @@ -82,9 +82,15 @@ public function it_can_have_multiple_instances() { $cart = $this->getCart(); - $cart->add(new BuyableProduct(1, 'First item')); + $cart->add(new BuyableProduct([ + 'id' => 1, + 'name' => 'First item' + ])); - $cart->instance('wishlist')->add(new BuyableProduct(2, 'Second item')); + $cart->instance('wishlist')->add(new BuyableProduct([ + 'id' => 2, + 'name' => 'Second item' + ])); $this->assertItemsInCart(1, $cart->instance(Cart::DEFAULT_INSTANCE)); $this->assertItemsInCart(1, $cart->instance('wishlist')); @@ -126,7 +132,9 @@ public function it_can_add_multiple_buyable_items_at_once() $cart = $this->getCart(); - $cart->add([new BuyableProduct(1), new BuyableProduct(2)]); + $cart->add([new BuyableProduct(1), new BuyableProduct([ + 'id' => 2 + ])]); $this->assertEquals(2, $cart->count()); @@ -140,7 +148,9 @@ public function it_will_return_an_array_of_cartitems_when_you_add_multiple_items $cart = $this->getCart(); - $cartItems = $cart->add([new BuyableProduct(1), new BuyableProduct(2)]); + $cartItems = $cart->add([new BuyableProduct(1), new BuyableProduct([ + 'id' => 2 + ])]); $this->assertTrue(is_array($cartItems)); $this->assertCount(2, $cartItems); @@ -334,7 +344,9 @@ public function it_can_update_an_existing_item_in_the_cart_from_a_buyable() $cart->add(new BuyableProduct()); - $cart->update('027c91341fd5cf4d2579b49c4b6a90da', new BuyableProduct(1, 'Different description')); + $cart->update('027c91341fd5cf4d2579b49c4b6a90da', new BuyableProduct([ + 'description' => 'Different description' + ])); $this->assertItemsInCart(1, $cart); $this->assertEquals('Different description', $cart->get('027c91341fd5cf4d2579b49c4b6a90da')->name); @@ -351,7 +363,7 @@ public function it_can_update_an_existing_item_in_the_cart_from_an_array() $cart->add(new BuyableProduct()); - $cart->update('027c91341fd5cf4d2579b49c4b6a90da', ['name' => 'Different description']); + $cart->update('027c91341fd5cf4d2579b49c4b6a90da', ['description' => 'Different description']); $this->assertItemsInCart(1, $cart); $this->assertEquals('Different description', $cart->get('027c91341fd5cf4d2579b49c4b6a90da')->name); @@ -370,7 +382,9 @@ public function it_will_throw_an_exception_if_a_rowid_was_not_found() $cart->add(new BuyableProduct()); - $cart->update('none-existing-rowid', new BuyableProduct(1, 'Different description')); + $cart->update('none-existing-rowid', new BuyableProduct([ + 'description' => 'Different description' + ])); } /** @test */ @@ -484,8 +498,10 @@ public function it_can_get_the_content_of_the_cart() { $cart = $this->getCart(); - $cart->add(new BuyableProduct(1)); - $cart->add(new BuyableProduct(2)); + $cart->add(new BuyableProduct()); + $cart->add(new BuyableProduct([ + 'id' => 2, + ])); $content = $cart->content(); @@ -509,8 +525,10 @@ public function it_will_include_the_tax_and_subtotal_when_converted_to_an_array( { $cart = $this->getCart(); - $cart->add(new BuyableProduct(1)); - $cart->add(new BuyableProduct(2)); + $cart->add(new BuyableProduct()); + $cart->add(new BuyableProduct([ + 'id' => 2, + ])); $content = $cart->content(); @@ -562,8 +580,14 @@ public function it_can_get_the_total_price_of_the_cart_content() { $cart = $this->getCart(); - $cart->add(new BuyableProduct(1, 'First item', 10.00)); - $cart->add(new BuyableProduct(2, 'Second item', 25.00), 2); + $cart->add(new BuyableProduct([ + 'name' => 'First item' + ])); + $cart->add(new BuyableProduct([ + 'id' => 2, + 'name' => 'Second item', + 'price' => 25.00 + ]), 2); $this->assertItemsInCart(3, $cart); $this->assertEquals(60.00, $cart->subtotal()); @@ -574,8 +598,15 @@ public function it_can_return_a_formatted_total() { $cart = $this->getCart(); - $cart->add(new BuyableProduct(1, 'First item', 1000.00)); - $cart->add(new BuyableProduct(2, 'Second item', 2500.00), 2); + $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, ',', '.')); @@ -586,8 +617,13 @@ public function it_can_search_the_cart_for_a_specific_item() { $cart = $this->getCart(); - $cart->add(new BuyableProduct(1, 'Some item')); - $cart->add(new BuyableProduct(2, 'Another item')); + $cart->add(new BuyableProduct([ + 'name' => 'Some item', + ])); + $cart->add(new BuyableProduct([ + 'id' => 2, + 'name' => 'Another item', + ])); $cartItem = $cart->search(function ($cartItem, $rowId) { return $cartItem->name == 'Some item'; @@ -604,9 +640,17 @@ public function it_can_search_the_cart_for_multiple_items() { $cart = $this->getCart(); - $cart->add(new BuyableProduct(1, 'Some item')); - $cart->add(new BuyableProduct(2, 'Some item')); - $cart->add(new BuyableProduct(3, 'Another item')); + $cart->add(new BuyableProduct([ + 'name' => 'Some item' + ])); + $cart->add(new BuyableProduct([ + 'id' => 2, + 'name' => 'Some item' + ])); + $cart->add(new BuyableProduct([ + 'id' => 3, + 'name' => 'Another item' + ])); $cartItem = $cart->search(function ($cartItem, $rowId) { return $cartItem->name == 'Some item'; @@ -620,8 +664,13 @@ public function it_can_search_the_cart_for_a_specific_item_with_options() { $cart = $this->getCart(); - $cart->add(new BuyableProduct(1, 'Some item'), 1, ['color' => 'red']); - $cart->add(new BuyableProduct(2, 'Another item'), 1, ['color' => 'blue']); + $cart->add(new BuyableProduct([ + 'name' => 'Some item' + ]), 1, ['color' => 'red']); + $cart->add(new BuyableProduct([ + 'id' => 2, + 'name' => 'Another item' + ]), 1, ['color' => 'blue']); $cartItem = $cart->search(function ($cartItem, $rowId) { return $cartItem->options->color == 'red'; @@ -694,7 +743,10 @@ public function it_can_calculate_the_subtotal_of_a_cart_item() { $cart = $this->getCart(); - $cart->add(new BuyableProduct(1, 'Some title', 9.99), 3); + $cart->add(new BuyableProduct([ + 'name' => 'Some title', + 'price' => 9.99, + ]), 3); $cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da'); @@ -706,7 +758,10 @@ public function it_can_return_a_formatted_subtotal() { $cart = $this->getCart(); - $cart->add(new BuyableProduct(1, 'Some title', 500), 3); + $cart->add(new BuyableProduct([ + 'name' => 'Some title' + 'price' => 500, + ]), 3); $cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da'); @@ -718,7 +773,9 @@ public function it_can_calculate_tax_based_on_the_default_tax_rate_in_the_config { $cart = $this->getCart(); - $cart->add(new BuyableProduct(1, 'Some title', 10.00), 1); + $cart->add(new BuyableProduct([ + 'name' => 'Some title' + ]), 1); $cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da'); @@ -730,7 +787,9 @@ public function it_can_calculate_tax_based_on_the_specified_tax() { $cart = $this->getCart(); - $cart->add(new BuyableProduct(1, 'Some title', 10.00), 1); + $cart->add(new BuyableProduct([ + 'name' => 'Some title' + ]), 1); $cart->setTax('027c91341fd5cf4d2579b49c4b6a90da', 19); @@ -744,7 +803,10 @@ public function it_can_return_the_calculated_tax_formatted() { $cart = $this->getCart(); - $cart->add(new BuyableProduct(1, 'Some title', 10000.00), 1); + $cart->add(new BuyableProduct([ + 'name' => 'Some title', + 'price' => 10000.00, + ]), 1); $cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da'); @@ -756,8 +818,14 @@ public function it_can_calculate_the_total_tax_for_all_cart_items() { $cart = $this->getCart(); - $cart->add(new BuyableProduct(1, 'Some title', 10.00), 1); - $cart->add(new BuyableProduct(2, 'Some title', 20.00), 2); + $cart->add(new BuyableProduct([ + 'name' => 'Some title' + ]), 1); + $cart->add(new BuyableProduct([ + 'id' => 2, + 'name' => 'Some title', + 'price' => 20.00 + ]), 2); $this->assertEquals(10.50, $cart->tax); } @@ -767,8 +835,15 @@ public function it_can_return_formatted_total_tax() { $cart = $this->getCart(); - $cart->add(new BuyableProduct(1, 'Some title', 1000.00), 1); - $cart->add(new BuyableProduct(2, 'Some title', 2000.00), 2); + $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, ',', '.')); } @@ -778,7 +853,9 @@ public function it_can_access_tax_as_percentage() { $cart = $this->getCart(); - $cart->add(new BuyableProduct(1, 'Some title', 10.00), 1); + $cart->add(new BuyableProduct([ + 'name' => 'Some title' + ]), 1); $cart->setTax('027c91341fd5cf4d2579b49c4b6a90da', 19); @@ -792,8 +869,11 @@ public function it_can_return_the_subtotal() { $cart = $this->getCart(); - $cart->add(new BuyableProduct(1, 'Some title', 10.00), 1); - $cart->add(new BuyableProduct(2, 'Some title', 20.00), 2); + $cart->add(new BuyableProduct(), 1); + $cart->add(new BuyableProduct([ + 'id' => 2, + 'price' => 20.00 + ]), 2); $this->assertEquals(50.00, $cart->subtotal); } @@ -803,8 +883,13 @@ public function it_can_return_formatted_subtotal() { $cart = $this->getCart(); - $cart->add(new BuyableProduct(1, 'Some title', 1000.00), 1); - $cart->add(new BuyableProduct(2, 'Some title', 2000.00), 2); + $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, ',', '')); } @@ -816,8 +901,13 @@ public function it_can_return_cart_formated_numbers_by_config_values() $cart = $this->getCart(); - $cart->add(new BuyableProduct(1, 'Some title', 1000.00), 1); - $cart->add(new BuyableProduct(2, 'Some title', 2000.00), 2); + $cart->add(new BuyableProduct([ + 'price' => 1000.00 + ]), 1); + $cart->add(new BuyableProduct([ + 'id' =>2, + 'price' => 2000.00 + ]), 2); $this->assertEquals('5000,00', $cart->subtotal()); $this->assertEquals('1050,00', $cart->tax()); @@ -835,7 +925,9 @@ public function it_can_return_cartItem_formated_numbers_by_config_values() $cart = $this->getCartDiscount(50); - $cart->add(new BuyableProduct(1, 'Some title', 2000.00), 2); + $cart->add(new BuyableProduct([ + 'price' => 2000.00 + ]), 2); $cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da'); @@ -988,7 +1080,9 @@ public function it_can_calculate_all_values() { $cart = $this->getCartDiscount(50); - $cart->add(new BuyableProduct(1, 'First item', 10.00), 2); + $cart->add(new BuyableProduct([ + 'name' => 'First item', + ]), 2); $cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da'); @@ -1032,9 +1126,14 @@ public function it_can_calculate_all_values_after_updating_from_array() public function it_can_calculate_all_values_after_updating_from_buyable() { $cart = $this->getCartDiscount(50); - $cart->add(new BuyableProduct(1, 'First item', 5.00), 2); + $cart->add(new BuyableProduct([ + 'name' => 'First item', + 'price' => 5.00 + ]), 2); - $cart->update('027c91341fd5cf4d2579b49c4b6a90da', new BuyableProduct(1, 'First item', 10.00)); + $cart->update('027c91341fd5cf4d2579b49c4b6a90da', new BuyableProduct([ + 'name' => 'First item', + ])); $cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da'); @@ -1070,7 +1169,9 @@ public function can_change_tax_globally() { $cart = $this->getCart(); - $cart->add(new BuyableProduct(1, 'Item', 10.00), 2); + $cart->add(new BuyableProduct([ + 'name' => 'Item' + ]), 2); $cart->setGlobalTax(0); @@ -1084,7 +1185,9 @@ public function can_change_discount_globally() { $cart = $this->getCart(); - $cart->add(new BuyableProduct(1, 'Item', 10.00), 2); + $cart->add(new BuyableProduct([ + 'name' => 'Item' + ]), 2); $cart->setGlobalTax(0); $cart->setGlobalDiscount(50); @@ -1099,7 +1202,10 @@ public function cart_has_no_rounding_errors() { $cart = $this->getCart(); - $cart->add(new BuyableProduct(1, 'Item', 10.004), 2); + $cart->add(new BuyableProduct([ + 'name' => 'Item' + 'price' 10.004, + ]), 2); $cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da'); @@ -1116,8 +1222,13 @@ public function it_can_merge_multiple_carts() Event::fake(); $cart = $this->getCartDiscount(50); - $cart->add(new BuyableProduct(1, 'Item', 10.00), 1); - $cart->add(new BuyableProduct(2, 'Item 2', 10.00), 1); + $cart->add(new BuyableProduct([ + 'name' => 'Item', + ]), 1); + $cart->add(new BuyableProduct([ + 'id' => 2, + 'name' => 'Item 2', + ]), 1); $cart->store('test'); $cart2 = $this->getCart(); @@ -1150,8 +1261,13 @@ public function it_cant_merge_non_existing_cart() ]); Event::fake(); $cart = $this->getCartDiscount(50); - $cart->add(new BuyableProduct(1, 'Item', 10.00), 1); - $cart->add(new BuyableProduct(2, 'Item 2', 10.00), 1); + $cart->add(new BuyableProduct([ + 'name' => 'Item', + ]), 1); + $cart->add(new BuyableProduct([ + 'id' => 2, + 'name' => 'Item 2', + ]), 1); $this->assertEquals(false, $cart->merge('doesNotExist')); $this->assertEquals(2, $cart->countItems()); } @@ -1160,7 +1276,9 @@ public function it_cant_merge_non_existing_cart() public function cart_can_calculate_all_values() { $cart = $this->getCartDiscount(50); - $cart->add(new BuyableProduct(1, 'First item', 10.00), 1); + $cart->add(new BuyableProduct([ + 'name' => 'First item' + ]), 1); $cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da'); $cart->setTax('027c91341fd5cf4d2579b49c4b6a90da', 19); $this->assertEquals('10.00', $cart->initial(2)); @@ -1179,7 +1297,9 @@ public function cart_can_calculate_all_values() public function can_access_cart_item_propertys() { $cart = $this->getCartDiscount(50); - $cart->add(new BuyableProduct(1, 'First item', 10.00), 1); + $cart->add(new BuyableProduct([ + 'name' => 'First item' + ]), 1); $cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da'); $this->assertEquals(50, $cartItem->discountRate); } @@ -1188,7 +1308,9 @@ public function can_access_cart_item_propertys() public function cant_access_non_existant_propertys() { $cart = $this->getCartDiscount(50); - $cart->add(new BuyableProduct(1, 'First item', 10.00), 1); + $cart->add(new BuyableProduct([ + 'name' => 'First item' + ]), 1); $cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da'); $this->assertEquals(null, $cartItem->doesNotExist); $this->assertEquals(null, $cart->doesNotExist); @@ -1198,7 +1320,9 @@ public function cant_access_non_existant_propertys() public function can_set_cart_item_discount() { $cart = $this->getCart(); - $cart->add(new BuyableProduct(1, 'First item', 10.00), 1); + $cart->add(new BuyableProduct([ + 'name' => 'First item' + ]), 1); $cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da'); $cart->setDiscount('027c91341fd5cf4d2579b49c4b6a90da', 50); $this->assertEquals(50, $cartItem->discountRate); @@ -1208,7 +1332,10 @@ public function can_set_cart_item_discount() public function can_set_cart_item_weight_and_calculate_total_weight() { $cart = $this->getCart(); - $cart->add(new BuyableProduct(1, 'First item', 10.00, 250), 2); + $cart->add(new BuyableProduct([ + 'name' => 'First item', + 'weight' => 250, + ]), 2); $cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da'); $cart->setDiscount('027c91341fd5cf4d2579b49c4b6a90da', 50); $this->assertEquals('500.00', $cart->weight(2)); @@ -1232,7 +1359,10 @@ public function cart_can_create_and_restore_from_instance_identifier() $cart->instance($identifier); $this->assertEquals('User1', $cart->currentInstance()); - $cart->add(new BuyableProduct(1, 'First item', 10.00, 250), 2); + $cart->add(new BuyableProduct([ + 'name' => 'First item', + 'weight' => 250, + ]), 2); $this->assertItemsInCart(2, $cart); $cart->store($identifier); @@ -1248,7 +1378,9 @@ public function cart_can_create_items_from_models_using_the_canbebought_trait() { $cart = $this->getCartDiscount(50); - $cart->add(new BuyableProductTrait(1, 'First item', 10.00), 2); + $cart->add(new BuyableProductTrait([ + 'name' => 'First item', + ]), 2); $cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da'); @@ -1271,7 +1403,9 @@ public function it_does_calculate_correct_results_with_rational_qtys() // https://github.com/Crinsane/LaravelShoppingcart/issues/544 $cart = $this->getCart(); - $cart->add(new BuyableProductTrait(1, 'First item', 10.00), 0.5); + $cart->add(new BuyableProductTrait([ + 'name' => 'First item', + ]), 0.5); $cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da'); @@ -1304,8 +1438,13 @@ public function it_can_merge_without_dispatching_add_events() ]); $cart = $this->getCartDiscount(50); - $cart->add(new BuyableProduct(1, 'Item', 10.00), 1); - $cart->add(new BuyableProduct(2, 'Item 2', 10.00), 1); + $cart->add(new BuyableProduct([ + 'name' => 'Item' + ]), 1); + $cart->add(new BuyableProduct([ + 'id' => 2, + 'name' => 'Item 2' + ]), 1); $cart->store('test'); Event::fakeFor(function () { @@ -1334,8 +1473,13 @@ public function it_can_merge_dispatching_add_events() ]); $cart = $this->getCartDiscount(50); - $cart->add(new BuyableProduct(1, 'Item', 10.00), 1); - $cart->add(new BuyableProduct(2, 'Item 2', 10.00), 1); + $cart->add(new BuyableProduct([ + 'name' => 'Item' + ]), 1); + $cart->add(new BuyableProduct([ + 'id' => 2, + 'name' => 'Item 2' + ]), 1); $cart->store('test'); Event::fakeFor(function () { @@ -1362,9 +1506,20 @@ public function it_use_correctly_rounded_values_for_totals_and_cart_summary() $cart = $this->getCartDiscount(6); - $cartItem = $cart->add(new BuyableProduct(1, 'First item', 0.18929), 1000); - $cart->add(new BuyableProduct(2, 'Second item', 4.41632), 5); - $cart->add(new BuyableProduct(3, 'Third item', 0.37995), 25); + $cartItem = $cart->add(new BuyableProduct([ + 'name' => 'First item', + 'price' => 0.18929 + ]), 1000); + $cart->add(new BuyableProduct([ + 'id' => 2, + 'name' => 'Second item', + 'price' => 4.41632 + ]), 5); + $cart->add(new BuyableProduct([ + 'id' => 3, + 'name' => 'Third item', + 'price' => 0.37995 + ]), 25); $cart->setGlobalTax(22); @@ -1381,7 +1536,10 @@ public function it_use_gross_price_as_base_price() $cart = $this->getCartDiscount(0); config(['cart.calculator' => GrossPrice::class]); - $cartItem = $cart->add(new BuyableProduct(1, 'First item', 100), 2); + $cartItem = $cart->add(new BuyableProduct([ + 'name' => 'First item', + 'price' => 100 + ]), 2); $cart->setGlobalTax(22); @@ -1397,9 +1555,20 @@ public function it_use_gross_price_and_it_use_correctly_rounded_values_for_total $cart = $this->getCartDiscount(6); - $cartItem = $cart->add(new BuyableProduct(1, 'First item', 0.23093), 1000); - $cart->add(new BuyableProduct(2, 'Second item', 5.38791), 5); - $cart->add(new BuyableProduct(3, 'Third item', 0.46354), 25); + $cartItem = $cart->add(new BuyableProduct([ + 'name' => 'First item', + 'price' => 0.23093 + ]), 1000); + $cart->add(new BuyableProduct([ + 'id' => 2, + 'name' => 'Second item', + 'price' => 5.38791 + ]), 5); + $cart->add(new BuyableProduct([ + 'id' => 3, + 'name' => 'Third item', + 'price' => 0.46354 + ]), 25); $cart->setGlobalTax(22); @@ -1492,7 +1661,10 @@ public function it_can_calculate_the_total_price_of_the_items_in_cart() { $cart = $this->getCart(); - $cart->add(new BuyableProduct(1, 'first item', $price = 1000), $qty = 5); + $cart->add(new BuyableProduct([ + 'name' => 'first item', + 'price' => 1000 + ]), $qty = 5); $this->assertEquals(5000, $cart->priceTotalFloat()); } @@ -1501,7 +1673,10 @@ public function it_can_format_the_total_price_of_the_items_in_cart() { $cart = $this->getCart(); - $cart->add(new BuyableProduct(1, 'first item', 1000), 5); + $cart->add(new BuyableProduct([ + 'name' => 'first item', + 'price' => 1000 + ]), 5); $this->assertEquals('5,000.00', $cart->priceTotal()); $this->assertEquals('5,000.0000', $cart->priceTotal(4, '.', ',')); } @@ -1516,8 +1691,13 @@ public function it_can_erase_saved_cart_from_the_database() Event::fake(); $cart = $this->getCart(); - $cart->add(new BuyableProduct(1, 'Item', 10.00), 1); - $cart->add(new BuyableProduct(2, 'Item 2', 10.00), 1); + $cart->add(new BuyableProduct([ + 'name' => 'Item' + ]), 1); + $cart->add(new BuyableProduct([ + 'id' => 2, + 'name' => 'Item 2' + ]), 1); $cart->store($identifier = 'test'); $cart->erase($identifier); Event::assertDispatched('cart.erased'); From 7aacf1027bd7cf048985f93d32e47ab8aaa83d28 Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 22:20:38 +0100 Subject: [PATCH 12/37] Update CartTest.php --- tests/CartTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CartTest.php b/tests/CartTest.php index 0c5dea2f..3057aaef 100644 --- a/tests/CartTest.php +++ b/tests/CartTest.php @@ -759,7 +759,7 @@ public function it_can_return_a_formatted_subtotal() $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'name' => 'Some title' + 'name' => 'Some title', 'price' => 500, ]), 3); From aae1b7b9b46fb05015f76b0a2163f38ac83300ff Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 22:21:50 +0100 Subject: [PATCH 13/37] Update BuyableProduct.php --- tests/Fixtures/BuyableProduct.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Fixtures/BuyableProduct.php b/tests/Fixtures/BuyableProduct.php index be0c08ef..e891f994 100644 --- a/tests/Fixtures/BuyableProduct.php +++ b/tests/Fixtures/BuyableProduct.php @@ -8,9 +8,9 @@ class BuyableProduct extends Model implements Buyable { protected $attributes = [ - 'id' => 1, - 'name' => 'Item name', - 'price' => 10.00, + 'id' => 1, + 'name' => 'Item name', + 'price' => 10.00, 'weight' => 0, ]; From 4ab1d4879a3232b66d98bff663d2d657620dd395 Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 22:22:13 +0100 Subject: [PATCH 14/37] Update BuyableProductTrait.php --- tests/Fixtures/BuyableProductTrait.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Fixtures/BuyableProductTrait.php b/tests/Fixtures/BuyableProductTrait.php index aa2c701e..9bfee7ed 100644 --- a/tests/Fixtures/BuyableProductTrait.php +++ b/tests/Fixtures/BuyableProductTrait.php @@ -10,9 +10,9 @@ class BuyableProductTrait extends Model implements Buyable use \Gloudemans\Shoppingcart\CanBeBought; protected $attributes = [ - 'id' => 1, - 'name' => 'Item name', - 'price' => 10.00, + 'id' => 1, + 'name' => 'Item name', + 'price' => 10.00, 'weight' => 0, ]; } From 468d456a545886cdd730ed29ff09b268c46fdb89 Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 22:23:24 +0100 Subject: [PATCH 15/37] Update CartTest.php --- tests/CartTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CartTest.php b/tests/CartTest.php index 3057aaef..b8adaf8f 100644 --- a/tests/CartTest.php +++ b/tests/CartTest.php @@ -1203,7 +1203,7 @@ public function cart_has_no_rounding_errors() $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'name' => 'Item' + 'name' => 'Item', 'price' 10.004, ]), 2); From 6d6399d43fe0d52c470bba1936fd84f00edbd684 Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 22:27:06 +0100 Subject: [PATCH 16/37] Update CartTest.php --- tests/CartTest.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/CartTest.php b/tests/CartTest.php index b8adaf8f..e1babead 100644 --- a/tests/CartTest.php +++ b/tests/CartTest.php @@ -1204,7 +1204,7 @@ public function cart_has_no_rounding_errors() $cart->add(new BuyableProduct([ 'name' => 'Item', - 'price' 10.004, + 'price' => 10.004 ]), 2); $cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da'); @@ -1223,11 +1223,11 @@ public function it_can_merge_multiple_carts() $cart = $this->getCartDiscount(50); $cart->add(new BuyableProduct([ - 'name' => 'Item', + 'name' => 'Item' ]), 1); $cart->add(new BuyableProduct([ 'id' => 2, - 'name' => 'Item 2', + 'name' => 'Item 2' ]), 1); $cart->store('test'); @@ -1257,16 +1257,16 @@ public function it_can_merge_multiple_carts() public function it_cant_merge_non_existing_cart() { $this->artisan('migrate', [ - '--database' => 'testing', + '--database' => 'testing' ]); Event::fake(); $cart = $this->getCartDiscount(50); $cart->add(new BuyableProduct([ - 'name' => 'Item', + 'name' => 'Item' ]), 1); $cart->add(new BuyableProduct([ 'id' => 2, - 'name' => 'Item 2', + 'name' => 'Item 2' ]), 1); $this->assertEquals(false, $cart->merge('doesNotExist')); $this->assertEquals(2, $cart->countItems()); @@ -1348,7 +1348,7 @@ public function can_set_cart_item_weight_and_calculate_total_weight() public function cart_can_create_and_restore_from_instance_identifier() { $this->artisan('migrate', [ - '--database' => 'testing', + '--database' => 'testing' ]); Event::fake(); @@ -1379,7 +1379,7 @@ public function cart_can_create_items_from_models_using_the_canbebought_trait() $cart = $this->getCartDiscount(50); $cart->add(new BuyableProductTrait([ - 'name' => 'First item', + 'name' => 'First item' ]), 2); $cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da'); @@ -1404,7 +1404,7 @@ public function it_does_calculate_correct_results_with_rational_qtys() $cart = $this->getCart(); $cart->add(new BuyableProductTrait([ - 'name' => 'First item', + 'name' => 'First item' ]), 0.5); $cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da'); @@ -1434,7 +1434,7 @@ public function it_does_allow_adding_cart_items_with_weight_and_options() public function it_can_merge_without_dispatching_add_events() { $this->artisan('migrate', [ - '--database' => 'testing', + '--database' => 'testing' ]); $cart = $this->getCartDiscount(50); From 994004b175e879b96b2766239d42d954a473cf9a Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 22:29:26 +0100 Subject: [PATCH 17/37] Update BuyableProduct.php --- tests/Fixtures/BuyableProduct.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/Fixtures/BuyableProduct.php b/tests/Fixtures/BuyableProduct.php index e891f994..c9d94633 100644 --- a/tests/Fixtures/BuyableProduct.php +++ b/tests/Fixtures/BuyableProduct.php @@ -7,6 +7,18 @@ class BuyableProduct extends Model implements Buyable { + /** + * The attributes that are mass assignable. + * + * @var array + */ + protected $fillable = [ + 'id', + 'name', + 'price', + 'weight' + ]; + protected $attributes = [ 'id' => 1, 'name' => 'Item name', From bad0597ae0ef771a34d09ff254a633e23d3c6527 Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 22:29:41 +0100 Subject: [PATCH 18/37] Update BuyableProductTrait.php --- tests/Fixtures/BuyableProductTrait.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/Fixtures/BuyableProductTrait.php b/tests/Fixtures/BuyableProductTrait.php index 9bfee7ed..958e17e5 100644 --- a/tests/Fixtures/BuyableProductTrait.php +++ b/tests/Fixtures/BuyableProductTrait.php @@ -9,6 +9,18 @@ class BuyableProductTrait extends Model implements Buyable { use \Gloudemans\Shoppingcart\CanBeBought; + /** + * The attributes that are mass assignable. + * + * @var array + */ + protected $fillable = [ + 'id', + 'name', + 'price', + 'weight' + ]; + protected $attributes = [ 'id' => 1, 'name' => 'Item name', From ca4674525ad405508768387589e5d7927e6c309d Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 22:30:53 +0100 Subject: [PATCH 19/37] Update CartTest.php --- tests/CartTest.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/CartTest.php b/tests/CartTest.php index e1babead..b77a75a2 100644 --- a/tests/CartTest.php +++ b/tests/CartTest.php @@ -132,7 +132,9 @@ public function it_can_add_multiple_buyable_items_at_once() $cart = $this->getCart(); - $cart->add([new BuyableProduct(1), new BuyableProduct([ + $cart->add([new BuyableProduct([ + 'id' => 1 + ]), new BuyableProduct([ 'id' => 2 ])]); @@ -148,7 +150,9 @@ public function it_will_return_an_array_of_cartitems_when_you_add_multiple_items $cart = $this->getCart(); - $cartItems = $cart->add([new BuyableProduct(1), new BuyableProduct([ + $cartItems = $cart->add([new BuyableProduct([ + 'id' => 1 + ]), new BuyableProduct([ 'id' => 2 ])]); From fa3a606faa10392f1307395df9e50e8c0c6ca82b Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 22:31:33 +0100 Subject: [PATCH 20/37] Update CartTest.php --- tests/CartTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/CartTest.php b/tests/CartTest.php index b77a75a2..7cd167e9 100644 --- a/tests/CartTest.php +++ b/tests/CartTest.php @@ -1107,7 +1107,9 @@ public function it_can_calculate_all_values() public function it_can_calculate_all_values_after_updating_from_array() { $cart = $this->getCartDiscount(50); - $cart->add(new BuyableProduct(1, 'First item', 10.00), 1); + $cart->add(new BuyableProduct([ + 'name' => 'First item' + ]), 1); $cart->update('027c91341fd5cf4d2579b49c4b6a90da', ['qty' => 2]); From daca090c157a43638892d79a395e3a9563cd58d3 Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 22:32:48 +0100 Subject: [PATCH 21/37] Update BuyableProductTrait.php --- tests/Fixtures/BuyableProductTrait.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/Fixtures/BuyableProductTrait.php b/tests/Fixtures/BuyableProductTrait.php index 958e17e5..2a8f33bc 100644 --- a/tests/Fixtures/BuyableProductTrait.php +++ b/tests/Fixtures/BuyableProductTrait.php @@ -17,6 +17,8 @@ class BuyableProductTrait extends Model implements Buyable protected $fillable = [ 'id', 'name', + 'title', + 'description', 'price', 'weight' ]; From 209a813a8f674091586c63193b08bf663823ec50 Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 22:32:59 +0100 Subject: [PATCH 22/37] Update BuyableProduct.php --- tests/Fixtures/BuyableProduct.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/Fixtures/BuyableProduct.php b/tests/Fixtures/BuyableProduct.php index c9d94633..0b36140a 100644 --- a/tests/Fixtures/BuyableProduct.php +++ b/tests/Fixtures/BuyableProduct.php @@ -15,6 +15,8 @@ class BuyableProduct extends Model implements Buyable protected $fillable = [ 'id', 'name', + 'title', + 'description', 'price', 'weight' ]; From f9f072a13b9b55921e46cbc734d2aa059e166427 Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 22:33:51 +0100 Subject: [PATCH 23/37] Update CartTest.php --- tests/CartTest.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/CartTest.php b/tests/CartTest.php index 7cd167e9..56f8b45f 100644 --- a/tests/CartTest.php +++ b/tests/CartTest.php @@ -365,7 +365,10 @@ public function it_can_update_an_existing_item_in_the_cart_from_an_array() $cart = $this->getCart(); - $cart->add(new BuyableProduct()); + $cart->add(new BuyableProduct([ + 'name' => null, + 'title' => null + )); $cart->update('027c91341fd5cf4d2579b49c4b6a90da', ['description' => 'Different description']); From 1eff96a05e03f754444b96c7d475c19133b02c78 Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 22:34:47 +0100 Subject: [PATCH 24/37] Update BuyableProduct.php --- tests/Fixtures/BuyableProduct.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Fixtures/BuyableProduct.php b/tests/Fixtures/BuyableProduct.php index 0b36140a..84e452fd 100644 --- a/tests/Fixtures/BuyableProduct.php +++ b/tests/Fixtures/BuyableProduct.php @@ -18,9 +18,9 @@ class BuyableProduct extends Model implements Buyable 'title', 'description', 'price', - 'weight' + 'weight', ]; - + protected $attributes = [ 'id' => 1, 'name' => 'Item name', From 444bb1d7fd1038133d0b521ad591b4e116985003 Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 22:35:20 +0100 Subject: [PATCH 25/37] Update BuyableProduct.php --- tests/Fixtures/BuyableProduct.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Fixtures/BuyableProduct.php b/tests/Fixtures/BuyableProduct.php index 84e452fd..be0dc7cf 100644 --- a/tests/Fixtures/BuyableProduct.php +++ b/tests/Fixtures/BuyableProduct.php @@ -27,7 +27,7 @@ class BuyableProduct extends Model implements Buyable 'price' => 10.00, 'weight' => 0, ]; - + /** * Get the identifier of the Buyable item. * From 60a9b726f115e093d78988317d8c269bd7ba55d1 Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 22:35:53 +0100 Subject: [PATCH 26/37] Update BuyableProductTrait.php --- tests/Fixtures/BuyableProductTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Fixtures/BuyableProductTrait.php b/tests/Fixtures/BuyableProductTrait.php index 2a8f33bc..cf661f66 100644 --- a/tests/Fixtures/BuyableProductTrait.php +++ b/tests/Fixtures/BuyableProductTrait.php @@ -22,7 +22,7 @@ class BuyableProductTrait extends Model implements Buyable 'price', 'weight' ]; - + protected $attributes = [ 'id' => 1, 'name' => 'Item name', From 69447fd82d9e3ea608704629e7a3bca7587ca643 Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 22:36:07 +0100 Subject: [PATCH 27/37] Update BuyableProductTrait.php --- tests/Fixtures/BuyableProductTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Fixtures/BuyableProductTrait.php b/tests/Fixtures/BuyableProductTrait.php index cf661f66..06010280 100644 --- a/tests/Fixtures/BuyableProductTrait.php +++ b/tests/Fixtures/BuyableProductTrait.php @@ -20,7 +20,7 @@ class BuyableProductTrait extends Model implements Buyable 'title', 'description', 'price', - 'weight' + 'weight', ]; protected $attributes = [ From 80b610b8cb0f2dfc3e6e6062d6221a8472f06607 Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 22:36:40 +0100 Subject: [PATCH 28/37] Update CartTest.php --- tests/CartTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CartTest.php b/tests/CartTest.php index 56f8b45f..a40f5036 100644 --- a/tests/CartTest.php +++ b/tests/CartTest.php @@ -368,7 +368,7 @@ public function it_can_update_an_existing_item_in_the_cart_from_an_array() $cart->add(new BuyableProduct([ 'name' => null, 'title' => null - )); + ])); $cart->update('027c91341fd5cf4d2579b49c4b6a90da', ['description' => 'Different description']); From 8f196928e9bb29ab3a80376edef21771a2884fac Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 22:37:16 +0100 Subject: [PATCH 29/37] Update BuyableProductTrait.php --- tests/Fixtures/BuyableProductTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Fixtures/BuyableProductTrait.php b/tests/Fixtures/BuyableProductTrait.php index 06010280..29e39f31 100644 --- a/tests/Fixtures/BuyableProductTrait.php +++ b/tests/Fixtures/BuyableProductTrait.php @@ -8,7 +8,7 @@ class BuyableProductTrait extends Model implements Buyable { use \Gloudemans\Shoppingcart\CanBeBought; - + /** * The attributes that are mass assignable. * From 36361474e849e5f339531dbe52862b992d6faa9f Mon Sep 17 00:00:00 2001 From: Patrick Henninger Date: Mon, 18 Jan 2021 22:39:28 +0100 Subject: [PATCH 30/37] StyleCI --- tests/CartTest.php | 220 ++++++++++++++++++++++----------------------- 1 file changed, 110 insertions(+), 110 deletions(-) diff --git a/tests/CartTest.php b/tests/CartTest.php index a40f5036..e1ddfa45 100644 --- a/tests/CartTest.php +++ b/tests/CartTest.php @@ -83,13 +83,13 @@ public function it_can_have_multiple_instances() $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'id' => 1, - 'name' => 'First item' + 'id' => 1, + 'name' => 'First item', ])); $cart->instance('wishlist')->add(new BuyableProduct([ - 'id' => 2, - 'name' => 'Second item' + 'id' => 2, + 'name' => 'Second item', ])); $this->assertItemsInCart(1, $cart->instance(Cart::DEFAULT_INSTANCE)); @@ -133,9 +133,9 @@ public function it_can_add_multiple_buyable_items_at_once() $cart = $this->getCart(); $cart->add([new BuyableProduct([ - 'id' => 1 + 'id' => 1, ]), new BuyableProduct([ - 'id' => 2 + 'id' => 2, ])]); $this->assertEquals(2, $cart->count()); @@ -151,9 +151,9 @@ public function it_will_return_an_array_of_cartitems_when_you_add_multiple_items $cart = $this->getCart(); $cartItems = $cart->add([new BuyableProduct([ - 'id' => 1 + 'id' => 1, ]), new BuyableProduct([ - 'id' => 2 + 'id' => 2, ])]); $this->assertTrue(is_array($cartItems)); @@ -349,7 +349,7 @@ public function it_can_update_an_existing_item_in_the_cart_from_a_buyable() $cart->add(new BuyableProduct()); $cart->update('027c91341fd5cf4d2579b49c4b6a90da', new BuyableProduct([ - 'description' => 'Different description' + 'description' => 'Different description', ])); $this->assertItemsInCart(1, $cart); @@ -366,8 +366,8 @@ public function it_can_update_an_existing_item_in_the_cart_from_an_array() $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'name' => null, - 'title' => null + 'name' => null, + 'title' => null, ])); $cart->update('027c91341fd5cf4d2579b49c4b6a90da', ['description' => 'Different description']); @@ -390,7 +390,7 @@ public function it_will_throw_an_exception_if_a_rowid_was_not_found() $cart->add(new BuyableProduct()); $cart->update('none-existing-rowid', new BuyableProduct([ - 'description' => 'Different description' + 'description' => 'Different description', ])); } @@ -588,12 +588,12 @@ public function it_can_get_the_total_price_of_the_cart_content() $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'name' => 'First item' + 'name' => 'First item', ])); $cart->add(new BuyableProduct([ - 'id' => 2, - 'name' => 'Second item', - 'price' => 25.00 + 'id' => 2, + 'name' => 'Second item', + 'price' => 25.00, ]), 2); $this->assertItemsInCart(3, $cart); @@ -606,13 +606,13 @@ public function it_can_return_a_formatted_total() $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'name' => 'First item', - 'price' => 1000.00 + 'name' => 'First item', + 'price' => 1000.00, ])); $cart->add(new BuyableProduct([ - 'id' => 2, - 'name' => 'Second item', - 'price' => 2500.00 + 'id' => 2, + 'name' => 'Second item', + 'price' => 2500.00, ]), 2); $this->assertItemsInCart(3, $cart); @@ -628,7 +628,7 @@ public function it_can_search_the_cart_for_a_specific_item() 'name' => 'Some item', ])); $cart->add(new BuyableProduct([ - 'id' => 2, + 'id' => 2, 'name' => 'Another item', ])); @@ -648,15 +648,15 @@ public function it_can_search_the_cart_for_multiple_items() $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'name' => 'Some item' + 'name' => 'Some item', ])); $cart->add(new BuyableProduct([ - 'id' => 2, - 'name' => 'Some item' + 'id' => 2, + 'name' => 'Some item', ])); $cart->add(new BuyableProduct([ - 'id' => 3, - 'name' => 'Another item' + 'id' => 3, + 'name' => 'Another item', ])); $cartItem = $cart->search(function ($cartItem, $rowId) { @@ -672,11 +672,11 @@ public function it_can_search_the_cart_for_a_specific_item_with_options() $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'name' => 'Some item' + 'name' => 'Some item', ]), 1, ['color' => 'red']); $cart->add(new BuyableProduct([ - 'id' => 2, - 'name' => 'Another item' + 'id' => 2, + 'name' => 'Another item', ]), 1, ['color' => 'blue']); $cartItem = $cart->search(function ($cartItem, $rowId) { @@ -751,7 +751,7 @@ public function it_can_calculate_the_subtotal_of_a_cart_item() $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'name' => 'Some title', + 'name' => 'Some title', 'price' => 9.99, ]), 3); @@ -766,7 +766,7 @@ public function it_can_return_a_formatted_subtotal() $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'name' => 'Some title', + 'name' => 'Some title', 'price' => 500, ]), 3); @@ -781,7 +781,7 @@ public function it_can_calculate_tax_based_on_the_default_tax_rate_in_the_config $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'name' => 'Some title' + 'name' => 'Some title', ]), 1); $cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da'); @@ -795,7 +795,7 @@ public function it_can_calculate_tax_based_on_the_specified_tax() $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'name' => 'Some title' + 'name' => 'Some title', ]), 1); $cart->setTax('027c91341fd5cf4d2579b49c4b6a90da', 19); @@ -811,7 +811,7 @@ public function it_can_return_the_calculated_tax_formatted() $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'name' => 'Some title', + 'name' => 'Some title', 'price' => 10000.00, ]), 1); @@ -826,12 +826,12 @@ public function it_can_calculate_the_total_tax_for_all_cart_items() $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'name' => 'Some title' + 'name' => 'Some title', ]), 1); $cart->add(new BuyableProduct([ - 'id' => 2, - 'name' => 'Some title', - 'price' => 20.00 + 'id' => 2, + 'name' => 'Some title', + 'price' => 20.00, ]), 2); $this->assertEquals(10.50, $cart->tax); @@ -843,13 +843,13 @@ public function it_can_return_formatted_total_tax() $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'name' => 'Some title', - 'price' => 1000.00 + 'name' => 'Some title', + 'price' => 1000.00, ]), 1); $cart->add(new BuyableProduct([ - 'id' => 2, - 'name' => 'Some title', - 'price' => 2000.00 + 'id' => 2, + 'name' => 'Some title', + 'price' => 2000.00, ]), 2); $this->assertEquals('1.050,00', $cart->tax(2, ',', '.')); @@ -861,7 +861,7 @@ public function it_can_access_tax_as_percentage() $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'name' => 'Some title' + 'name' => 'Some title', ]), 1); $cart->setTax('027c91341fd5cf4d2579b49c4b6a90da', 19); @@ -878,8 +878,8 @@ public function it_can_return_the_subtotal() $cart->add(new BuyableProduct(), 1); $cart->add(new BuyableProduct([ - 'id' => 2, - 'price' => 20.00 + 'id' => 2, + 'price' => 20.00, ]), 2); $this->assertEquals(50.00, $cart->subtotal); @@ -891,11 +891,11 @@ public function it_can_return_formatted_subtotal() $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'price' => 1000.00 + 'price' => 1000.00, ]), 1); $cart->add(new BuyableProduct([ - 'id' => 2, - 'price' => 2000.00 + 'id' => 2, + 'price' => 2000.00, ]), 2); $this->assertEquals('5000,00', $cart->subtotal(2, ',', '')); @@ -909,11 +909,11 @@ public function it_can_return_cart_formated_numbers_by_config_values() $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'price' => 1000.00 + 'price' => 1000.00, ]), 1); $cart->add(new BuyableProduct([ - 'id' =>2, - 'price' => 2000.00 + 'id' => 2, + 'price' => 2000.00, ]), 2); $this->assertEquals('5000,00', $cart->subtotal()); @@ -933,7 +933,7 @@ public function it_can_return_cartItem_formated_numbers_by_config_values() $cart = $this->getCartDiscount(50); $cart->add(new BuyableProduct([ - 'price' => 2000.00 + 'price' => 2000.00, ]), 2); $cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da'); @@ -1111,7 +1111,7 @@ public function it_can_calculate_all_values_after_updating_from_array() { $cart = $this->getCartDiscount(50); $cart->add(new BuyableProduct([ - 'name' => 'First item' + 'name' => 'First item', ]), 1); $cart->update('027c91341fd5cf4d2579b49c4b6a90da', ['qty' => 2]); @@ -1136,12 +1136,12 @@ public function it_can_calculate_all_values_after_updating_from_buyable() { $cart = $this->getCartDiscount(50); $cart->add(new BuyableProduct([ - 'name' => 'First item', - 'price' => 5.00 + 'name' => 'First item', + 'price' => 5.00, ]), 2); $cart->update('027c91341fd5cf4d2579b49c4b6a90da', new BuyableProduct([ - 'name' => 'First item', + 'name' => 'First item', ])); $cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da'); @@ -1179,7 +1179,7 @@ public function can_change_tax_globally() $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'name' => 'Item' + 'name' => 'Item', ]), 2); $cart->setGlobalTax(0); @@ -1195,7 +1195,7 @@ public function can_change_discount_globally() $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'name' => 'Item' + 'name' => 'Item', ]), 2); $cart->setGlobalTax(0); @@ -1212,8 +1212,8 @@ public function cart_has_no_rounding_errors() $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'name' => 'Item', - 'price' => 10.004 + 'name' => 'Item', + 'price' => 10.004, ]), 2); $cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da'); @@ -1232,11 +1232,11 @@ public function it_can_merge_multiple_carts() $cart = $this->getCartDiscount(50); $cart->add(new BuyableProduct([ - 'name' => 'Item' + 'name' => 'Item', ]), 1); $cart->add(new BuyableProduct([ - 'id' => 2, - 'name' => 'Item 2' + 'id' => 2, + 'name' => 'Item 2', ]), 1); $cart->store('test'); @@ -1266,16 +1266,16 @@ public function it_can_merge_multiple_carts() public function it_cant_merge_non_existing_cart() { $this->artisan('migrate', [ - '--database' => 'testing' + '--database' => 'testing', ]); Event::fake(); $cart = $this->getCartDiscount(50); $cart->add(new BuyableProduct([ - 'name' => 'Item' + 'name' => 'Item', ]), 1); $cart->add(new BuyableProduct([ - 'id' => 2, - 'name' => 'Item 2' + 'id' => 2, + 'name' => 'Item 2', ]), 1); $this->assertEquals(false, $cart->merge('doesNotExist')); $this->assertEquals(2, $cart->countItems()); @@ -1286,7 +1286,7 @@ public function cart_can_calculate_all_values() { $cart = $this->getCartDiscount(50); $cart->add(new BuyableProduct([ - 'name' => 'First item' + 'name' => 'First item', ]), 1); $cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da'); $cart->setTax('027c91341fd5cf4d2579b49c4b6a90da', 19); @@ -1307,7 +1307,7 @@ public function can_access_cart_item_propertys() { $cart = $this->getCartDiscount(50); $cart->add(new BuyableProduct([ - 'name' => 'First item' + 'name' => 'First item', ]), 1); $cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da'); $this->assertEquals(50, $cartItem->discountRate); @@ -1318,7 +1318,7 @@ public function cant_access_non_existant_propertys() { $cart = $this->getCartDiscount(50); $cart->add(new BuyableProduct([ - 'name' => 'First item' + 'name' => 'First item', ]), 1); $cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da'); $this->assertEquals(null, $cartItem->doesNotExist); @@ -1330,7 +1330,7 @@ public function can_set_cart_item_discount() { $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'name' => 'First item' + 'name' => 'First item', ]), 1); $cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da'); $cart->setDiscount('027c91341fd5cf4d2579b49c4b6a90da', 50); @@ -1342,7 +1342,7 @@ public function can_set_cart_item_weight_and_calculate_total_weight() { $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'name' => 'First item', + 'name' => 'First item', 'weight' => 250, ]), 2); $cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da'); @@ -1357,7 +1357,7 @@ public function can_set_cart_item_weight_and_calculate_total_weight() public function cart_can_create_and_restore_from_instance_identifier() { $this->artisan('migrate', [ - '--database' => 'testing' + '--database' => 'testing', ]); Event::fake(); @@ -1369,7 +1369,7 @@ public function cart_can_create_and_restore_from_instance_identifier() $this->assertEquals('User1', $cart->currentInstance()); $cart->add(new BuyableProduct([ - 'name' => 'First item', + 'name' => 'First item', 'weight' => 250, ]), 2); $this->assertItemsInCart(2, $cart); @@ -1388,7 +1388,7 @@ public function cart_can_create_items_from_models_using_the_canbebought_trait() $cart = $this->getCartDiscount(50); $cart->add(new BuyableProductTrait([ - 'name' => 'First item' + 'name' => 'First item', ]), 2); $cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da'); @@ -1413,7 +1413,7 @@ public function it_does_calculate_correct_results_with_rational_qtys() $cart = $this->getCart(); $cart->add(new BuyableProductTrait([ - 'name' => 'First item' + 'name' => 'First item', ]), 0.5); $cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da'); @@ -1443,16 +1443,16 @@ public function it_does_allow_adding_cart_items_with_weight_and_options() public function it_can_merge_without_dispatching_add_events() { $this->artisan('migrate', [ - '--database' => 'testing' + '--database' => 'testing', ]); $cart = $this->getCartDiscount(50); $cart->add(new BuyableProduct([ - 'name' => 'Item' + 'name' => 'Item', ]), 1); $cart->add(new BuyableProduct([ - 'id' => 2, - 'name' => 'Item 2' + 'id' => 2, + 'name' => 'Item 2', ]), 1); $cart->store('test'); @@ -1483,11 +1483,11 @@ public function it_can_merge_dispatching_add_events() $cart = $this->getCartDiscount(50); $cart->add(new BuyableProduct([ - 'name' => 'Item' + 'name' => 'Item', ]), 1); $cart->add(new BuyableProduct([ - 'id' => 2, - 'name' => 'Item 2' + 'id' => 2, + 'name' => 'Item 2', ]), 1); $cart->store('test'); @@ -1516,18 +1516,18 @@ public function it_use_correctly_rounded_values_for_totals_and_cart_summary() $cart = $this->getCartDiscount(6); $cartItem = $cart->add(new BuyableProduct([ - 'name' => 'First item', - 'price' => 0.18929 + 'name' => 'First item', + 'price' => 0.18929, ]), 1000); $cart->add(new BuyableProduct([ - 'id' => 2, - 'name' => 'Second item', - 'price' => 4.41632 + 'id' => 2, + 'name' => 'Second item', + 'price' => 4.41632, ]), 5); $cart->add(new BuyableProduct([ - 'id' => 3, - 'name' => 'Third item', - 'price' => 0.37995 + 'id' => 3, + 'name' => 'Third item', + 'price' => 0.37995, ]), 25); $cart->setGlobalTax(22); @@ -1546,8 +1546,8 @@ public function it_use_gross_price_as_base_price() config(['cart.calculator' => GrossPrice::class]); $cartItem = $cart->add(new BuyableProduct([ - 'name' => 'First item', - 'price' => 100 + 'name' => 'First item', + 'price' => 100, ]), 2); $cart->setGlobalTax(22); @@ -1565,18 +1565,18 @@ public function it_use_gross_price_and_it_use_correctly_rounded_values_for_total $cart = $this->getCartDiscount(6); $cartItem = $cart->add(new BuyableProduct([ - 'name' => 'First item', - 'price' => 0.23093 + 'name' => 'First item', + 'price' => 0.23093, ]), 1000); $cart->add(new BuyableProduct([ - 'id' => 2, - 'name' => 'Second item', - 'price' => 5.38791 + 'id' => 2, + 'name' => 'Second item', + 'price' => 5.38791, ]), 5); $cart->add(new BuyableProduct([ - 'id' => 3, - 'name' => 'Third item', - 'price' => 0.46354 + 'id' => 3, + 'name' => 'Third item', + 'price' => 0.46354, ]), 25); $cart->setGlobalTax(22); @@ -1671,8 +1671,8 @@ public function it_can_calculate_the_total_price_of_the_items_in_cart() $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'name' => 'first item', - 'price' => 1000 + 'name' => 'first item', + 'price' => 1000, ]), $qty = 5); $this->assertEquals(5000, $cart->priceTotalFloat()); } @@ -1683,8 +1683,8 @@ public function it_can_format_the_total_price_of_the_items_in_cart() $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'name' => 'first item', - 'price' => 1000 + 'name' => 'first item', + 'price' => 1000, ]), 5); $this->assertEquals('5,000.00', $cart->priceTotal()); $this->assertEquals('5,000.0000', $cart->priceTotal(4, '.', ',')); @@ -1701,11 +1701,11 @@ public function it_can_erase_saved_cart_from_the_database() $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'name' => 'Item' + 'name' => 'Item', ]), 1); $cart->add(new BuyableProduct([ - 'id' => 2, - 'name' => 'Item 2' + 'id' => 2, + 'name' => 'Item 2', ]), 1); $cart->store($identifier = 'test'); $cart->erase($identifier); From d25ed27d89134c1cfd8a84a7f89823b842ccca8f Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 22:41:35 +0100 Subject: [PATCH 31/37] Update CartTest.php --- tests/CartTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/CartTest.php b/tests/CartTest.php index e1ddfa45..3d9fcf48 100644 --- a/tests/CartTest.php +++ b/tests/CartTest.php @@ -366,8 +366,8 @@ public function it_can_update_an_existing_item_in_the_cart_from_an_array() $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'name' => null, - 'title' => null, + 'name' => '', + 'title' => '', ])); $cart->update('027c91341fd5cf4d2579b49c4b6a90da', ['description' => 'Different description']); From 65ed1a1469797b2b49389c7252e2e5b6ea959ab6 Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 22:42:33 +0100 Subject: [PATCH 32/37] Update CartTest.php --- tests/CartTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/CartTest.php b/tests/CartTest.php index 3d9fcf48..df74864e 100644 --- a/tests/CartTest.php +++ b/tests/CartTest.php @@ -353,7 +353,7 @@ public function it_can_update_an_existing_item_in_the_cart_from_a_buyable() ])); $this->assertItemsInCart(1, $cart); - $this->assertEquals('Different description', $cart->get('027c91341fd5cf4d2579b49c4b6a90da')->name); + $this->assertEquals('Different description', $cart->get('027c91341fd5cf4d2579b49c4b6a90da')->description); Event::assertDispatched('cart.updated'); } @@ -373,7 +373,7 @@ public function it_can_update_an_existing_item_in_the_cart_from_an_array() $cart->update('027c91341fd5cf4d2579b49c4b6a90da', ['description' => 'Different description']); $this->assertItemsInCart(1, $cart); - $this->assertEquals('Different description', $cart->get('027c91341fd5cf4d2579b49c4b6a90da')->name); + $this->assertEquals('Different description', $cart->get('027c91341fd5cf4d2579b49c4b6a90da')->description); Event::assertDispatched('cart.updated'); } From 68ba7e70f419a9a81ca67e29363da137fcf38c75 Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 22:45:59 +0100 Subject: [PATCH 33/37] Update CartTest.php --- tests/CartTest.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/CartTest.php b/tests/CartTest.php index df74864e..4e3f6b4f 100644 --- a/tests/CartTest.php +++ b/tests/CartTest.php @@ -346,7 +346,9 @@ public function it_can_update_an_existing_item_in_the_cart_from_a_buyable() $cart = $this->getCart(); - $cart->add(new BuyableProduct()); + $cart->add(new BuyableProduct([ + 'description' => 'Description' + ])); $cart->update('027c91341fd5cf4d2579b49c4b6a90da', new BuyableProduct([ 'description' => 'Different description', @@ -366,8 +368,7 @@ public function it_can_update_an_existing_item_in_the_cart_from_an_array() $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'name' => '', - 'title' => '', + 'description' => 'Description' ])); $cart->update('027c91341fd5cf4d2579b49c4b6a90da', ['description' => 'Different description']); From ec9f6e477260fad8dc4c0d71b5898298f2a638a1 Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Jan 2021 22:46:44 +0100 Subject: [PATCH 34/37] Update CartTest.php --- tests/CartTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/CartTest.php b/tests/CartTest.php index 4e3f6b4f..8c876bb7 100644 --- a/tests/CartTest.php +++ b/tests/CartTest.php @@ -347,7 +347,7 @@ public function it_can_update_an_existing_item_in_the_cart_from_a_buyable() $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'description' => 'Description' + 'description' => 'Description', ])); $cart->update('027c91341fd5cf4d2579b49c4b6a90da', new BuyableProduct([ @@ -368,7 +368,7 @@ public function it_can_update_an_existing_item_in_the_cart_from_an_array() $cart = $this->getCart(); $cart->add(new BuyableProduct([ - 'description' => 'Description' + 'description' => 'Description', ])); $cart->update('027c91341fd5cf4d2579b49c4b6a90da', ['description' => 'Different description']); From a6bfcac463af80ffefa0eae146d1fae411c55743 Mon Sep 17 00:00:00 2001 From: Patrick Date: Tue, 19 Jan 2021 00:42:51 +0100 Subject: [PATCH 35/37] Update CartTest.php --- tests/CartTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/CartTest.php b/tests/CartTest.php index 8c876bb7..0f558d43 100644 --- a/tests/CartTest.php +++ b/tests/CartTest.php @@ -346,7 +346,7 @@ public function it_can_update_an_existing_item_in_the_cart_from_a_buyable() $cart = $this->getCart(); - $cart->add(new BuyableProduct([ + $cart->add(new BuyableProductTrait([ 'description' => 'Description', ])); @@ -355,7 +355,7 @@ public function it_can_update_an_existing_item_in_the_cart_from_a_buyable() ])); $this->assertItemsInCart(1, $cart); - $this->assertEquals('Different description', $cart->get('027c91341fd5cf4d2579b49c4b6a90da')->description); + $this->assertEquals('Different description', $cart->get('027c91341fd5cf4d2579b49c4b6a90da')->name); Event::assertDispatched('cart.updated'); } @@ -367,14 +367,14 @@ public function it_can_update_an_existing_item_in_the_cart_from_an_array() $cart = $this->getCart(); - $cart->add(new BuyableProduct([ + $cart->add(new BuyableProductTrait([ 'description' => 'Description', ])); - $cart->update('027c91341fd5cf4d2579b49c4b6a90da', ['description' => 'Different description']); + $cart->update('027c91341fd5cf4d2579b49c4b6a90da', ['name' => 'Different description']); $this->assertItemsInCart(1, $cart); - $this->assertEquals('Different description', $cart->get('027c91341fd5cf4d2579b49c4b6a90da')->description); + $this->assertEquals('Different description', $cart->get('027c91341fd5cf4d2579b49c4b6a90da')->name); Event::assertDispatched('cart.updated'); } From d33ad7141ce4a092fc560dc185ef66016dd7a882 Mon Sep 17 00:00:00 2001 From: Patrick Date: Tue, 19 Jan 2021 00:51:05 +0100 Subject: [PATCH 36/37] Update CartTest.php --- tests/CartTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/CartTest.php b/tests/CartTest.php index 0f558d43..b01fca57 100644 --- a/tests/CartTest.php +++ b/tests/CartTest.php @@ -350,7 +350,8 @@ public function it_can_update_an_existing_item_in_the_cart_from_a_buyable() 'description' => 'Description', ])); - $cart->update('027c91341fd5cf4d2579b49c4b6a90da', new BuyableProduct([ + $cart->update('027c91341fd5cf4d2579b49c4b6a90da', new BuyableProductTrait([ + 'name' => '', 'description' => 'Different description', ])); From 40f47e87adca0907006c372d13f095f7deda6259 Mon Sep 17 00:00:00 2001 From: Patrick Date: Tue, 19 Jan 2021 00:53:02 +0100 Subject: [PATCH 37/37] StyleCI --- tests/CartTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CartTest.php b/tests/CartTest.php index b01fca57..ced58798 100644 --- a/tests/CartTest.php +++ b/tests/CartTest.php @@ -351,7 +351,7 @@ public function it_can_update_an_existing_item_in_the_cart_from_a_buyable() ])); $cart->update('027c91341fd5cf4d2579b49c4b6a90da', new BuyableProductTrait([ - 'name' => '', + 'name' => '', 'description' => 'Different description', ]));