Skip to content

Commit

Permalink
Rename UpdatePaymentMethod command properties.
Browse files Browse the repository at this point in the history
Fix typos.
  • Loading branch information
dlobato committed May 6, 2019
1 parent ec9b6e6 commit 467db1f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions spec/Command/Order/UpdatePaymentMethodSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ function it_has_order_token(): void

function it_has_identifier_of_payment(): void
{
$this->paymentIdentifier()->shouldReturn(1);
$this->paymentId()->shouldReturn(1);
}

function it_has_payment_method_defined(): void
{
$this->paymentMethod()->shouldReturn('CASH_ON_DELIVERY_METHOD');
$this->paymentMethodCode()->shouldReturn('CASH_ON_DELIVERY_METHOD');
}
}
2 changes: 1 addition & 1 deletion spec/Validator/Order/OrderExistsValidatorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function it_does_not_add_constraint_if_order_exists_multi_state(
));
}

function it_adds_constraint_if_order_does_not_exits_exists(
function it_adds_constraint_if_order_does_not_exists(
OrderRepositoryInterface $orderRepository,
ExecutionContextInterface $executionContext
): void {
Expand Down
18 changes: 9 additions & 9 deletions src/Command/Order/UpdatePaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,30 @@ class UpdatePaymentMethod
protected $orderToken;

/** @var mixed */
protected $paymentIdentifier;
protected $paymentId;

/** @var string */
protected $paymentMethod;
protected $paymentMethodCode;

public function __construct(string $orderToken, $paymentIdentifier, string $paymentMethod)
public function __construct(string $orderToken, $paymentId, string $paymentMethodCode)
{
$this->orderToken = $orderToken;
$this->paymentIdentifier = $paymentIdentifier;
$this->paymentMethod = $paymentMethod;
$this->paymentId = $paymentId;
$this->paymentMethodCode = $paymentMethodCode;
}

public function orderToken(): string
{
return $this->orderToken;
}

public function paymentIdentifier()
public function paymentId()
{
return $this->paymentIdentifier;
return $this->paymentId;
}

public function paymentMethod(): string
public function paymentMethodCode(): string
{
return $this->paymentMethod;
return $this->paymentMethodCode;
}
}
6 changes: 3 additions & 3 deletions src/Handler/Order/UpdatePaymentMethodHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ public function __invoke(UpdatePaymentMethod $choosePaymentMethod): void
Assert::same(OrderPaymentStates::STATE_AWAITING_PAYMENT, $order->getPaymentState(), 'Only awaiting payment orders can be updated.');

/** @var PaymentMethodInterface $paymentMethod */
$paymentMethod = $this->paymentMethodRepository->findOneBy(['code' => $choosePaymentMethod->paymentMethod()]);
$paymentMethod = $this->paymentMethodRepository->findOneBy(['code' => $choosePaymentMethod->paymentMethodCode()]);

Assert::notNull($paymentMethod, 'Payment method has not been found');
Assert::true(isset($order->getPayments()[$choosePaymentMethod->paymentIdentifier()]), 'Can not find payment with given identifier.');
Assert::true(isset($order->getPayments()[$choosePaymentMethod->paymentId()]), 'Can not find payment with given identifier.');

$payment = $order->getPayments()[$choosePaymentMethod->paymentIdentifier()];
$payment = $order->getPayments()[$choosePaymentMethod->paymentId()];
Assert::same(PaymentInterface::STATE_NEW, $payment->getState(), 'Payment should have new state');

$payment->setMethod($paymentMethod);
Expand Down

0 comments on commit 467db1f

Please sign in to comment.