mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
[ApiBundle][CatalogPromotion] Add order filters
This commit is contained in:
parent
9e8e797c81
commit
59c2798883
4 changed files with 81 additions and 10 deletions
|
|
@ -16,69 +16,69 @@ Feature: Sorting listed catalog promotion
|
|||
And its priority is 2
|
||||
And I am logged in as an administrator
|
||||
|
||||
@ui
|
||||
@api @ui
|
||||
Scenario: Catalog promotions are sorted by ascending code by default
|
||||
When I browse catalog promotions
|
||||
Then I should see 3 catalog promotions on the list
|
||||
And the first catalog promotion should have code "a"
|
||||
|
||||
@ui
|
||||
@api @ui
|
||||
Scenario: Changing the code sorting order to descending
|
||||
When I browse catalog promotions
|
||||
And I sort catalog promotions by descending code
|
||||
Then I should see 3 catalog promotions on the list
|
||||
And the first catalog promotion should have code "not-b"
|
||||
|
||||
@ui
|
||||
@api @ui
|
||||
Scenario: Sorting catalog promotions by name in ascending order
|
||||
When I browse catalog promotions
|
||||
And I sort catalog promotions by ascending name
|
||||
Then I should see 3 catalog promotions on the list
|
||||
And the first catalog promotion should have code "a"
|
||||
|
||||
@ui
|
||||
@api @ui
|
||||
Scenario: Sorting catalog promotion by name in descending order
|
||||
When I browse catalog promotions
|
||||
And I sort catalog promotions by descending name
|
||||
Then I should see 3 catalog promotions on the list
|
||||
And the first catalog promotion should have code "c"
|
||||
|
||||
@ui @no-postgres
|
||||
@api @ui @no-postgres
|
||||
Scenario: Sorting catalog promotion by start date in ascending order
|
||||
When I browse catalog promotions
|
||||
And I sort catalog promotions by ascending "start date"
|
||||
Then I should see 3 catalog promotions on the list
|
||||
And the first catalog promotion should have code "not-b"
|
||||
|
||||
@ui @no-postgres
|
||||
@api @ui @no-postgres
|
||||
Scenario: Sorting catalog promotion by start date in descending order
|
||||
When I browse catalog promotions
|
||||
And I sort catalog promotions by descending "start date"
|
||||
Then I should see 3 catalog promotions on the list
|
||||
And the first catalog promotion should have code "a"
|
||||
|
||||
@ui @no-postgres
|
||||
@api @ui @no-postgres
|
||||
Scenario: Sorting catalog promotion by end date in ascending order
|
||||
When I browse catalog promotions
|
||||
And I sort catalog promotions by ascending "end date"
|
||||
Then I should see 3 catalog promotions on the list
|
||||
And the first catalog promotion should have code "a"
|
||||
|
||||
@ui @no-postgres
|
||||
@api @ui @no-postgres
|
||||
Scenario: Sorting catalog promotion by end date in descending order
|
||||
When I browse catalog promotions
|
||||
And I sort catalog promotions by descending "end date"
|
||||
Then I should see 3 catalog promotions on the list
|
||||
And the first catalog promotion should have code "c"
|
||||
|
||||
@ui
|
||||
@api @ui
|
||||
Scenario: Sorting catalog promotion by priority in ascending order
|
||||
When I browse catalog promotions
|
||||
And I sort catalog promotions by ascending priority
|
||||
Then I should see 3 catalog promotions on the list
|
||||
And the first catalog promotion should have code "not-b"
|
||||
|
||||
@ui
|
||||
@api @ui
|
||||
Scenario: Sorting catalog promotion by priority in descending order
|
||||
When I browse catalog promotions
|
||||
And I sort catalog promotions by descending priority
|
||||
|
|
|
|||
|
|
@ -888,6 +888,18 @@ final class ManagingCatalogPromotionsContext implements Context
|
|||
$this->client->filter();
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I sort catalog promotions by :order :field
|
||||
*/
|
||||
public function iSortCatalogPromotionByOrderField(string $order, string $field): void
|
||||
{
|
||||
$this->client->addFilter(
|
||||
sprintf('order[%s]', lcfirst(str_replace(' ', '', ucwords($field)))),
|
||||
$order === 'descending' ? 'desc' : 'asc',
|
||||
);
|
||||
$this->client->filter();
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I request the removal of :catalogPromotion catalog promotion
|
||||
*/
|
||||
|
|
@ -1554,6 +1566,24 @@ final class ManagingCatalogPromotionsContext implements Context
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should see :count catalog promotions on the list
|
||||
*/
|
||||
public function iShouldSeeCountCatalogPromotionsOnTheList(int $count): void
|
||||
{
|
||||
Assert::count($this->responseChecker->getCollection($this->client->getLastResponse()), $count);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then the first catalog promotion should have code :code
|
||||
*/
|
||||
public function theFirstCatalogPromotionShouldHaveCode(string $code): void
|
||||
{
|
||||
$catalogPromotions = $this->responseChecker->getCollection($this->client->getLastResponse());
|
||||
|
||||
Assert::same(reset($catalogPromotions)['code'], $code);
|
||||
}
|
||||
|
||||
private function catalogPromotionAppliesOnVariants(ProductVariantInterface ...$productVariants): bool
|
||||
{
|
||||
$response = $this->responseChecker->getResponseContent($this->client->getLastResponse());
|
||||
|
|
|
|||
|
|
@ -29,6 +29,11 @@
|
|||
<attribute>sylius.api.catalog_promotion_start_date_filter</attribute>
|
||||
<attribute>sylius.api.catalog_promotion_end_date_filter</attribute>
|
||||
<attribute>Sylius\Bundle\ApiBundle\Filter\Doctrine\CatalogPromotionChannelFilter</attribute>
|
||||
<attribute>sylius.api.order_filter.code</attribute>
|
||||
<attribute>sylius.api.order_filter.name</attribute>
|
||||
<attribute>sylius.api.order_filter.start_date</attribute>
|
||||
<attribute>sylius.api.order_filter.end_date</attribute>
|
||||
<attribute>sylius.api.order_filter.priority</attribute>
|
||||
</attribute>
|
||||
<attribute name="normalization_context">
|
||||
<attribute name="groups">admin:catalog_promotion:read</attribute>
|
||||
|
|
|
|||
|
|
@ -353,5 +353,41 @@
|
|||
</argument>
|
||||
<tag name="api_platform.filter" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.api.order_filter.code" parent="api_platform.doctrine.orm.order_filter" public="true">
|
||||
<argument type="collection">
|
||||
<argument key="code" />
|
||||
</argument>
|
||||
<tag name="api_platform.filter" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.api.order_filter.name" parent="api_platform.doctrine.orm.order_filter" public="true">
|
||||
<argument type="collection">
|
||||
<argument key="name" />
|
||||
</argument>
|
||||
<tag name="api_platform.filter" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.api.order_filter.start_date" parent="api_platform.doctrine.orm.order_filter" public="true">
|
||||
<argument type="collection">
|
||||
<argument key="startDate" />
|
||||
</argument>
|
||||
<tag name="api_platform.filter" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.api.order_filter.end_date" parent="api_platform.doctrine.orm.order_filter" public="true">
|
||||
<argument type="collection">
|
||||
<argument key="endDate" />
|
||||
</argument>
|
||||
<tag name="api_platform.filter" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.api.order_filter.priority" parent="api_platform.doctrine.orm.order_filter" public="true">
|
||||
<argument type="collection">
|
||||
<argument key="priority" />
|
||||
</argument>
|
||||
<tag name="api_platform.filter" />
|
||||
</service>
|
||||
|
||||
</services>
|
||||
</container>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue