Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check proper state during resolving order refunded state #263

Merged
merged 1 commit into from
Mar 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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