Skip to content

Commit

Permalink
bug #263 Check proper state during resolving order refunded state (GS…
Browse files Browse the repository at this point in the history
…adee)

This PR was merged into the 1.0-dev branch.

Discussion
----------

Fixes #253

Commits
-------

f651c0f Check proper state during resolving order refunded state
  • Loading branch information
lchrusciel authored Mar 10, 2021
2 parents 4e6da18 + f651c0f commit e233082
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions spec/StateResolver/OrderFullyRefundedStateResolverSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function it_applies_refund_transition_on_order(
): void {
$orderRepository->findOneByNumber('000222')->willReturn($order);
$orderFullyRefundedTotalChecker->isOrderFullyRefunded($order)->willReturn(true);
$order->getState()->willReturn(OrderInterface::STATE_NEW);
$order->getPaymentState()->willReturn(OrderPaymentStates::STATE_PAID);

$stateMachineFactory->get($order, OrderPaymentTransitions::GRAPH)->willReturn($stateMachine);
$stateMachine->apply(OrderPaymentTransitions::TRANSITION_REFUND)->shouldBeCalled();
Expand All @@ -59,7 +59,7 @@ function it_does_nothing_if_order_state_is_fully_refunded(
): void {
$orderRepository->findOneByNumber('000222')->willReturn($order);
$orderFullyRefundedTotalChecker->isOrderFullyRefunded($order)->willReturn(true);
$order->getState()->willReturn(OrderPaymentStates::STATE_REFUNDED);
$order->getPaymentState()->willReturn(OrderPaymentStates::STATE_REFUNDED);

$stateMachineFactory->get(Argument::any())->shouldNotBeCalled();

Expand All @@ -80,7 +80,7 @@ function it_does_nothing_if_order_is_not_fully_refunded(
$this->resolve('000222');
}

function it_throws_exception_if_there_is_no_order_with_given_number(OrderRepositoryInterface $orderRepository): void
function it_throws_an_exception_if_there_is_no_order_with_given_number(OrderRepositoryInterface $orderRepository): void
{
$orderRepository->findOneByNumber('000222')->willReturn(null);

Expand Down
2 changes: 1 addition & 1 deletion src/StateResolver/OrderFullyRefundedStateResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function resolve(string $orderNumber): void

if (
!$this->orderFullyRefundedTotalChecker->isOrderFullyRefunded($order) ||
OrderPaymentStates::STATE_REFUNDED === $order->getState()
OrderPaymentStates::STATE_REFUNDED === $order->getPaymentState()
) {
return;
}
Expand Down

0 comments on commit e233082

Please sign in to comment.