Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[API][Checkout] Cover scenarios for checking promotions#11749

Merged
lchrusciel merged 2 commits into
Sylius:masterfrom
GSadee:api-checkout-promotions
Aug 20, 2020
Merged

[API][Checkout] Cover scenarios for checking promotions#11749
lchrusciel merged 2 commits into
Sylius:masterfrom
GSadee:api-checkout-promotions

Conversation

@GSadee
Copy link
Copy Markdown
Member

@GSadee GSadee commented Aug 19, 2020

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Related tickets
License MIT

@GSadee GSadee added the API APIs related issues and PRs. label Aug 19, 2020
@GSadee GSadee requested a review from a team as a code owner August 19, 2020 11:03
@GSadee GSadee force-pushed the api-checkout-promotions branch from d0048f7 to 0f3f5f5 Compare August 20, 2020 06:20
public function shouldBeAppliedToMyOrder(string $promotionName): void
{
$response = $this->client->show($this->sharedStorage->get('cart_token'));
Assert::notFalse(array_search($promotionName, array_column($this->getAdjustmentsForOrder(), 'label')));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This extraction logic seems like a good candidate for placing it in separate private method

/**
* @Then :promotionName should be applied to my order shipping
*/
public function shouldBeAppliedToMyOrderShipping(string $promotionName): void
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we merge it with the previous step?

}

/**
* @Then /^the ("[^"]+" product) should have unit price discounted by ("\$\d+")$/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why didn't you use our price transformation here?

{
$response = $this->client->customAction(
sprintf('/new-api/orders/%s/items/%s/adjustments', $this->sharedStorage->get('cart_token'), $itemId),
HttpRequest::METHOD_GET);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
HttpRequest::METHOD_GET);
HttpRequest::METHOD_GET)
;

</itemOperations>

<subresourceOperations>
<subresourceOperation name="api_order_items_adjustments_get_subresource">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between these two operations?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the subresources to generate adjustments endpoints, for example to have endpoint: /orders/{token}/items/{id}/adjustments, we need to expose also /order-items/{id}/adjustments.

These are all adjustments endpoints that are currently exposed:
image

->shouldReturn(false)
;

$context['subresource_identifiers'] = ['id' => 'TOKEN'];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should test the version with items as well

@lchrusciel lchrusciel merged commit 2642511 into Sylius:master Aug 20, 2020
@lchrusciel
Copy link
Copy Markdown
Contributor

Thank you, Grzegorz! 🎉

@GSadee GSadee deleted the api-checkout-promotions branch August 20, 2020 08:15

return
is_a($resourceClass, AdjustmentInterface::class, true) &&
isset($subresourceIdentifiers['id']) &&
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible to merge it to isset($subresourceIdentifiers['id'], $subresourceIdentifiers['items']) 🚀

lchrusciel added a commit that referenced this pull request Aug 20, 2020
This PR was merged into the 1.8-dev branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | master
| Bug fix?        | no
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | fixes for review from #11749 
| License         | MIT


Commits
-------

2b41ca9 [API] Minor fixes for adjustments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API APIs related issues and PRs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants