Skip to content

Commit

Permalink
minor #16334 [Inventory] Extend \RuntimeException by inventory except…
Browse files Browse the repository at this point in the history
…ions (GSadee)

This PR was merged into the 2.0 branch.

Discussion
----------

| Q               | A
|-----------------|-----
| Branch?         | 2.0
| Bug fix?        | no
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no<!-- don't forget to update the UPGRADE-*.md file -->
| Related tickets | after #16307, related to #16333
| License         | MIT

<!--
 - Bug fixes must be submitted against the 1.12 or 1.13 branches
 - Features and deprecations must be submitted against the 1.14 branch
 - Features, removing deprecations and BC breaks must be submitted against the 2.0 branch
 - Make sure that the correct base branch is set

 To be sure you are not breaking any Backward Compatibilities, check the documentation:
 https://docs.sylius.com/en/latest/book/organization/backward-compatibility-promise.html
-->


Commits
-------
  [Inventory] Extend \RuntimeException by NotEnoughUnitsOnHandException and NotEnoughUnitsOnHoldException exceptions
  [Inventory] Adjust OrderInventoryOperator spec for exceptions changes
  • Loading branch information
NoResponseMate committed Jun 3, 2024
2 parents c37b118 + 997dd06 commit bbe8be1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Sylius\Component\Core\Inventory\Exception;

final class NotEnoughUnitsOnHandException extends \InvalidArgumentException
final class NotEnoughUnitsOnHandException extends \RuntimeException
{
public function __construct(string $variantName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Sylius\Component\Core\Inventory\Exception;

final class NotEnoughUnitsOnHoldException extends \InvalidArgumentException
final class NotEnoughUnitsOnHoldException extends \RuntimeException
{
public function __construct(string $variantName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
use Doctrine\Common\Collections\ArrayCollection;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Sylius\Component\Core\Inventory\Exception\NotEnoughUnitsOnHandException;
use Sylius\Component\Core\Inventory\Exception\NotEnoughUnitsOnHoldException;
use Sylius\Component\Core\Inventory\Operator\OrderInventoryOperatorInterface;
use Sylius\Component\Core\Model\OrderInterface;
use Sylius\Component\Core\Model\OrderItemInterface;
Expand Down Expand Up @@ -123,7 +125,7 @@ function it_increases_on_hand_during_cancelling_of_a_refunded_order(
$this->cancel($order);
}

function it_throws_an_invalid_argument_exception_if_difference_between_on_hold_and_item_quantity_is_smaller_than_zero_during_cancelling(
function it_throws_a_not_enough_units_on_hold_exception_if_difference_between_on_hold_and_item_quantity_is_smaller_than_zero_during_cancelling(
OrderInterface $order,
OrderItemInterface $orderItem,
ProductVariantInterface $variant,
Expand All @@ -139,10 +141,10 @@ function it_throws_an_invalid_argument_exception_if_difference_between_on_hold_a

$variant->getName()->willReturn('Red Skirt');

$this->shouldThrow(\InvalidArgumentException::class)->during('cancel', [$order]);
$this->shouldThrow(NotEnoughUnitsOnHoldException::class)->during('cancel', [$order]);
}

function it_throws_an_invalid_argument_exception_if_difference_between_on_hold_and_item_quantity_is_smaller_than_zero_during_selling(
function it_throws_a_not_enough_units_on_hold_exception_if_difference_between_on_hold_and_item_quantity_is_smaller_than_zero_during_selling(
OrderInterface $order,
OrderItemInterface $orderItem,
ProductVariantInterface $variant,
Expand All @@ -156,10 +158,10 @@ function it_throws_an_invalid_argument_exception_if_difference_between_on_hold_a

$variant->getName()->willReturn('Red Skirt');

$this->shouldThrow(\InvalidArgumentException::class)->during('sell', [$order]);
$this->shouldThrow(NotEnoughUnitsOnHoldException::class)->during('sell', [$order]);
}

function it_throws_an_invalid_argument_exception_if_difference_between_on_hand_and_item_quantity_is_smaller_than_zero_during_selling(
function it_throws_a_not_enough_units_on_hand_exception_if_difference_between_on_hand_and_item_quantity_is_smaller_than_zero_during_selling(
OrderInterface $order,
OrderItemInterface $orderItem,
ProductVariantInterface $variant,
Expand All @@ -174,7 +176,7 @@ function it_throws_an_invalid_argument_exception_if_difference_between_on_hand_a

$variant->getName()->willReturn('Red Skirt');

$this->shouldThrow(\InvalidArgumentException::class)->during('sell', [$order]);
$this->shouldThrow(NotEnoughUnitsOnHandException::class)->during('sell', [$order]);
}

function it_does_nothing_if_variant_is_not_tracked_during_cancelling(
Expand Down

0 comments on commit bbe8be1

Please sign in to comment.