Skip to content

Commit

Permalink
Applies PR Crinsane#550 from upstream for Laravel 5.8 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
camilopayan committed Aug 16, 2019
1 parent f460ab7 commit 9679e49
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 25 deletions.
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "gloudemans/shoppingcart",
"name": "mpenterprises/shoppingcart",
"description": "Laravel Shoppingcart",
"keywords": ["laravel", "shoppingcart"],
"license": "MIT",
Expand All @@ -10,13 +10,13 @@
}
],
"require": {
"illuminate/support": "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.*",
"illuminate/events": "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.* || 5.8.*",
"illuminate/events": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.*|| 5.6.* || 5.7.* || 5.8.*"
},
"require-dev": {
"phpunit/phpunit": "~5.0 || ~6.0 || ~7.0",
"mockery/mockery": "~0.9.0",
"phpunit/phpunit": "~5.0 || ~6.0 || ~7.0 || ~8.0",
"mockery/mockery": "~0.9.0 || ^1.0",
"orchestra/testbench": "~3.1"
},
"autoload": {
Expand Down
10 changes: 5 additions & 5 deletions src/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function add($id, $name = null, $qty = null, $price = null, array $option

$content->put($cartItem->rowId, $cartItem);

$this->events->fire('cart.added', $cartItem);
$this->events->dispatch('cart.added', $cartItem);

$this->session->put($this->instance, $content);

Expand Down Expand Up @@ -148,7 +148,7 @@ public function update($rowId, $qty)
$content->put($cartItem->rowId, $cartItem);
}

$this->events->fire('cart.updated', $cartItem);
$this->events->dispatch('cart.updated', $cartItem);

$this->session->put($this->instance, $content);

Expand All @@ -169,7 +169,7 @@ public function remove($rowId)

$content->pull($cartItem->rowId);

$this->events->fire('cart.removed', $cartItem);
$this->events->dispatch('cart.removed', $cartItem);

$this->session->put($this->instance, $content);
}
Expand Down Expand Up @@ -360,7 +360,7 @@ public function store($identifier)
'content' => serialize($content)
]);

$this->events->fire('cart.stored');
$this->events->dispatch('cart.stored');
}

/**
Expand Down Expand Up @@ -390,7 +390,7 @@ public function restore($identifier)
$content->put($cartItem->rowId, $cartItem);
}

$this->events->fire('cart.restored');
$this->events->dispatch('cart.restored');

$this->session->put($this->instance, $content);

Expand Down
35 changes: 21 additions & 14 deletions tests/CartTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected function getEnvironmentSetUp($app)
*
* @return void
*/
protected function setUp()
protected function setUp():void
{
parent::setUp();

Expand Down Expand Up @@ -212,47 +212,51 @@ public function it_can_add_an_item_with_options()

/**
* @test
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Please supply a valid identifier.
*/
public function it_will_validate_the_identifier()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Please supply a valid identifier.');

$cart = $this->getCart();

$cart->add(null, 'Some title', 1, 10.00);
}

/**
* @test
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Please supply a valid name.
*/
public function it_will_validate_the_name()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Please supply a valid name.');

$cart = $this->getCart();

$cart->add(1, null, 1, 10.00);
}

/**
* @test
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Please supply a valid quantity.
*/
public function it_will_validate_the_quantity()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Please supply a valid quantity.');

$cart = $this->getCart();

$cart->add(1, 'Some title', 'invalid', 10.00);
}

/**
* @test
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Please supply a valid price.
*/
public function it_will_validate_the_price()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Please supply a valid price.');

$cart = $this->getCart();

$cart->add(1, 'Some title', 1, 'invalid');
Expand Down Expand Up @@ -340,10 +344,11 @@ public function it_can_update_an_existing_item_in_the_cart_from_an_array()

/**
* @test
* @expectedException \Gloudemans\Shoppingcart\Exceptions\InvalidRowIDException
*/
public function it_will_throw_an_exception_if_a_rowid_was_not_found()
{
$this->expectException(\Gloudemans\Shoppingcart\Exceptions\InvalidRowIDException::class);

$cart = $this->getCart();

$cart->add(new BuyableProduct);
Expand Down Expand Up @@ -620,11 +625,12 @@ public function it_can_associate_the_cart_item_with_a_model()

/**
* @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()
{
$this->expectException(\Gloudemans\Shoppingcart\Exceptions\UnknownModelException::class);
$this->expectExceptionMessage('The supplied model SomeModel does not exist.');

$cart = $this->getCart();

$cart->add(1, 'Test item', 1, 10.00);
Expand Down Expand Up @@ -815,11 +821,12 @@ public function it_can_store_the_cart_in_a_database()

/**
* @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()
{
$this->expectException(\Gloudemans\Shoppingcart\Exceptions\CartAlreadyStoredException::class);
$this->expectExceptionMessage('A cart with identifier 123 was already stored.');

$this->artisan('migrate', [
'--database' => 'testing',
]);
Expand Down

0 comments on commit 9679e49

Please sign in to comment.