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
Cover "Order details" scenarios in API #15553
Conversation
jakubtobiasz
commented
Nov 21, 2023
Q | A |
---|---|
Branch? | 1.13 |
Bug fix? | no |
New feature? | |
BC breaks? | no |
Deprecations? | |
Related tickets | |
License | MIT |
Bunnyshell Preview Environment deployedIt will be automatically stopped in 4 hours. Use the command
Available commands:
|
545c7c8
to
06c75fe
Compare
…s_applied.feature scenarios
…feature scenarios
…s_to_deliver.feature scenarios
* "@id": string, | ||
* "@type": string, | ||
* "variant": string, | ||
* "productName": string, | ||
* "id": int, | ||
* "quantity": int, | ||
* "unitPrice": int, | ||
* "originalUnitPrice": int, | ||
* "total": int, | ||
* "subtotal": int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* "@id": string, | |
* "@type": string, | |
* "variant": string, | |
* "productName": string, | |
* "id": int, | |
* "quantity": int, | |
* "unitPrice": int, | |
* "originalUnitPrice": int, | |
* "total": int, | |
* "subtotal": int | |
* "productName": string |
Adding everything seems like an overkill
* @Then it should have shipment in state :state | ||
* @Then /^order "[^"]+" should have shipment state "([^"]+)"$/ | ||
*/ | ||
public function itShouldHaveShipmentState(string $state): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @Then it should have shipment in state :state | |
* @Then /^order "[^"]+" should have shipment state "([^"]+)"$/ | |
*/ | |
public function itShouldHaveShipmentState(string $state): void | |
* @Then /^(it) should have shipment in state "([^"]+)"$/ | |
* @Then /^(order "[^"]+") should have shipment state "([^"]+)"$/ | |
*/ | |
public function itShouldHaveShipmentState(OrderInterface $order, string $state): void |
Should work virtually the same since we're getting an order from shared storage either way
/** @var OrderInterface $order */ | ||
$order = $this->sharedStorage->get('order'); | ||
|
||
$adjustments = $this->client->subResourceIndex( | ||
Resources::ORDERS, | ||
Resources::ADJUSTMENTS, | ||
$order->getTokenValue(), | ||
forgetResponse: true, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be after moving it to some private method, as we are using it several times 🤔
/** @var OrderInterface $order */ | |
$order = $this->sharedStorage->get('order'); | |
$adjustments = $this->client->subResourceIndex( | |
Resources::ORDERS, | |
Resources::ADJUSTMENTS, | |
$order->getTokenValue(), | |
forgetResponse: true, | |
); | |
$adjustments = $this->getAdjustmentsForOrder(); |
/** @var OrderInterface $order */ | ||
$order = $this->sharedStorage->get('order'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be provided by the transformer
} | ||
|
||
/** | ||
* @Then /^its subtotal should be ([^"]+)$/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @Then /^its subtotal should be ([^"]+)$/ | |
* @Then its subtotal should be :subtotal |
Assert::same( | ||
$this->responseChecker->getValue($this->client->getLastResponse(), 'payments'), | ||
[], | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assert::same( | |
$this->responseChecker->getValue($this->client->getLastResponse(), 'payments'), | |
[], | |
); | |
Assert::isEmpty($this->responseChecker->getValue($this->client->getLastResponse(), 'payments')); |
} | ||
|
||
/** | ||
* @Then /^the order "[^"]+" should have order shipping state "([^"]+)"$/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This step definition does not fit the arguments, as the order number will be taken as the state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It won't be as the order number is not between parentheses.
Assert::same( | ||
$this->responseChecker->getValue($this->client->getLastResponse(), 'shipments'), | ||
[], | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assert::same( | |
$this->responseChecker->getValue($this->client->getLastResponse(), 'shipments'), | |
[], | |
); | |
Assert::isEmpty($this->responseChecker->getValue($this->client->getLastResponse(), 'shipments')); |
foreach ($adjustments as $adjustment) { | ||
if (in_array($adjustment['order_item_unit']['@id'], $orderItem['units'])) { | ||
Assert::same($this->getTotalAsInt(trim($price," ~")), $adjustment['amount']); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return; | |
return; |
if ($isMinus) { | ||
return $amount * -1; | ||
} | ||
return $amount; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return $amount; | |
return $amount; |
<service id="Sylius\Bundle\ApiBundle\Controller\GetOrderAdjustmentsAction"> | ||
<argument type="service" id="sylius.repository.order" /> | ||
<tag name="controller.service_arguments" /> | ||
</service> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be added to services/controllers.xml
0fee660
Thanks, Jacob! 🎉 |