[API] configure order cancelling with promotion

This commit is contained in:
Adam Kasperczak 2020-03-16 14:15:10 +01:00
parent acb2c3340c
commit 8c835d55a3
No known key found for this signature in database
GPG key ID: DD72C983CF887628
6 changed files with 42 additions and 3 deletions

View file

@ -17,7 +17,7 @@ Feature: Cancelling order with promotion applied
And the customer chose "Free" shipping method with "Cash on Delivery" payment
And I am logged in as an administrator
@ui
@ui @api
Scenario: Cancelling order when the applied promotion is no longer valid
Given the promotion was disabled for the channel "Web"
When I view the summary of the order "#00000001"

View file

@ -101,6 +101,7 @@ final class ManagingOrdersContext implements Context
}
/**
* @Then this order should have state :state
* @Then its state should be :state
*/
public function itsStateShouldBe(string $state): void
@ -171,4 +172,31 @@ final class ManagingOrdersContext implements Context
'Transition "cancel" cannot be applied on state "cancelled"'
);
}
/**
* @Then /^the order's total should(?:| still) be "([^"]+)"$/
*/
public function theOrdersTotalShouldBe(string $total): void
{
Assert::same(
$this->responseChecker->getValue($this->client->show($this->sharedStorage->get('order')->getNumber()), 'total'),
$this->getPriceFromString($total)
);
}
/**
* @Then /^the order's promotion total should(?:| still) be "([^"]+)"$/
*/
public function theOrdersPromotionTotalShouldBe(string $promotionTotal): void
{
Assert::same(
$this->responseChecker->getValue($this->client->show($this->sharedStorage->get('order')->getNumber()), 'orderPromotionTotal'),
$this->getPriceFromString($promotionTotal)
);
}
private function getPriceFromString(string $price): int
{
return (int) round((float) str_replace(['€', '£', '$'], '', $price) * 100, 2);
}
}

View file

@ -22,11 +22,12 @@ default:
- sylius.behat.context.transform.currency
- sylius.behat.context.transform.customer
- sylius.behat.context.transform.lexical
- sylius.behat.context.transform.lexical
- sylius.behat.context.transform.order
- sylius.behat.context.transform.payment
- sylius.behat.context.transform.product
- sylius.behat.context.transform.shipping_method
- sylius.behat.context.transform.shared_storage
- sylius.behat.context.transform.shipping_method
- sylius.behat.context.api.admin.managing_orders

View file

@ -49,5 +49,7 @@
<property name="shipments" writable="false" />
<property name="state" writable="false" />
<property name="paymentState" writable="false" />
<property name="total" writable="false" />
<property name="orderPromotionTotal" writable="false" />
</resource>
</resources>

View file

@ -47,5 +47,13 @@
<attribute name="paymentState">
<group>order:read</group>
</attribute>
<attribute name="total">
<group>order:read</group>
</attribute>
<attribute name="orderPromotionTotal">
<group>order:read</group>
</attribute>
</class>
</serializer>

View file

@ -31,7 +31,7 @@ final class OrderStateMachineTransitionApplicatorSpec extends ObjectBehavior
OrderInterface $order,
StateMachine $stateMachine
): void {
$stateMachineFactory->get($$order, OrderTransitions::GRAPH)->willReturn($stateMachine);
$stateMachineFactory->get($order, OrderTransitions::GRAPH)->willReturn($stateMachine);
$stateMachine->apply(OrderTransitions::TRANSITION_CANCEL)->shouldBeCalled();
$this->cancel($order);