mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
[API][Admin] Finish covering product filtering
This commit is contained in:
parent
1df06bf7e0
commit
03b11686df
8 changed files with 37 additions and 11 deletions
|
|
@ -12,7 +12,7 @@ Feature: Filtering products by a channel
|
|||
And the store also has a product "HP Spectre" in channel "Web-US"
|
||||
And I am logged in as an administrator
|
||||
|
||||
@ui
|
||||
@ui @api
|
||||
Scenario: Filtering products by a chosen channel
|
||||
When I browse products
|
||||
And I choose "Web-EU" as a channel filter
|
||||
|
|
@ -22,7 +22,7 @@ Feature: Filtering products by a channel
|
|||
And I should see a product with name "MacBook Pro"
|
||||
But I should not see any product with name "HP Spectre"
|
||||
|
||||
@ui
|
||||
@ui @api
|
||||
Scenario: Filtering products by a chosen channel
|
||||
When I browse products
|
||||
And I choose "Web-US" as a channel filter
|
||||
|
|
|
|||
|
|
@ -1581,14 +1581,14 @@ parameters:
|
|||
path: src/Sylius/Bundle/ApiBundle/EventSubscriber/TaxonDeletionEventSubscriber.php
|
||||
|
||||
-
|
||||
message: "#^Method Sylius\\\\Bundle\\\\ApiBundle\\\\Filter\\\\Doctrine\\\\CatalogPromotionChannelFilter\\:\\:__construct\\(\\) has parameter \\$properties with no value type specified in iterable type array\\.$#"
|
||||
message: "#^Method Sylius\\\\Bundle\\\\ApiBundle\\\\Filter\\\\Doctrine\\\\ChannelsAwareChannelFilter\\:\\:__construct\\(\\) has parameter \\$properties with no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
path: src/Sylius/Bundle/ApiBundle/Filter/Doctrine/CatalogPromotionChannelFilter.php
|
||||
path: src/Sylius/Bundle/ApiBundle/Filter/Doctrine/ChannelsAwareChannelFilter.php
|
||||
|
||||
-
|
||||
message: "#^Method Sylius\\\\Bundle\\\\ApiBundle\\\\Filter\\\\Doctrine\\\\CatalogPromotionChannelFilter\\:\\:getDescription\\(\\) return type has no value type specified in iterable type array\\.$#"
|
||||
message: "#^Method Sylius\\\\Bundle\\\\ApiBundle\\\\Filter\\\\Doctrine\\\\ChannelsAwareChannelFilter\\:\\:getDescription\\(\\) return type has no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
path: src/Sylius/Bundle/ApiBundle/Filter/Doctrine/CatalogPromotionChannelFilter.php
|
||||
path: src/Sylius/Bundle/ApiBundle/Filter/Doctrine/ChannelsAwareChannelFilter.php
|
||||
|
||||
-
|
||||
message: "#^Method Sylius\\\\Bundle\\\\ApiBundle\\\\Filter\\\\Doctrine\\\\ExchangeRateFilter\\:\\:filterProperty\\(\\) has no return type specified\\.$#"
|
||||
|
|
|
|||
|
|
@ -403,6 +403,14 @@ final class ManagingProductsContext implements Context
|
|||
$this->client->show(Resources::PRODUCTS, $product->getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I choose :channel as a channel filter
|
||||
*/
|
||||
public function iChooseChannelAsAChannelFilter(ChannelInterface $channel): void
|
||||
{
|
||||
$this->client->addFilter('channel', $this->iriConverter->getIriFromResource($channel));
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I save my changes to the images
|
||||
*/
|
||||
|
|
@ -411,6 +419,16 @@ final class ManagingProductsContext implements Context
|
|||
// Intentionally left blank
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I filter
|
||||
*/
|
||||
public function iFilter(): void
|
||||
{
|
||||
$this->client->filter();
|
||||
|
||||
$this->sharedStorage->set('response', $this->client->getLastResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should be notified that it has been successfully created
|
||||
*/
|
||||
|
|
@ -486,9 +504,10 @@ final class ManagingProductsContext implements Context
|
|||
}
|
||||
|
||||
/**
|
||||
* @Then I should see a single product in the list
|
||||
* @Then I should see :count products in the list
|
||||
*/
|
||||
public function iShouldSeeProductsInTheList(int $count): void
|
||||
public function iShouldSeeProductsInTheList(int $count = 1): void
|
||||
{
|
||||
Assert::count($this->responseChecker->getCollection($this->client->getLastResponse()), $count);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ use Symfony\Component\HttpFoundation\RequestStack;
|
|||
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
|
||||
|
||||
/** @experimental */
|
||||
final class CatalogPromotionChannelFilter extends AbstractContextAwareFilter
|
||||
final class ChannelsAwareChannelFilter extends AbstractContextAwareFilter
|
||||
{
|
||||
public function __construct(
|
||||
private IriConverterInterface $iriConverter,
|
||||
|
|
@ -28,7 +28,7 @@
|
|||
<attribute>sylius.api.catalog_promotion_enabled_filter</attribute>
|
||||
<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\Bundle\ApiBundle\Filter\Doctrine\ChannelsAwareChannelFilter</attribute>
|
||||
<attribute>sylius.api.order_filter.code</attribute>
|
||||
<attribute>sylius.api.order_filter.name</attribute>
|
||||
<attribute>sylius.api.order_filter.start_date</attribute>
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
<attribute>sylius.api.product_name_filter</attribute>
|
||||
<attribute>sylius.api.product_order_filter</attribute>
|
||||
<attribute>sylius.api.product_taxon_code_filter</attribute>
|
||||
<attribute>Sylius\Bundle\ApiBundle\Filter\Doctrine\ChannelsAwareChannelFilter</attribute>
|
||||
<attribute>Sylius\Bundle\ApiBundle\Filter\Doctrine\TranslationOrderNameAndLocaleFilter</attribute>
|
||||
</attribute>
|
||||
<attribute name="normalization_context">
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@
|
|||
<tag name="api_platform.filter" />
|
||||
</service>
|
||||
|
||||
<service id="Sylius\Bundle\ApiBundle\Filter\Doctrine\CatalogPromotionChannelFilter" public="true">
|
||||
<service id="Sylius\Bundle\ApiBundle\Filter\Doctrine\ChannelsAwareChannelFilter" public="true">
|
||||
<argument type="service" id="api_platform.symfony.iri_converter" />
|
||||
<argument type="service" id="doctrine" />
|
||||
<tag name="api_platform.filter" />
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@
|
|||
"hydra:totalItems": 3,
|
||||
"hydra:search": {
|
||||
"@type": "hydra:IriTemplate",
|
||||
"hydra:template": "\/api\/v2\/admin\/products{?translations.name,order[code],order[createdAt],productTaxons.taxon.code,productTaxons.taxon.code[],order[translation.name],localeCode for order[translation.name]}",
|
||||
"hydra:template": "\/api\/v2\/admin\/products{?translations.name,order[code],order[createdAt],productTaxons.taxon.code,productTaxons.taxon.code[],channel,order[translation.name],localeCode for order[translation.name]}",
|
||||
"hydra:variableRepresentation": "BasicRepresentation",
|
||||
"hydra:mapping": [
|
||||
{
|
||||
|
|
@ -195,6 +195,12 @@
|
|||
"property": "productTaxons.taxon.code",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"@type": "IriTemplateMapping",
|
||||
"variable": "channel",
|
||||
"property": "channels",
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"@type": "IriTemplateMapping",
|
||||
"variable": "order[translation.name]",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue