mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
PaymentProcessor related fixes
This commit is contained in:
parent
148e809061
commit
411660ac09
11 changed files with 25 additions and 66 deletions
|
|
@ -1,8 +1,8 @@
|
|||
@customer_account
|
||||
Feature: Viewing payment's cost on my account panel
|
||||
Feature: Viewing payment's amount on my account panel
|
||||
In order to know how much I have to pay for my order
|
||||
As a Customer
|
||||
I want to see the payment cost of my order with all fees
|
||||
I want to see the payment amount of my order with all fees
|
||||
|
||||
Background:
|
||||
Given the store operates on a single channel in "France"
|
||||
|
|
@ -21,4 +21,4 @@ Feature: Viewing payment's cost on my account panel
|
|||
Scenario: Seeing total payment
|
||||
When I view the summary of the order "#00000666"
|
||||
Then I should see "€66.60" as order's total
|
||||
And I should see "€66.60" as payment's cost
|
||||
And I should see that I have to pay "€66.60" for this order
|
||||
|
|
@ -20,8 +20,8 @@ Feature: Cancelling orders
|
|||
And I cancel this order
|
||||
Then I should be notified that it has been successfully updated
|
||||
And its state should be "Cancelled"
|
||||
And it should have payment state "Cancelled"
|
||||
And it should have shipment in state "Cancelled"
|
||||
And it should have payment state "Cancelled"
|
||||
And there should be only 1 payment
|
||||
|
||||
@ui
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
@managing_orders
|
||||
Feature: Seeing payment's cost of an order including all fees
|
||||
In order to see how much a customer actually has to pay
|
||||
Feature: Seeing order's payment amount including all fees
|
||||
In order to see how much a customer has to pay for his order
|
||||
As an Administrator
|
||||
I want to see the exact payment cost including all additional fees
|
||||
I want to see the exact payment amount including all additional fees
|
||||
|
||||
Background:
|
||||
Given the store operates on a single channel in "France"
|
||||
|
|
@ -260,16 +260,13 @@ final class ManagingOrdersContext implements Context
|
|||
}
|
||||
|
||||
/**
|
||||
* @Then the order's payment should (also) be :paymentCost
|
||||
* @Then the order's payment should (also) be :paymentAmount
|
||||
*/
|
||||
public function theOrdersPaymentShouldBe($paymentCost)
|
||||
public function theOrdersPaymentShouldBe($paymentAmount)
|
||||
{
|
||||
$actualPaymentCost = $this->showPage->getPaymentPrice();
|
||||
$actualPaymentAmount = $this->showPage->getPaymentAmount();
|
||||
|
||||
Assert::true(
|
||||
$this->showPage->hasPaymentPrice($paymentCost),
|
||||
sprintf('Order\'s payment should be %s, but is %s', $paymentCost, $actualPaymentCost)
|
||||
);
|
||||
Assert::eq($paymentAmount, $actualPaymentAmount);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -613,16 +610,12 @@ final class ManagingOrdersContext implements Context
|
|||
}
|
||||
|
||||
/**
|
||||
* @Then /^there should be(?:| only) (\d+) payment(?:|s)$/
|
||||
* @Then /^there should be(?:| only) (\d+) payments?$/
|
||||
*/
|
||||
public function theOrderShouldHaveNumberOfPayments($number)
|
||||
{
|
||||
$actualNumberOfPayments = $this->showPage->getPaymentsCount();
|
||||
|
||||
Assert::eq(
|
||||
$number,
|
||||
$actualNumberOfPayments,
|
||||
sprintf('Payments count should equal "%d", but equals "%d" instead.', $number, $actualNumberOfPayments)
|
||||
);
|
||||
Assert::eq($number, $actualNumberOfPayments);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -359,16 +359,13 @@ final class AccountContext implements Context
|
|||
}
|
||||
|
||||
/**
|
||||
* @Then I should see :paymentCost as payment's cost
|
||||
* @Then I should see that I have to pay :paymentAmount for this order
|
||||
*/
|
||||
public function iShouldSeeAsPaymentsCost($paymentCost)
|
||||
public function iShouldSeeIHaveToPayForThisOrder($paymentAmount)
|
||||
{
|
||||
$actualCost = $this->orderShowPage->getPaymentPrice();
|
||||
$actualAmount = $this->orderShowPage->getPaymentPrice();
|
||||
|
||||
Assert::true(
|
||||
$this->orderShowPage->hasPaymentPrice($paymentCost),
|
||||
sprintf('The payment\'s cost should be %s, but is %s.', $paymentCost, $actualCost)
|
||||
);
|
||||
Assert::eq($paymentAmount, $actualAmount);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -292,17 +292,7 @@ class ShowPage extends SymfonyPage implements ShowPageInterface
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasPaymentPrice($price)
|
||||
{
|
||||
$payments = $this->getElement('payments')->getText();
|
||||
|
||||
return false !== strpos($payments, $price);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPaymentPrice()
|
||||
public function getPaymentAmount()
|
||||
{
|
||||
$paymentsPrice = $this->getElement('payments')->find('css', '.description');
|
||||
|
||||
|
|
|
|||
|
|
@ -197,17 +197,10 @@ interface ShowPageInterface extends SymfonyPageInterface
|
|||
*/
|
||||
public function getItemTotal($itemName);
|
||||
|
||||
/**
|
||||
* @param string $price
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasPaymentPrice($price);
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPaymentPrice();
|
||||
public function getPaymentAmount();
|
||||
|
||||
/**
|
||||
* @return int
|
||||
|
|
|
|||
|
|
@ -110,16 +110,6 @@ class ShowPage extends SymfonyPage implements ShowPageInterface
|
|||
return $this->tableAccessor->countTableBodyRows($this->getElement('order_items'));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasPaymentPrice($price)
|
||||
{
|
||||
$payments = $this->getElement('payments')->getText();
|
||||
|
||||
return false !== strpos($payments, $price);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -60,13 +60,6 @@ interface ShowPageInterface extends SymfonyPageInterface
|
|||
*/
|
||||
public function countItems();
|
||||
|
||||
/**
|
||||
* @param string $price
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasPaymentPrice($price);
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -43,8 +43,9 @@ class PaymentProcessor implements PaymentProcessorInterface
|
|||
return;
|
||||
}
|
||||
|
||||
if ($payment = $order->getLastPayment(PaymentInterface::STATE_NEW)) {
|
||||
$payment->setAmount($order->getTotal());
|
||||
$newPayment = $order->getLastPayment(PaymentInterface::STATE_NEW);
|
||||
if (null !== $newPayment) {
|
||||
$newPayment->setAmount($order->getTotal());
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
namespace spec\Sylius\Component\Core\OrderProcessing;
|
||||
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Prophecy\Argument;
|
||||
use Sylius\Component\Core\Model\OrderInterface;
|
||||
use Sylius\Component\Core\OrderProcessing\PaymentProcessor;
|
||||
use Sylius\Component\Core\OrderProcessing\PaymentProcessorInterface;
|
||||
|
|
@ -175,9 +176,10 @@ final class PaymentProcessorSpec extends ObjectBehavior
|
|||
$this->processOrderPayments($order);
|
||||
}
|
||||
|
||||
function it_does_not_add_payment_if_the_order_is_cancelled(OrderInterface $order)
|
||||
function it_does_not_add_a_new_payment_if_the_order_is_cancelled(OrderInterface $order)
|
||||
{
|
||||
$order->getState()->willReturn(OrderInterface::STATE_CANCELLED);
|
||||
$order->addPayment(Argument::any())->shouldNotBeCalled();
|
||||
|
||||
$this->processOrderPayments($order);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue