Skip to content

Commit

Permalink
Fix phpspec
Browse files Browse the repository at this point in the history
  • Loading branch information
Prometee committed Sep 26, 2024
1 parent 3d5e397 commit a01be0c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 41 deletions.
23 changes: 5 additions & 18 deletions spec/StateMachine/CancelOrderProcessorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,50 +19,37 @@ public function let(MessageBusInterface $commandBus): void {

public function it_is_invokable_when_it_is_new(
PaymentInterface $payment,
TransitionEvent $event,
MessageBusInterface $commandBus,
): void {
$event->getState()->willReturn(PaymentInterface::STATE_NEW);

$payment->getId()->willReturn(1);

$command = new CancelPayment(1);
$commandBus->dispatch($command)->willReturn(new Envelope($command));

$this->__invoke($payment);
$this->__invoke($payment, PaymentInterface::STATE_NEW);
}

public function it_is_invokable_when_is_authorized(
PaymentInterface $payment,
TransitionEvent $event,
MessageBusInterface $commandBus
): void {

$event->getState()->willReturn(PaymentInterface::STATE_AUTHORIZED);

$payment->getId()->willReturn(1);

$command = new CancelPayment(1);
$commandBus->dispatch($command)->willReturn(new Envelope($command));

$this->__invoke($payment);
$this->__invoke($payment, PaymentInterface::STATE_AUTHORIZED);
}

public function it_do_nothing_when_it_is_completed(
PaymentInterface $payment,
TransitionEvent $event
PaymentInterface $payment
): void {
$event->getState()->willReturn(PaymentInterface::STATE_COMPLETED);

$this->__invoke($payment);
$this->__invoke($payment, PaymentInterface::STATE_COMPLETED);
}

public function it_do_nothing_when_it_is_refunded(
PaymentInterface $payment,
TransitionEvent $event
): void {
$event->getState()->willReturn(PaymentInterface::STATE_REFUNDED);

$this->__invoke($payment);
$this->__invoke($payment, PaymentInterface::STATE_REFUNDED);
}
}
19 changes: 5 additions & 14 deletions spec/StateMachine/CaptureAuthorizedOrderProcessorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,25 @@ public function let(MessageBusInterface $commandBus): void {

public function it_is_invokable(
PaymentInterface $payment,
TransitionEvent $event,
MessageBusInterface $commandBus
): void {
$event->getState()->willReturn(PaymentInterface::STATE_AUTHORIZED);

$payment->getId()->willReturn(1);

$command = new CaptureAuthorizedPayment(1);
$commandBus->dispatch($command)->willReturn(new Envelope($command));

$this->__invoke($payment);
$this->__invoke($payment, PaymentInterface::STATE_AUTHORIZED);
}

public function it_do_nothing_when_it_is_completed(
PaymentInterface $payment,
TransitionEvent $event
PaymentInterface $payment
): void {
$event->getState()->willReturn(PaymentInterface::STATE_COMPLETED);

$this->__invoke($payment);
$this->__invoke($payment, PaymentInterface::STATE_COMPLETED);
}

public function it_do_nothing_when_it_is_refunded(
PaymentInterface $payment,
TransitionEvent $event
PaymentInterface $payment
): void {
$event->getState()->willReturn(PaymentInterface::STATE_REFUNDED);

$this->__invoke($payment);
$this->__invoke($payment, PaymentInterface::STATE_REFUNDED);
}
}
19 changes: 10 additions & 9 deletions spec/StateMachine/RefundOrderProcessorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,31 @@
final class RefundOrderProcessorSpec extends ObjectBehavior
{
public function let(MessageBusInterface $commandBus): void {
$this->beConstructedWith($commandBus);
$this->beConstructedWith($commandBus, false);
}

public function it_is_invokable(
PaymentInterface $payment,
TransitionEvent $event,
MessageBusInterface $commandBus
): void {
$event->getState()->willReturn(PaymentInterface::STATE_COMPLETED);

$payment->getId()->willReturn(1);

$command = new RefundPayment(1);
$commandBus->dispatch($command)->willReturn(new Envelope($command));

$this->__invoke($payment);
$this->__invoke($payment, PaymentInterface::STATE_COMPLETED);
}

public function it_do_nothing_when_it_is_authorized(
public function it_do_nothing_when_it_is_disabled(
PaymentInterface $payment,
TransitionEvent $event
MessageBusInterface $commandBus
): void {
$event->getState()->willReturn(PaymentInterface::STATE_AUTHORIZED);

$this->__invoke($payment);
$this->beConstructedWith($commandBus, true);

$command = new RefundPayment(1);
$commandBus->dispatch($command)->shouldNotBeCalled();

$this->__invoke($payment, PaymentInterface::STATE_COMPLETED);
}
}

0 comments on commit a01be0c

Please sign in to comment.