mirror of
https://github.com/wearepixel/laravel-cart.git
synced 2026-11-14 22:01:48 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2196f58f01 | ||
|
|
ed4d112665 | ||
|
|
f60bf92157 | ||
|
|
a231ed8c43 | ||
|
|
599051631c | ||
|
|
b3ef4c38fc | ||
|
|
a45121ca63 | ||
|
|
5505f121c7 |
@@ -13,7 +13,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
php: ['8.1', '8.2', '8.3']
|
||||
php: ['8.2', '8.3', '8.4']
|
||||
stability: [prefer-stable]
|
||||
|
||||
steps:
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Pixel Digital Pty Ltd <hello@wearepixel.com.au>
|
||||
Copyright (c) Joel Male <joel@joelmale.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
[](https://packagist.org/packages/wearepixel/laravel-cart)
|
||||
[](https://github.com/wearepixel/laravel-cart/actions?query=workflow%3ATests+branch%3Amaster)
|
||||
[](https://packagist.org/packages/wearepixel/laravel-cart)
|
||||
[](https://packagist.org/packages/wearepixel/laravel-cart)
|
||||
[](https://packagist.org/packages/joelwmale/laravel-cart)
|
||||
[](https://github.com/joelwmale/laravel-cart/actions?query=workflow%3ATests+branch%3Amaster)
|
||||
[](https://packagist.org/packages/joelwmale/laravel-cart)
|
||||
[](https://packagist.org/packages/joelwmale/laravel-cart)
|
||||
|
||||
A Cart Implementation for Laravel.
|
||||
|
||||
Supported Laravel Versions: 9, 10, 11
|
||||
Supported Laravel Versions: 10, 11, and 12.
|
||||
|
||||
For Laravel 9.0 and below, please use version [1.0](https://github.com/joelwmale/laravel-cart/releases/tag/1.0.12)
|
||||
|
||||
## Quick Demo
|
||||
|
||||
@@ -33,14 +35,14 @@ ## Installing
|
||||
|
||||
Install the package through [Composer](http://getcomposer.org/).
|
||||
|
||||
`composer require "wearepixel/laravel-cart"`
|
||||
`composer require "joelwmale/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="Joelwmale\Cart\CartServiceProvider" --tag="config"
|
||||
```
|
||||
|
||||
### Formatting Numbers
|
||||
@@ -304,7 +306,7 @@ #### Adding a condition to the cart: **Cart::condition()**
|
||||
|
||||
```php
|
||||
// Add a single condition to the cart
|
||||
$condition = new \Wearepixel\Cart\CartCondition([
|
||||
$condition = new \Joelwmale\Cart\CartCondition([
|
||||
'name' => 'Tax: 10%',
|
||||
'type' => 'tax',
|
||||
'target' => 'subtotal', // this condition will be applied to cart's subtotal when getSubTotal() is called.
|
||||
@@ -317,7 +319,7 @@ #### Adding a condition to the cart: **Cart::condition()**
|
||||
Cart::condition($condition);
|
||||
|
||||
// Add multiple conditions
|
||||
$tax = new \Wearepixel\Cart\CartCondition([
|
||||
$tax = new \Joelwmale\Cart\CartCondition([
|
||||
'name' => 'Tax: 10%',
|
||||
'type' => 'tax',
|
||||
'target' => 'subtotal', // this condition will be applied to cart's subtotal when getSubTotal() is called.
|
||||
@@ -325,7 +327,7 @@ #### Adding a condition to the cart: **Cart::condition()**
|
||||
'order' => 2
|
||||
]);
|
||||
|
||||
$shipping = new \Wearepixel\Cart\CartCondition([
|
||||
$shipping = new \Joelwmale\Cart\CartCondition([
|
||||
'name' => 'Shipping: $15',
|
||||
'type' => 'shipping',
|
||||
'target' => 'subtotal', // this condition will be applied to cart's subtotal when getSubTotal() is called.
|
||||
@@ -340,7 +342,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 \Joelwmale\Cart\CartCondition([
|
||||
'name' => 'Express Shipping $15',
|
||||
'type' => 'shipping',
|
||||
'target' => 'total',
|
||||
@@ -532,7 +534,7 @@ ### Condition on items
|
||||
```php
|
||||
|
||||
// lets create first our condition instance
|
||||
$saleCondition = new \Wearepixel\Cart\CartCondition([
|
||||
$saleCondition = new \Joelwmale\Cart\CartCondition([
|
||||
'name' => '50% Off',
|
||||
'type' => 'tax',
|
||||
'value' => '-50%',
|
||||
@@ -552,7 +554,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 \Joelwmale\Cart\CartCondition([
|
||||
'name' => 'SALE 5%',
|
||||
'type' => 'sale',
|
||||
'value' => '-5%',
|
||||
|
||||
+12
-13
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "wearepixel/laravel-cart",
|
||||
"version": "1.0.10",
|
||||
"name": "joelwmale/laravel-cart",
|
||||
"version": "1.1.0",
|
||||
"description": "A cart implementation for Laravel",
|
||||
"keywords": [
|
||||
"laravel",
|
||||
@@ -15,34 +15,33 @@
|
||||
},
|
||||
{
|
||||
"name": "Joel Male",
|
||||
"email": "joel@wearepixel.com.au"
|
||||
"email": "joel@joelmale.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=8.1",
|
||||
"illuminate/support": "^9.0|^10.0|^11.0",
|
||||
"illuminate/validation": "^9.0|^10.0|^11.0",
|
||||
"illuminate/translation": "^9.0|^10.0|^11.0"
|
||||
"php": ">=8.2",
|
||||
"illuminate/support": "^10.0|^11.0|^12.0",
|
||||
"illuminate/validation": "^10.0|^11.0|^12.0",
|
||||
"illuminate/translation": "^10.0|^11.0|^12.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "^1.4.2",
|
||||
"laravel/pint": "^1.17",
|
||||
"pestphp/pest": "2.35.1",
|
||||
"larapack/dd": "1.1"
|
||||
"laravel/pint": "^1.21",
|
||||
"pestphp/pest": "^3.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Wearepixel\\Cart\\": "src/"
|
||||
"Joelwmale\\Cart\\": "src/"
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Wearepixel\\Cart\\CartServiceProvider"
|
||||
"Joelwmale\\Cart\\CartServiceProvider"
|
||||
],
|
||||
"aliases": {
|
||||
"Cart": "Wearepixel\\Cart\\Facades\\CartFacade"
|
||||
"Cart": "Joelwmale\\Cart\\Facades\\CartFacade"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Generated
+809
-871
File diff suppressed because it is too large
Load Diff
+17
-16
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Wearepixel\Cart;
|
||||
namespace Joelwmale\Cart;
|
||||
|
||||
use Wearepixel\Cart\Helpers\Helpers;
|
||||
use Wearepixel\Cart\Validators\CartItemValidator;
|
||||
use Wearepixel\Cart\Exceptions\InvalidItemException;
|
||||
use Wearepixel\Cart\Exceptions\UnknownModelException;
|
||||
use Wearepixel\Cart\Exceptions\InvalidConditionException;
|
||||
use Joelwmale\Cart\Helpers\Helpers;
|
||||
use Joelwmale\Cart\Validators\CartItemValidator;
|
||||
use Joelwmale\Cart\Exceptions\InvalidItemException;
|
||||
use Joelwmale\Cart\Exceptions\UnknownModelException;
|
||||
use Joelwmale\Cart\Exceptions\InvalidConditionException;
|
||||
|
||||
class Cart
|
||||
{
|
||||
@@ -227,11 +227,11 @@ public function setConfig($config)
|
||||
public function addItemCondition($productId, $itemCondition)
|
||||
{
|
||||
if ($product = $this->get($productId)) {
|
||||
$conditionInstance = '\\Wearepixel\\Cart\\CartCondition';
|
||||
$conditionInstance = '\\Joelwmale\\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 Joelwmale\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'];
|
||||
@@ -313,7 +313,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 \'Joelwmale\Cart\CartCondition\'');
|
||||
}
|
||||
|
||||
$conditions = $this->getConditions();
|
||||
@@ -448,7 +448,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 = 'Joelwmale\\Cart\\CartCondition';
|
||||
|
||||
if ($item['conditions'] instanceof $conditionInstance) {
|
||||
if ($tempConditionsHolder->getName() == $conditionName) {
|
||||
@@ -458,9 +458,6 @@ public function removeItemCondition($itemId, $conditionName)
|
||||
}
|
||||
}
|
||||
|
||||
// reset indexes
|
||||
$item['conditions'] = array_values($item['conditions']);
|
||||
|
||||
$this->update($itemId, [
|
||||
'conditions' => $item['conditions'],
|
||||
]);
|
||||
@@ -601,10 +598,14 @@ public function getTotal(): int|float
|
||||
return Helpers::formatValue($subTotal, $this->config['format_numbers'], $this->config);
|
||||
}
|
||||
|
||||
$conditionsForTotal->each(function (CartCondition $condition) use ($subTotal, &$total) {
|
||||
$toBeCalculated = $total > 0 ? $total : $subTotal;
|
||||
$index = 0;
|
||||
|
||||
$conditionsForTotal->each(function (CartCondition $condition) use ($subTotal, &$total, &$index) {
|
||||
$toBeCalculated = ($index > 0) ? $total : $subTotal;
|
||||
|
||||
$total = $condition->applyCondition($toBeCalculated);
|
||||
|
||||
$index++;
|
||||
});
|
||||
|
||||
return Helpers::formatValue($total, $this->config['format_numbers'], $this->config);
|
||||
@@ -763,7 +764,7 @@ protected function itemHasConditions($item)
|
||||
return count($item['conditions']) > 0;
|
||||
}
|
||||
|
||||
$conditionInstance = 'Wearepixel\\Cart\\CartCondition';
|
||||
$conditionInstance = 'Joelwmale\\Cart\\CartCondition';
|
||||
|
||||
if ($item['conditions'] instanceof $conditionInstance) {
|
||||
return true;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Wearepixel\Cart;
|
||||
namespace Joelwmale\Cart;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Wearepixel\Cart;
|
||||
namespace Joelwmale\Cart;
|
||||
|
||||
use Wearepixel\Cart\Helpers\Helpers;
|
||||
use Wearepixel\Cart\Validators\CartConditionValidator;
|
||||
use Wearepixel\Cart\Exceptions\InvalidConditionException;
|
||||
use Joelwmale\Cart\Helpers\Helpers;
|
||||
use Joelwmale\Cart\Validators\CartConditionValidator;
|
||||
use Joelwmale\Cart\Exceptions\InvalidConditionException;
|
||||
|
||||
class CartCondition
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Wearepixel\Cart;
|
||||
namespace Joelwmale\Cart;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Wearepixel\Cart;
|
||||
namespace Joelwmale\Cart;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Wearepixel\Cart\Exceptions;
|
||||
namespace Joelwmale\Cart\Exceptions;
|
||||
|
||||
class InvalidConditionException extends \Exception {}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Wearepixel\Cart\Exceptions;
|
||||
namespace Joelwmale\Cart\Exceptions;
|
||||
|
||||
class InvalidItemException extends \Exception {}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Wearepixel\Cart\Exceptions;
|
||||
namespace Joelwmale\Cart\Exceptions;
|
||||
|
||||
class UnknownModelException extends \Exception {}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Wearepixel\Cart\Facades;
|
||||
namespace Joelwmale\Cart\Facades;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Wearepixel\Cart\Helpers;
|
||||
namespace Joelwmale\Cart\Helpers;
|
||||
|
||||
class Helpers
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Wearepixel\Cart;
|
||||
namespace Joelwmale\Cart;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Wearepixel\Cart;
|
||||
namespace Joelwmale\Cart;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Wearepixel\Cart\Helpers\Helpers;
|
||||
use Joelwmale\Cart\Helpers\Helpers;
|
||||
|
||||
class ItemCollection extends Collection
|
||||
{
|
||||
@@ -72,7 +72,7 @@ public function hasConditions()
|
||||
if (is_array($this['conditions'])) {
|
||||
return count($this['conditions']) > 0;
|
||||
}
|
||||
$conditionInstance = 'Wearepixel\\Cart\\CartCondition';
|
||||
$conditionInstance = 'Joelwmale\\Cart\\CartCondition';
|
||||
if ($this['conditions'] instanceof $conditionInstance) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Wearepixel\Cart\Validators;
|
||||
namespace Joelwmale\Cart\Validators;
|
||||
|
||||
class CartConditionValidator extends Validator {}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Wearepixel\Cart\Validators;
|
||||
namespace Joelwmale\Cart\Validators;
|
||||
|
||||
class CartItemValidator extends Validator {}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Wearepixel\Cart\Validators;
|
||||
namespace Joelwmale\Cart\Validators;
|
||||
|
||||
use Illuminate\Validation\Factory;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Wearepixel\Cart\Tests\Helpers;
|
||||
namespace Joelwmale\Cart\Tests\Helpers;
|
||||
|
||||
use Illuminate\Contracts\Database\ModelIdentifier;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Wearepixel\Cart\Tests\Helpers;
|
||||
namespace Joelwmale\Cart\Tests\Helpers;
|
||||
|
||||
class SessionMock
|
||||
{
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
use Wearepixel\Cart\Cart;
|
||||
use Wearepixel\Cart\CartCondition;
|
||||
use Wearepixel\Cart\CartConditionCollection;
|
||||
use Wearepixel\Cart\Tests\Helpers\SessionMock;
|
||||
use Joelwmale\Cart\Cart;
|
||||
use Joelwmale\Cart\CartCondition;
|
||||
use Joelwmale\Cart\CartConditionCollection;
|
||||
use Joelwmale\Cart\Tests\Helpers\SessionMock;
|
||||
|
||||
beforeEach(function () {
|
||||
$events = Mockery::mock('Illuminate\Contracts\Events\Dispatcher');
|
||||
@@ -1310,7 +1310,7 @@
|
||||
|
||||
// now we should have only 1 condition left on that item
|
||||
expect($this->cart->get(1)['conditions'])->toHaveCount(1, 'Item should have one condition left');
|
||||
expect($this->cart->get(1)['conditions'][0]->getName())->toEqual('Mother\'s Day Gift Pack');
|
||||
expect($this->cart->get(1)['conditions'][1]->getName())->toEqual('Mother\'s Day Gift Pack');
|
||||
});
|
||||
|
||||
test('can add item with multiple negative item conditions', function () {
|
||||
|
||||
+10
-10
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
use Wearepixel\Cart\Cart;
|
||||
use Wearepixel\Cart\Tests\Helpers\MockProduct;
|
||||
use Wearepixel\Cart\Tests\Helpers\SessionMock;
|
||||
use Joelwmale\Cart\Cart;
|
||||
use Joelwmale\Cart\Tests\Helpers\MockProduct;
|
||||
use Joelwmale\Cart\Tests\Helpers\SessionMock;
|
||||
|
||||
beforeEach(function () {
|
||||
$events = Mockery::mock('Illuminate\Contracts\Events\Dispatcher');
|
||||
@@ -149,7 +149,7 @@
|
||||
|
||||
$item = $this->cart->get(1);
|
||||
|
||||
expect($item->attributes)->toBeInstanceOf('Wearepixel\\Cart\\ItemAttributeCollection');
|
||||
expect($item->attributes)->toBeInstanceOf('Joelwmale\\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('Joelwmale\\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('Joelwmale\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('Joelwmale\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('Joelwmale\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('Joelwmale\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('Joelwmale\Cart\Tests\Helpers\MockProduct');
|
||||
}
|
||||
|
||||
expect($this->cart->isEmpty())->toBeFalse('Cart should not be empty');
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Wearepixel\Cart\Cart;
|
||||
use Wearepixel\Cart\Tests\Helpers\SessionMock;
|
||||
use Joelwmale\Cart\Cart;
|
||||
use Joelwmale\Cart\Tests\Helpers\SessionMock;
|
||||
|
||||
beforeEach(function () {});
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Wearepixel\Cart\Cart;
|
||||
use Wearepixel\Cart\Tests\Helpers\SessionMock;
|
||||
use Joelwmale\Cart\Cart;
|
||||
use Joelwmale\Cart\Tests\Helpers\SessionMock;
|
||||
|
||||
beforeEach(function () {
|
||||
$events = Mockery::mock('Illuminate\Contracts\Events\Dispatcher');
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
use Wearepixel\Cart\Cart;
|
||||
use Wearepixel\Cart\CartCondition;
|
||||
use Wearepixel\Cart\Tests\Helpers\MockProduct;
|
||||
use Wearepixel\Cart\Tests\Helpers\SessionMock;
|
||||
use Joelwmale\Cart\Cart;
|
||||
use Joelwmale\Cart\CartCondition;
|
||||
use Joelwmale\Cart\Tests\Helpers\MockProduct;
|
||||
use Joelwmale\Cart\Tests\Helpers\SessionMock;
|
||||
|
||||
beforeEach(function () {
|
||||
$events = Mockery::mock('Illuminate\Contracts\Events\Dispatcher');
|
||||
@@ -47,7 +47,7 @@
|
||||
});
|
||||
|
||||
test('item get conditions with conditions', function () {
|
||||
$itemCondition1 = new \Wearepixel\Cart\CartCondition([
|
||||
$itemCondition1 = new \Joelwmale\Cart\CartCondition([
|
||||
'name' => '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(\Joelwmale\Cart\Exceptions\UnknownModelException::class);
|
||||
$this->expectExceptionMessage('The supplied model SomeModel does not exist.');
|
||||
|
||||
$this->cart->add(1, 'Test item', 1, 10.00)->associate('SomeModel');
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Wearepixel\Cart\Cart;
|
||||
use Wearepixel\Cart\Tests\Helpers\SessionMock;
|
||||
use Joelwmale\Cart\Cart;
|
||||
use Joelwmale\Cart\Tests\Helpers\SessionMock;
|
||||
|
||||
beforeEach(function () {
|
||||
$events = Mockery::mock('Illuminate\Contracts\Events\Dispatcher');
|
||||
|
||||
Reference in New Issue
Block a user