From 4a312a37e23c1fc4cf2a799c8bc27dcda8914d30 Mon Sep 17 00:00:00 2001 From: Joel Male Date: Fri, 30 Aug 2024 09:44:40 +1000 Subject: [PATCH] 1.0.7 --- README.md | 16 +++++++------- composer.json | 10 ++++----- src/Cart.php | 22 ++++++++++---------- src/CartCollection.php | 2 +- src/CartCondition.php | 8 +++---- src/CartConditionCollection.php | 2 +- src/CartServiceProvider.php | 2 +- src/Exceptions/InvalidConditionException.php | 2 +- src/Exceptions/InvalidItemException.php | 2 +- src/Exceptions/UnknownModelException.php | 2 +- src/Facades/CartFacade.php | 2 +- src/Helpers/Helpers.php | 2 +- src/ItemAttributeCollection.php | 2 +- src/ItemCollection.php | 6 +++--- src/Validators/CartConditionValidator.php | 2 +- src/Validators/CartItemValidator.php | 2 +- src/Validators/Validator.php | 2 +- tests/Helpers/MockProduct.php | 2 +- tests/Helpers/SessionMock.php | 2 +- tests/Unit/CartConditionsTest.php | 6 +++--- tests/Unit/CartTest.php | 20 +++++++++--------- tests/Unit/CartTestEventsTest.php | 4 ++-- tests/Unit/CartTestMultipleInstancesTest.php | 4 ++-- tests/Unit/ItemTest.php | 12 +++++------ tests/Unit/ItemTestOtherFormatTest.php | 4 ++-- 25 files changed, 70 insertions(+), 70 deletions(-) diff --git a/README.md b/README.md index f19bf5d..5e2bcd2 100644 --- a/README.md +++ b/README.md @@ -33,14 +33,14 @@ ## Installing Install the package through [Composer](http://getcomposer.org/). -`composer require "wearepixel/laravel-cart"` +`composer require "pixeldigital/laravel-cart"` ## Configuration You can publish the configuration file to customize various options. ```php -php artisan vendor:publish --provider="Wearepixel\Cart\CartServiceProvider" --tag="config" +php artisan vendor:publish --provider="Pixeldigital\Cart\CartServiceProvider" --tag="config" ``` ### Formatting Numbers @@ -302,7 +302,7 @@ #### Adding a condition to the cart: **Cart::condition()** ```php // Add a single condition to the cart -$condition = new \Wearepixel\Cart\CartCondition([ +$condition = new \Pixeldigital\Cart\CartCondition([ 'name' => 'Tax: 10%', 'type' => 'tax', 'target' => 'subtotal', // this condition will be applied to cart's subtotal when getSubTotal() is called. @@ -315,7 +315,7 @@ #### Adding a condition to the cart: **Cart::condition()** Cart::condition($condition); // Add multiple conditions -$tax = new \Wearepixel\Cart\CartCondition([ +$tax = new \Pixeldigital\Cart\CartCondition([ 'name' => 'Tax: 10%', 'type' => 'tax', 'target' => 'subtotal', // this condition will be applied to cart's subtotal when getSubTotal() is called. @@ -323,7 +323,7 @@ #### Adding a condition to the cart: **Cart::condition()** 'order' => 2 ]); -$shipping = new \Wearepixel\Cart\CartCondition([ +$shipping = new \Pixeldigital\Cart\CartCondition([ 'name' => 'Shipping: $15', 'type' => 'shipping', 'target' => 'subtotal', // this condition will be applied to cart's subtotal when getSubTotal() is called. @@ -338,7 +338,7 @@ #### Adding a condition to the cart: **Cart::condition()** Cart::condition([$tax, $shipping]); // add condition to only apply on totals, not in subtotal -$shipping = new \Wearepixel\Cart\CartCondition([ +$shipping = new \Pixeldigital\Cart\CartCondition([ 'name' => 'Express Shipping $15', 'type' => 'shipping', 'target' => 'total', @@ -429,7 +429,7 @@ ### Condition on items ```php // lets create first our condition instance -$saleCondition = new \Wearepixel\Cart\CartCondition([ +$saleCondition = new \Pixeldigital\Cart\CartCondition([ 'name' => '50% Off', 'type' => 'tax', 'value' => '-50%', @@ -449,7 +449,7 @@ ### Condition on items Cart::add($product); // You can of course also do multiple conditions on an item -$saleCondition = new \Wearepixel\Cart\CartCondition([ +$saleCondition = new \Pixeldigital\Cart\CartCondition([ 'name' => 'SALE 5%', 'type' => 'sale', 'value' => '-5%', diff --git a/composer.json b/composer.json index 301e78d..b319367 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { - "name": "wearepixel/laravel-cart", - "version": "1.0.6", + "name": "pixeldigital/laravel-cart", + "version": "1.0.7", "description": "A cart implementation for Laravel", "keywords": [ "laravel", @@ -32,17 +32,17 @@ }, "autoload": { "psr-4": { - "Wearepixel\\Cart\\": "src/" + "Pixeldigital\\Cart\\": "src/" } }, "minimum-stability": "dev", "extra": { "laravel": { "providers": [ - "Wearepixel\\Cart\\CartServiceProvider" + "Pixeldigital\\Cart\\CartServiceProvider" ], "aliases": { - "Cart": "Wearepixel\\Cart\\Facades\\CartFacade" + "Cart": "Pixeldigital\\Cart\\Facades\\CartFacade" } } }, diff --git a/src/Cart.php b/src/Cart.php index e6ece4f..2f8f65a 100644 --- a/src/Cart.php +++ b/src/Cart.php @@ -1,12 +1,12 @@ get($productId)) { - $conditionInstance = '\\Wearepixel\\Cart\\CartCondition'; + $conditionInstance = '\\Pixeldigital\\Cart\\CartCondition'; if ($itemCondition instanceof $conditionInstance) { // we need to copy first to a temporary variable to hold the conditions - // to avoid hitting this error "Indirect modification of overloaded element of Wearepixel\Cart\ItemCollection has no effect" + // to avoid hitting this error "Indirect modification of overloaded element of Pixeldigital\Cart\ItemCollection has no effect" // this is due to laravel Collection instance that implements Array Access // // see link for more info: http://stackoverflow.com/questions/20053269/indirect-modification-of-overloaded-element-of-splfixedarray-has-no-effect $itemConditionTempHolder = $product['conditions']; @@ -353,7 +353,7 @@ public function condition(array|CartCondition $condition): self } if (! $condition instanceof CartCondition) { - throw new InvalidConditionException('Argument 1 must be an instance of \'Wearepixel\Cart\CartCondition\''); + throw new InvalidConditionException('Argument 1 must be an instance of \'Pixeldigital\Cart\CartCondition\''); } $conditions = $this->getConditions(); @@ -479,7 +479,7 @@ public function removeItemCondition($itemId, $conditionName) // on the given condition name the user wants to remove, if so, // lets just make $item['conditions'] an empty array as there's just 1 condition on it anyway else { - $conditionInstance = 'Wearepixel\\Cart\\CartCondition'; + $conditionInstance = 'Pixeldigital\\Cart\\CartCondition'; if ($item['conditions'] instanceof $conditionInstance) { if ($tempConditionsHolder->getName() == $conditionName) { @@ -776,7 +776,7 @@ protected function itemHasConditions($item) return count($item['conditions']) > 0; } - $conditionInstance = 'Wearepixel\\Cart\\CartCondition'; + $conditionInstance = 'Pixeldigital\\Cart\\CartCondition'; if ($item['conditions'] instanceof $conditionInstance) { return true; diff --git a/src/CartCollection.php b/src/CartCollection.php index 18ee559..76dcaeb 100644 --- a/src/CartCollection.php +++ b/src/CartCollection.php @@ -1,6 +1,6 @@ 0; } - $conditionInstance = 'Wearepixel\\Cart\\CartCondition'; + $conditionInstance = 'Pixeldigital\\Cart\\CartCondition'; if ($this['conditions'] instanceof $conditionInstance) { return true; } diff --git a/src/Validators/CartConditionValidator.php b/src/Validators/CartConditionValidator.php index 8cb4b8d..f9ce815 100644 --- a/src/Validators/CartConditionValidator.php +++ b/src/Validators/CartConditionValidator.php @@ -1,5 +1,5 @@ cart->get(1); - expect($item->attributes)->toBeInstanceOf('Wearepixel\\Cart\\ItemAttributeCollection'); + expect($item->attributes)->toBeInstanceOf('Pixeldigital\\Cart\\ItemAttributeCollection'); // now lets update the item with its new attributes // when we get that item from cart, it should still be an instance of ItemAttributeCollection @@ -162,7 +162,7 @@ $this->cart->update(1, $updatedItem); - expect($item->attributes)->toBeInstanceOf('Wearepixel\\Cart\\ItemAttributeCollection'); + expect($item->attributes)->toBeInstanceOf('Pixeldigital\\Cart\\ItemAttributeCollection'); }); test('item orders are preserved by the order they are added', function () { @@ -298,19 +298,19 @@ }); test('should throw an exception when no quantity is provided', function () { - $this->expectException('Wearepixel\Cart\Exceptions\InvalidItemException'); + $this->expectException('Pixeldigital\Cart\Exceptions\InvalidItemException'); $this->expectExceptionMessage('The quantity must be at least 0.1.'); $this->cart->add(455, 'Sample Item', 100.99, 0, []); }); test('should throw an exception when no id is provided', function () { - $this->expectException('Wearepixel\Cart\Exceptions\InvalidItemException'); + $this->expectException('Pixeldigital\Cart\Exceptions\InvalidItemException'); $this->expectExceptionMessage('The id field is required.'); $this->cart->add('', 'Sample Item', 100.99, 2, []); }); test('should throw an exception when no name is provided', function () { - $this->expectException('Wearepixel\Cart\Exceptions\InvalidItemException'); + $this->expectException('Pixeldigital\Cart\Exceptions\InvalidItemException'); $this->expectExceptionMessage('The name field is required.'); $this->cart->add(523, '', 100.99, 2, []); }); @@ -646,7 +646,7 @@ expect($this->cart->getContent()->count())->toEqual(1, 'Cart should have 1 item on it'); expect($this->cart->getContent()->first()['id'])->toEqual(456, 'The first content must have ID of 456'); expect($this->cart->getContent()->first()['name'])->toEqual('Sample Item', 'The first content must have name of "Sample Item"'); - expect($addedItem->model)->toBeInstanceOf('Wearepixel\Cart\Tests\Helpers\MockProduct'); + expect($addedItem->model)->toBeInstanceOf('Pixeldigital\Cart\Tests\Helpers\MockProduct'); }); test('cart can add items with multidimensional array with associated model', function () { @@ -681,7 +681,7 @@ $content = $this->cart->getContent(); foreach ($content as $item) { - expect($item->model)->toBeInstanceOf('Wearepixel\Cart\Tests\Helpers\MockProduct'); + expect($item->model)->toBeInstanceOf('Pixeldigital\Cart\Tests\Helpers\MockProduct'); } expect($this->cart->isEmpty())->toBeFalse('Cart should not be empty'); diff --git a/tests/Unit/CartTestEventsTest.php b/tests/Unit/CartTestEventsTest.php index d098ea0..52a6d85 100644 --- a/tests/Unit/CartTestEventsTest.php +++ b/tests/Unit/CartTestEventsTest.php @@ -1,7 +1,7 @@ 'SALE 5%', 'type' => 'sale', 'target' => 'item', @@ -77,7 +77,7 @@ }); test('it will throw an exception when a non existing model is being associated', function () { - $this->expectException(\Wearepixel\Cart\Exceptions\UnknownModelException::class); + $this->expectException(\Pixeldigital\Cart\Exceptions\UnknownModelException::class); $this->expectExceptionMessage('The supplied model SomeModel does not exist.'); $this->cart->add(1, 'Test item', 1, 10.00)->associate('SomeModel'); diff --git a/tests/Unit/ItemTestOtherFormatTest.php b/tests/Unit/ItemTestOtherFormatTest.php index 928e8af..d9dab8a 100644 --- a/tests/Unit/ItemTestOtherFormatTest.php +++ b/tests/Unit/ItemTestOtherFormatTest.php @@ -1,7 +1,7 @@