-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 filtration' scenarios in API #15566
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -22,8 +22,11 @@ | |||||
use Sylius\Behat\Service\SharedSecurityServiceInterface; | ||||||
use Sylius\Behat\Service\SharedStorageInterface; | ||||||
use Sylius\Component\Core\Model\AdminUserInterface; | ||||||
use Sylius\Component\Core\Model\ChannelInterface; | ||||||
use Sylius\Component\Core\Model\CustomerInterface; | ||||||
use Sylius\Component\Core\Model\OrderInterface; | ||||||
use Sylius\Component\Core\Model\ShippingMethodInterface; | ||||||
use Sylius\Component\Currency\Model\CurrencyInterface; | ||||||
use Sylius\Component\Order\OrderTransitions; | ||||||
use Sylius\Component\Payment\PaymentTransitions; | ||||||
use Sylius\Component\Shipping\ShipmentTransitions; | ||||||
|
@@ -62,6 +65,113 @@ public function iBrowseOrders(): void | |||||
$this->client->index(Resources::ORDERS); | ||||||
} | ||||||
|
||||||
/** | ||||||
* @When I filter | ||||||
*/ | ||||||
public function iFilter(): void | ||||||
{ | ||||||
$this->client->filter(); | ||||||
} | ||||||
|
||||||
/** | ||||||
* @When I choose :channel as a channel filter | ||||||
*/ | ||||||
public function iChooseChannelAsAChannelFilter(ChannelInterface $channel): void | ||||||
{ | ||||||
$this->client->addFilter('channel.code', $channel->getCode()); | ||||||
} | ||||||
|
||||||
/** | ||||||
* @When I specify filter date from as :dateTime | ||||||
*/ | ||||||
public function iSpecifyFilterDateFromAs(string $dateTime): void | ||||||
{ | ||||||
$this->client->addFilter('checkoutCompletedAt[after]', $dateTime); | ||||||
} | ||||||
|
||||||
/** | ||||||
* @When I specify filter date to as :dateTime | ||||||
*/ | ||||||
public function iSpecifyFilterDateToAs(string $dateTime): void | ||||||
{ | ||||||
$this->client->addFilter('checkoutCompletedAt[before]', $dateTime); | ||||||
} | ||||||
|
||||||
|
||||||
/** | ||||||
* @When I filter by product :productName | ||||||
* @When I filter by products :firstProduct and :secondProduct | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
*/ | ||||||
public function iFilterByProduct(string ...$productNames): void | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
{ | ||||||
foreach ($productNames as $productName) { | ||||||
$this->client->addFilter('items.productName[]', $productName); | ||||||
} | ||||||
|
||||||
$this->client->filter(); | ||||||
} | ||||||
|
||||||
/** | ||||||
* @When I choose :shippingMethod as a shipping method filter | ||||||
*/ | ||||||
public function iChooseAsAShippingMethodFilter(ShippingMethodInterface $shippingMethod): void | ||||||
{ | ||||||
$this->client->addFilter('shipments.method.code', $shippingMethod->getCode()); | ||||||
} | ||||||
|
||||||
/** | ||||||
* @When I choose :currency as the filter currency | ||||||
*/ | ||||||
public function iChooseCurrencyAsTheFilterCurrency(CurrencyInterface $currency): void | ||||||
{ | ||||||
$this->client->addFilter('currencyCode', $currency->getCode()); | ||||||
} | ||||||
|
||||||
/** | ||||||
* @When I specify filter total being greater than :total | ||||||
*/ | ||||||
public function iSpecifyFilterTotalBeingGreaterThan(string $total): void | ||||||
{ | ||||||
if (str_contains($total, '.')) { | ||||||
$total = str_replace('.', '', $total); | ||||||
$this->client->addFilter('total[gt]', $total); | ||||||
|
||||||
return; | ||||||
} | ||||||
Comment on lines
+135
to
+140
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest creating a private method that either removes |
||||||
|
||||||
$this->client->addFilter('total[gt]', $total . '00'); | ||||||
} | ||||||
|
||||||
/** | ||||||
* @When I specify filter total being less than :total | ||||||
*/ | ||||||
public function iSpecifyFilterTotalBeingLessThan(string $total): void | ||||||
{ | ||||||
$this->client->addFilter('total[lt]', $total. '00'); | ||||||
} | ||||||
|
||||||
/** | ||||||
* @When I filter by variant :variantName | ||||||
* @When I filter by variants :firstVariant and :secondVariant | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
*/ | ||||||
public function iFilterByVariant(string ...$variantsNames): void | ||||||
{ | ||||||
foreach ($variantsNames as $variantName) { | ||||||
$this->client->addFilter('items.variant.translations.name[]', $variantName); | ||||||
} | ||||||
|
||||||
$this->client->filter(); | ||||||
} | ||||||
|
||||||
/** | ||||||
* @When I switch the way orders are sorted by :fieldName | ||||||
*/ | ||||||
public function iSwitchSortingBy(string $fieldName): void | ||||||
{ | ||||||
$this->client->addFilter('order[number]', 'asc'); | ||||||
$this->client->filter(); | ||||||
} | ||||||
|
||||||
/** | ||||||
* @When /^I cancel (this order)$/ | ||||||
*/ | ||||||
|
@@ -107,15 +217,6 @@ public function iLimitNumberOfItemsTo(int $limit): void | |||||
$this->client->filter(); | ||||||
} | ||||||
|
||||||
/** | ||||||
* @When I switch the way orders are sorted by :fieldName | ||||||
*/ | ||||||
public function iSwitchSortingBy(string $fieldName): void | ||||||
{ | ||||||
$this->client->addFilter(sprintf('order[%s]', $fieldName), 'asc'); | ||||||
$this->client->filter(); | ||||||
} | ||||||
|
||||||
/** | ||||||
* @Then I should see a single order from customer :customer | ||||||
*/ | ||||||
|
@@ -133,10 +234,11 @@ public function iShouldSeeASingleOrderFromCustomer(CustomerInterface $customer): | |||||
|
||||||
/** | ||||||
* @Then I should see a single order in the list | ||||||
* @Then I should see :number orders in the list | ||||||
*/ | ||||||
public function iShouldSeeASingleOrderInTheList(): void | ||||||
public function iShouldSeeASingleOrderInTheList(int $number = 1): void | ||||||
{ | ||||||
Assert::same($this->responseChecker->countCollectionItems($this->client->getLastResponse()), 1); | ||||||
Assert::same($this->responseChecker->countCollectionItems($this->client->getLastResponse()), $number); | ||||||
} | ||||||
|
||||||
/** | ||||||
|
@@ -344,6 +446,32 @@ public function iShouldSeeOrderWithNumber(string $orderNumber): void | |||||
); | ||||||
} | ||||||
|
||||||
/** | ||||||
* @Then I should not see an order with :orderNumber number | ||||||
*/ | ||||||
public function iShouldNotSeeOrderWithNumber(string $orderNumber) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
{ | ||||||
$response = $this->client->getLastResponse(); | ||||||
|
||||||
Assert::false( | ||||||
$this->responseChecker->hasItemWithValue($response, 'number', $orderNumber), | ||||||
sprintf('The order with number "%s" has been found, but should not.', $orderNumber), | ||||||
); | ||||||
} | ||||||
|
||||||
/** | ||||||
* @Then I should not see any orders with currency :currencyCode | ||||||
*/ | ||||||
public function iShouldNotSeeAnyOrderWithCurrency(string $currencyCode): void | ||||||
{ | ||||||
$response = $this->client->getLastResponse(); | ||||||
|
||||||
Assert::false( | ||||||
$this->responseChecker->hasItemWithValue($response, 'currencyCode', $currencyCode), | ||||||
sprintf('The order with currency code "%s" has been found, but should not.', $currencyCode), | ||||||
); | ||||||
} | ||||||
|
||||||
/** | ||||||
* @Then the first order should have number :number | ||||||
*/ | ||||||
|
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.
Can we establish a convention? In the system, we have three variations:
@api @ui @javascript
,@ui @api @javascript
, and@ui @javascript @api
. I know it's not a problem of this PR.