Skip to content

Commit

Permalink
[API] Upgrade Locale resource (#16398)
Browse files Browse the repository at this point in the history
| Q               | A
|-----------------|-----
| Branch?         | api-platform-3
| Bug fix?        | no
| New feature?    | no
| BC breaks?      | no?
| Deprecations?   | no
| Related tickets | 
| License         | MIT

<!--
 - Bug fixes must be submitted against the 1.12 or 1.13 branches
 - Features and deprecations must be submitted against the 1.14 branch
- Features, removing deprecations and BC breaks must be submitted
against the 2.0 branch
 - Make sure that the correct base branch is set

To be sure you are not breaking any Backward Compatibilities, check the
documentation:

https://docs.sylius.com/en/latest/book/organization/backward-compatibility-promise.html
-->
  • Loading branch information
Wojdylak committed Jun 14, 2024
2 parents 82ecbb6 + f8d7956 commit 388f618
Show file tree
Hide file tree
Showing 28 changed files with 380 additions and 437 deletions.
53 changes: 0 additions & 53 deletions disabledTests/Api/Shop/LocalesTest.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Feature: Channel independent translatable entities locales
And it uses the "English (United States)" locale by default
And I am logged in as an administrator

@todo @ui
@no-api @todo @ui
Scenario: Using all locales to translate an entity
Given the store has locale "German (Germany)"
When I want to create a new translatable entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Feature: Adding a new locale
Background:
Given I am logged in as an administrator

@todo @ui @api
@api @ui
Scenario: Adding a new locale
When I want to create a new locale
And I choose Norwegian
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Feature: Locale unique code validation
Given the store has locale "Norwegian (Norway)"
And I am logged in as an administrator

@todo @ui @api
@api @ui
Scenario: Trying to add new locale with used code
When I want to add a new locale
Then I should not be able to choose "Norwegian (Norway)"
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Feature: Removing locales
And it uses the "English (United States)" locale by default
And I am logged in as an administrator

@todo @ui @api
@api @ui
Scenario: Deleting unused locale
Given the store has a product "T-Shirt banana"
And this product is named "Banana T-Shirt with Minions" in the "English (United States)" locale
Expand All @@ -19,7 +19,7 @@ Feature: Removing locales
Then I should be informed that locale "Polish (Poland)" has been deleted
And only the "English (United States)" locale should be present in the system

@todo @ui @api
@api @ui
Scenario: Deleting a locale in use
Given the store has a product "T-Shirt banana"
And this product is named "Banana T-Shirt with Minions" in the "English (United States)" locale
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ Feature: Browsing shop in different than default locale
And this product is named "Koszulka bananowa" in the "Polish (Poland)" locale
And this product is named "香蕉T恤" in the "Chinese (Simplified, China)" locale

@ui @api
# These scenarios should be implemented after implementing Product resource in APIP3
@todo-api @ui
Scenario: Browsing product details in non-default locale
When I browse that channel
And I check this product's details in the "Polish (Poland)" locale
Then I should see the product name "Koszulka bananowa"

@ui @api
@todo-api @ui
Scenario: Browsing product details in non-default locale
When I check this product's details in the "Chinese (Simplified, China)" locale
Then I should see the product name "香蕉T恤"

@ui @api
@todo-api @ui
Scenario: Not being able to shop using a locale non-existent in the channel
When I browse that channel
And I try to check this product's details in the "Irish (Ireland)" locale
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@ Feature: Handling different locales on multiple channels
And that channel allows to shop using "Polish (Poland)" and "Norwegian (Norway)" locales
And it uses the "Polish (Poland)" locale by default

@ui @api
# These scenarios should be implemented after implementing Order resource in APIP3
@todo-api @ui
Scenario: Showing locales only from the current channel
When I browse the "Mobile" channel
Then I should shop using the "Polish (Poland)" locale
And I should be able to shop using the "Norwegian (Norway)" locale
And I should not be able to shop using the "English (United States)" locale

@ui @api
@todo-api @ui
Scenario: Browsing channels using their default locales
When I browse the "Web" channel
And I start browsing the "Mobile" channel
Then I should shop using the "Polish (Poland)" locale

@ui @api
@todo-api @ui
Scenario: Switching a locale applies only to the current channel
When I browse the "Web" channel
And I switch to the "Norwegian (Norway)" locale
Expand Down
5 changes: 3 additions & 2 deletions features/shop/locale/redirecting_to_default_locale.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ Feature: Redirecting to the default locale
And it uses the "English (United States)" locale by default
And the store has a product "PHP T-Shirt"

@ui @api
# These scenarios should be implemented after implementing Order resource in APIP3
@todo-api @ui
Scenario: Staying on the current locale if it is available
When I browse that channel
And I use the locale "French (France)"
Then I should shop using the "French (France)" locale

@ui @api
@todo-api @ui
Scenario: Redirecting to default locale if it is not available
When I browse that channel
And I use the locale "Polish (Poland)"
Expand Down
8 changes: 5 additions & 3 deletions features/shop/locale/switching_current_locale.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@ Feature: Switching the current locale
And that channel allows to shop using "English (United States)" and "Polish (Poland)" locales
And it uses the "English (United States)" locale by default

@ui @api
# This scenario should be implemented after implementing Order resource in APIP3
@todo-api @ui
Scenario: Showing the current locale
When I browse that channel
Then I should shop using the "English (United States)" locale

@ui @api
@api @ui
Scenario: Showing available locales
When I browse that channel
Then I should be able to shop using the "Polish (Poland)" locale

@ui @api
# This scenario should be implemented after implementing Order resource in APIP3
@todo-api @ui
Scenario: Switching the current locale
When I browse that channel
And I switch to the "Polish (Poland)" locale
Expand Down
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -1490,11 +1490,6 @@ parameters:
count: 1
path: src/Sylius/Bundle/ApiBundle/Doctrine/QueryCollectionExtension/HideArchivedShippingMethodExtension.php

-
message: "#^Method Sylius\\\\Bundle\\\\ApiBundle\\\\Doctrine\\\\QueryCollectionExtension\\\\LocaleCollectionExtension\\:\\:applyToCollection\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
count: 1
path: src/Sylius/Bundle/ApiBundle/Doctrine/QueryCollectionExtension/LocaleCollectionExtension.php

-
message: "#^Method Sylius\\\\Bundle\\\\ApiBundle\\\\Doctrine\\\\QueryCollectionExtension\\\\OrdersByChannelExtension\\:\\:applyToCollection\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
count: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@
<argument>%sylius.security.new_api_route%</argument>
</service>

<!-- <service id="sylius.behat.context.api.admin.managing_locales" class="Sylius\Behat\Context\Api\Admin\ManagingLocalesContext">-->
<!-- <argument type="service" id="sylius.behat.api_platform_client.admin" />-->
<!-- <argument type="service" id="Sylius\Behat\Client\ResponseCheckerInterface" />-->
<!-- </service>-->
<service id="sylius.behat.context.api.admin.managing_locales" class="Sylius\Behat\Context\Api\Admin\ManagingLocalesContext">
<argument type="service" id="sylius.behat.api_platform_client.admin" />
<argument type="service" id="Sylius\Behat\Client\ResponseCheckerInterface" />
</service>

<!-- <service id="sylius.behat.context.api.admin.managing_product_associations" class="Sylius\Behat\Context\Api\Admin\ManagingProductAssociationsContext">-->
<!-- <argument type="service" id="sylius.behat.api_platform_client.admin" />-->
Expand Down
48 changes: 24 additions & 24 deletions src/Sylius/Behat/Resources/config/services/contexts/api/shop.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@
<!-- <argument type="service" id="sylius.behat.shared_storage" />-->
<!-- </service>-->

<!-- <service id="sylius.behat.context.api.shop.cart" class="Sylius\Behat\Context\Api\Shop\CartContext">-->
<!-- <argument type="service" id="sylius.behat.api_platform_client.shop" />-->
<!-- <argument type="service" id="sylius.behat.api_platform_client.admin" />-->
<!-- <argument type="service" id="Sylius\Behat\Client\ResponseCheckerInterface" />-->
<!-- <argument type="service" id="sylius.behat.shared_storage" />-->
<!-- <argument type="service" id="Sylius\Component\Product\Resolver\ProductVariantResolverInterface" />-->
<!-- <argument type="service" id="api_platform.iri_converter" />-->
<!-- <argument type="service" id="sylius.behat.request_factory" />-->
<!-- <argument>%sylius.security.new_api_route%</argument>-->
<!-- </service>-->
<service id="sylius.behat.context.api.shop.cart" class="Sylius\Behat\Context\Api\Shop\CartContext">
<argument type="service" id="sylius.behat.api_platform_client.shop" />
<argument type="service" id="sylius.behat.api_platform_client.admin" />
<argument type="service" id="Sylius\Behat\Client\ResponseCheckerInterface" />
<argument type="service" id="sylius.behat.shared_storage" />
<argument type="service" id="Sylius\Component\Product\Resolver\ProductVariantResolverInterface" />
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="sylius.behat.request_factory" />
<argument>%sylius.security.new_api_route%</argument>
</service>

<service id="sylius.behat.context.api.shop.customer" class="Sylius\Behat\Context\Api\Shop\CustomerContext">
<argument type="service" id="sylius.behat.api_platform_client.shop" />
Expand Down Expand Up @@ -104,15 +104,15 @@
<argument>%sylius.security.new_api_route%</argument>
</service>

<!-- <service id="sylius.behat.context.api.shop.product" class="Sylius\Behat\Context\Api\Shop\ProductContext">-->
<!-- <argument type="service" id="sylius.behat.api_platform_client.shop" />-->
<!-- <argument type="service" id="Sylius\Behat\Client\ResponseCheckerInterface" />-->
<!-- <argument type="service" id="sylius.behat.shared_storage" />-->
<!-- <argument type="service" id="api_platform.iri_converter" />-->
<!-- <argument type="service" id="sylius.behat.channel_context_setter" />-->
<!-- <argument type="service" id="sylius.behat.request_factory" />-->
<!-- <argument>%sylius.security.new_api_route%</argument>-->
<!-- </service>-->
<service id="sylius.behat.context.api.shop.product" class="Sylius\Behat\Context\Api\Shop\ProductContext">
<argument type="service" id="sylius.behat.api_platform_client.shop" />
<argument type="service" id="Sylius\Behat\Client\ResponseCheckerInterface" />
<argument type="service" id="sylius.behat.shared_storage" />
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="sylius.behat.channel_context_setter" />
<argument type="service" id="sylius.behat.request_factory" />
<argument>%sylius.security.new_api_route%</argument>
</service>

<!-- <service id="sylius.behat.context.api.shop.product_attribute" class="Sylius\Behat\Context\Api\Shop\ProductAttributeContext">-->
<!-- <argument type="service" id="sylius.behat.api_platform_client.shop" />-->
Expand Down Expand Up @@ -172,11 +172,11 @@
<!-- <argument type="service" id="sylius.behat.shared_storage" />-->
<!-- </service>-->

<!-- <service id="sylius.behat.context.api.shop.locale" class="Sylius\Behat\Context\Api\Shop\LocaleContext">-->
<!-- <argument type="service" id="sylius.behat.api_platform_client.shop" />-->
<!-- <argument type="service" id="Sylius\Behat\Client\ResponseCheckerInterface" />-->
<!-- <argument type="service" id="sylius.behat.shared_storage" />-->
<!-- </service>-->
<service id="sylius.behat.context.api.shop.locale" class="Sylius\Behat\Context\Api\Shop\LocaleContext">
<argument type="service" id="sylius.behat.api_platform_client.shop" />
<argument type="service" id="Sylius\Behat\Client\ResponseCheckerInterface" />
<argument type="service" id="sylius.behat.shared_storage" />
</service>

<service id="sylius.behat.context.api.shop.contact" class="Sylius\Behat\Context\Api\Shop\ContactContext">
<argument type="service" id="sylius.behat.request_factory" />
Expand Down
4 changes: 2 additions & 2 deletions src/Sylius/Behat/Resources/config/suites/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ imports:
# - api/inventory/cart_inventory.yml
# - api/inventory/checkout_inventory.yaml
# - api/inventory/managing_inventory.yaml
# - api/locale/locales.yaml
# - api/locale/managing_locales.yml
- api/locale/locales.yaml
- api/locale/managing_locales.yaml
# - api/order/managing_orders.yml
# - api/order/modifying_placed_order_address.yaml
# - api/order/order_history.yaml
Expand Down
59 changes: 0 additions & 59 deletions src/Sylius/Bundle/ApiBundle/DataPersister/LocaleDataPersister.php

This file was deleted.

Loading

0 comments on commit 388f618

Please sign in to comment.