mirror of
https://github.com/kevin-DL/LaravelShoppingcart.git
synced 2026-01-11 10:44:32 +00:00
Replaced deprecated OR operator https://getcomposer.org/doc/articles/versions.md#version-range
Added 5.8.* compatibility Updated dependency versions Added phpunit result cache to gitignore
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -2,4 +2,5 @@
|
|||||||
composer.phar
|
composer.phar
|
||||||
composer.lock
|
composer.lock
|
||||||
.DS_Store
|
.DS_Store
|
||||||
coverage.xml
|
coverage.xml
|
||||||
|
.phpunit.result.cache
|
||||||
@@ -14,14 +14,14 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"illuminate/support": "5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*",
|
"illuminate/support": "5.1.*||5.2.*||5.3.*||5.4.*||5.5.*||5.6.*||5.7.*||5.8.*",
|
||||||
"illuminate/session": "5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*",
|
"illuminate/session": "5.1.*||5.2.*||5.3.*||5.4.*||5.5.*||5.6.*||5.7.*||5.8.*",
|
||||||
"illuminate/events": "5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*"
|
"illuminate/events": "5.1.*||5.2.*||5.3.*||5.4.*||5.5.*||5.6.*||5.7.*||5.8.*"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "~5.0|~6.0|~7.0",
|
"phpunit/phpunit": "~5.0||~6.0||~7.0||~8.0",
|
||||||
"mockery/mockery": "~0.9.0",
|
"mockery/mockery": "^1.0",
|
||||||
"orchestra/testbench": "~3.1"
|
"orchestra/testbench": "^3.1"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
|||||||
10
src/Cart.php
10
src/Cart.php
@@ -149,7 +149,7 @@ class Cart
|
|||||||
|
|
||||||
$content->put($item->rowId, $item);
|
$content->put($item->rowId, $item);
|
||||||
|
|
||||||
$this->events->fire('cart.added', $item);
|
$this->events->dispatch('cart.added', $item);
|
||||||
|
|
||||||
$this->session->put($this->instance, $content);
|
$this->session->put($this->instance, $content);
|
||||||
|
|
||||||
@@ -195,7 +195,7 @@ class Cart
|
|||||||
$content->put($cartItem->rowId, $cartItem);
|
$content->put($cartItem->rowId, $cartItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->events->fire('cart.updated', $cartItem);
|
$this->events->dispatch('cart.updated', $cartItem);
|
||||||
|
|
||||||
$this->session->put($this->instance, $content);
|
$this->session->put($this->instance, $content);
|
||||||
|
|
||||||
@@ -217,7 +217,7 @@ class Cart
|
|||||||
|
|
||||||
$content->pull($cartItem->rowId);
|
$content->pull($cartItem->rowId);
|
||||||
|
|
||||||
$this->events->fire('cart.removed', $cartItem);
|
$this->events->dispatch('cart.removed', $cartItem);
|
||||||
|
|
||||||
$this->session->put($this->instance, $content);
|
$this->session->put($this->instance, $content);
|
||||||
}
|
}
|
||||||
@@ -582,7 +582,7 @@ class Cart
|
|||||||
'content' => serialize($content),
|
'content' => serialize($content),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->events->fire('cart.stored');
|
$this->events->dispatch('cart.stored');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -617,7 +617,7 @@ class Cart
|
|||||||
$content->put($cartItem->rowId, $cartItem);
|
$content->put($cartItem->rowId, $cartItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->events->fire('cart.restored');
|
$this->events->dispatch('cart.restored');
|
||||||
|
|
||||||
$this->session->put($this->instance, $content);
|
$this->session->put($this->instance, $content);
|
||||||
|
|
||||||
|
|||||||
@@ -379,6 +379,13 @@ class CartItem implements Arrayable, Jsonable
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
case 'modelFQCN':
|
||||||
|
if (isset($this->associatedModel)) {
|
||||||
|
return $this->associatedModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class CartTest extends TestCase
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function setUp()
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
@@ -215,11 +215,12 @@ class CartTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @expectedException \InvalidArgumentException
|
|
||||||
* @expectedExceptionMessage Please supply a valid identifier.
|
|
||||||
*/
|
*/
|
||||||
public function it_will_validate_the_identifier()
|
public function it_will_validate_the_identifier()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\InvalidArgumentException::class);
|
||||||
|
$this->expectExceptionMessage('Please supply a valid identifier.');
|
||||||
|
|
||||||
$cart = $this->getCart();
|
$cart = $this->getCart();
|
||||||
|
|
||||||
$cart->add(null, 'Some title', 1, 10.00);
|
$cart->add(null, 'Some title', 1, 10.00);
|
||||||
@@ -227,11 +228,12 @@ class CartTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @expectedException \InvalidArgumentException
|
|
||||||
* @expectedExceptionMessage Please supply a valid name.
|
|
||||||
*/
|
*/
|
||||||
public function it_will_validate_the_name()
|
public function it_will_validate_the_name()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\InvalidArgumentException::class);
|
||||||
|
$this->expectExceptionMessage('Please supply a valid name.');
|
||||||
|
|
||||||
$cart = $this->getCart();
|
$cart = $this->getCart();
|
||||||
|
|
||||||
$cart->add(1, null, 1, 10.00);
|
$cart->add(1, null, 1, 10.00);
|
||||||
@@ -239,11 +241,12 @@ class CartTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @expectedException \InvalidArgumentException
|
|
||||||
* @expectedExceptionMessage Please supply a valid quantity.
|
|
||||||
*/
|
*/
|
||||||
public function it_will_validate_the_quantity()
|
public function it_will_validate_the_quantity()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\InvalidArgumentException::class);
|
||||||
|
$this->expectExceptionMessage('Please supply a valid quantity.');
|
||||||
|
|
||||||
$cart = $this->getCart();
|
$cart = $this->getCart();
|
||||||
|
|
||||||
$cart->add(1, 'Some title', 'invalid', 10.00);
|
$cart->add(1, 'Some title', 'invalid', 10.00);
|
||||||
@@ -251,11 +254,12 @@ class CartTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @expectedException \InvalidArgumentException
|
|
||||||
* @expectedExceptionMessage Please supply a valid price.
|
|
||||||
*/
|
*/
|
||||||
public function it_will_validate_the_price()
|
public function it_will_validate_the_price()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\InvalidArgumentException::class);
|
||||||
|
$this->expectExceptionMessage('Please supply a valid price.');
|
||||||
|
|
||||||
$cart = $this->getCart();
|
$cart = $this->getCart();
|
||||||
|
|
||||||
$cart->add(1, 'Some title', 1, 'invalid');
|
$cart->add(1, 'Some title', 1, 'invalid');
|
||||||
@@ -343,10 +347,11 @@ class CartTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @expectedException \Gloudemans\Shoppingcart\Exceptions\InvalidRowIDException
|
|
||||||
*/
|
*/
|
||||||
public function it_will_throw_an_exception_if_a_rowid_was_not_found()
|
public function it_will_throw_an_exception_if_a_rowid_was_not_found()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Gloudemans\Shoppingcart\Exceptions\InvalidRowIDException::class);
|
||||||
|
|
||||||
$cart = $this->getCart();
|
$cart = $this->getCart();
|
||||||
|
|
||||||
$cart->add(new BuyableProduct());
|
$cart->add(new BuyableProduct());
|
||||||
@@ -608,7 +613,7 @@ class CartTest extends TestCase
|
|||||||
|
|
||||||
$cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da');
|
$cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da');
|
||||||
|
|
||||||
$this->assertContains(BuyableProduct::class, Assert::readAttribute($cartItem, 'associatedModel'));
|
$this->assertEquals(BuyableProduct::class, $cartItem->modelFQCN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
/** @test */
|
||||||
@@ -622,16 +627,17 @@ class CartTest extends TestCase
|
|||||||
|
|
||||||
$cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da');
|
$cartItem = $cart->get('027c91341fd5cf4d2579b49c4b6a90da');
|
||||||
|
|
||||||
$this->assertEquals(ProductModel::class, Assert::readAttribute($cartItem, 'associatedModel'));
|
$this->assertEquals(ProductModel::class, $cartItem->modelFQCN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @expectedException \Gloudemans\Shoppingcart\Exceptions\UnknownModelException
|
|
||||||
* @expectedExceptionMessage The supplied model SomeModel does not exist.
|
|
||||||
*/
|
*/
|
||||||
public function it_will_throw_an_exception_when_a_non_existing_model_is_being_associated()
|
public function it_will_throw_an_exception_when_a_non_existing_model_is_being_associated()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Gloudemans\Shoppingcart\Exceptions\UnknownModelException::class);
|
||||||
|
$this->expectExceptionMessage('The supplied model SomeModel does not exist.');
|
||||||
|
|
||||||
$cart = $this->getCart();
|
$cart = $this->getCart();
|
||||||
|
|
||||||
$cart->add(1, 'Test item', 1, 10.00);
|
$cart->add(1, 'Test item', 1, 10.00);
|
||||||
@@ -825,11 +831,12 @@ class CartTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @expectedException \Gloudemans\Shoppingcart\Exceptions\CartAlreadyStoredException
|
|
||||||
* @expectedExceptionMessage A cart with identifier 123 was already stored.
|
|
||||||
*/
|
*/
|
||||||
public function it_will_throw_an_exception_when_a_cart_was_already_stored_using_the_specified_identifier()
|
public function it_will_throw_an_exception_when_a_cart_was_already_stored_using_the_specified_identifier()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Gloudemans\Shoppingcart\Exceptions\CartAlreadyStoredException::class);
|
||||||
|
$this->expectExceptionMessage('A cart with identifier 123 was already stored.');
|
||||||
|
|
||||||
$this->artisan('migrate', [
|
$this->artisan('migrate', [
|
||||||
'--database' => 'testing',
|
'--database' => 'testing',
|
||||||
]);
|
]);
|
||||||
|
|||||||
Reference in New Issue
Block a user