[Behat] Update API context services config from xml to php#18855
Conversation
❌ Preview Environment deleted from BunnyshellAvailable commands:
|
📝 WalkthroughWalkthroughThis PR converts Behat API context service configurations from XML to PHP format across multiple files. It updates the main services loader to use the new PHP-based API contexts aggregator, replaces individual XML context definition files with PHP equivalents, and removes all XML configuration files. The service definitions and dependencies remain functionally equivalent. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~35 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (4)
src/Sylius/Behat/Resources/config/services/contexts/api/common.php (1)
14-19:useimports are not sorted alphabetically.As per coding guidelines,
useimports should be sorted alphabetically and grouped by type.Sylius\Behat\Client\ResponseCheckerInterfaceshould come before theSylius\Behat\Context\*imports.♻️ Suggested import order
-use Sylius\Behat\Context\Api\Common\SaveContext; -use Sylius\Behat\Context\Api\Common\ResponseContext; use Sylius\Behat\Client\ResponseCheckerInterface; +use Sylius\Behat\Context\Api\Common\ResponseContext; +use Sylius\Behat\Context\Api\Common\SaveContext; use Sylius\Behat\Context\Api\DebugContext; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use function Symfony\Component\DependencyInjection\Loader\Configurator\service;As per coding guidelines: "Sort PHP
useimports alphabetically and group by type (classes, functions, constants)"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Sylius/Behat/Resources/config/services/contexts/api/common.php` around lines 14 - 19, The use imports are out of alphabetical order; reorder the use statements so class imports are alphabetized and grouped together (e.g. ResponseCheckerInterface before SaveContext, ResponseContext, DebugContext) and place the function import (service) after the class imports; adjust the block containing SaveContext, ResponseContext, ResponseCheckerInterface, DebugContext, ContainerConfigurator and the function import service to follow this sorted grouping.src/Sylius/Behat/Resources/config/services/contexts/api/admin.php (2)
14-63:useimports are not sorted alphabetically, withIriConvertermisplaced amongContextimports.
Sylius\Behat\Service\Converter\IriConverter(line 27) is interleaved betweenContext\Api\Admin\*imports. It belongs after allSylius\Behat\Context\*imports sinceServicesorts afterContext. Additionally, theContext\Api\Admin\*imports themselves are not in alphabetical order (e.g.,ManagingProductTaxonsContextbeforeManagingChannelsContext).♻️ Suggested import order
use Sylius\Behat\Client\ResponseCheckerInterface; use Sylius\Behat\Context\Api\Admin\BrowsingCatalogPromotionProductVariantsContext; use Sylius\Behat\Context\Api\Admin\BrowsingProductVariantsContext; +use Sylius\Behat\Context\Api\Admin\ChannelPricingLogEntryContext; use Sylius\Behat\Context\Api\Admin\CreatingProductVariantContext; +use Sylius\Behat\Context\Api\Admin\DashboardContext; +use Sylius\Behat\Context\Api\Admin\LoginContext; use Sylius\Behat\Context\Api\Admin\ManagingAdministratorsContext; -use Sylius\Behat\Context\Api\Admin\ManagingProductTaxonsContext; +use Sylius\Behat\Context\Api\Admin\ManagingCatalogPromotionsContext; +use Sylius\Behat\Context\Api\Admin\ManagingChannelPriceHistoryConfigContext; use Sylius\Behat\Context\Api\Admin\ManagingChannelsContext; use Sylius\Behat\Context\Api\Admin\ManagingChannelsBillingDataContext; use Sylius\Behat\Context\Api\Admin\ManagingCountriesContext; use Sylius\Behat\Context\Api\Admin\ManagingCurrenciesContext; +use Sylius\Behat\Context\Api\Admin\ManagingCustomerGroupsContext; +use Sylius\Behat\Context\Api\Admin\ManagingCustomersContext; use Sylius\Behat\Context\Api\Admin\ManagingExchangeRatesContext; use Sylius\Behat\Context\Api\Admin\ManagingLocalesContext; +use Sylius\Behat\Context\Api\Admin\ManagingOrdersContext; +use Sylius\Behat\Context\Api\Admin\ManagingPaymentMethodsContext; +use Sylius\Behat\Context\Api\Admin\ManagingPaymentRequestsContext; +use Sylius\Behat\Context\Api\Admin\ManagingPaymentsContext; +use Sylius\Behat\Context\Api\Admin\ManagingPlacedOrderAddressesContext; use Sylius\Behat\Context\Api\Admin\ManagingProductAssociationsContext; -use Sylius\Behat\Service\Converter\IriConverter; use Sylius\Behat\Context\Api\Admin\ManagingProductAssociationTypesContext; use Sylius\Behat\Context\Api\Admin\ManagingProductAttributesContext; use Sylius\Behat\Context\Api\Admin\ManagingProductImagesContext; use Sylius\Behat\Context\Api\Admin\ManagingProductOptionsContext; +use Sylius\Behat\Context\Api\Admin\ManagingProductReviewsContext; use Sylius\Behat\Context\Api\Admin\ManagingProductsContext; +use Sylius\Behat\Context\Api\Admin\ManagingProductTaxonsContext; use Sylius\Behat\Context\Api\Admin\ManagingProductVariantsContext; use Sylius\Behat\Context\Api\Admin\ManagingProductVariantsPricesContext; -use Sylius\Behat\Context\Api\Admin\ManagingTaxCategoriesContext; -use Sylius\Behat\Context\Api\Admin\ManagingTaxonsContext; -use Sylius\Behat\Context\Api\Admin\ManagingTaxonImagesContext; +use Sylius\Behat\Context\Api\Admin\ManagingPromotionCouponsContext; +use Sylius\Behat\Context\Api\Admin\ManagingPromotionsContext; use Sylius\Behat\Context\Api\Admin\ManagingShippingCategoriesContext; use Sylius\Behat\Context\Api\Admin\ManagingShippingMethodsContext; -use Sylius\Behat\Context\Api\Admin\ManagingProductReviewsContext; -use Sylius\Behat\Context\Api\Admin\ManagingPaymentsContext; use Sylius\Behat\Context\Api\Admin\ManagingShipmentsContext; -use Sylius\Behat\Context\Api\Admin\ManagingOrdersContext; -use Sylius\Behat\Context\Api\Admin\ManagingPaymentMethodsContext; -use Sylius\Behat\Context\Api\Admin\ManagingZonesContext; +use Sylius\Behat\Context\Api\Admin\ManagingTaxCategoriesContext; +use Sylius\Behat\Context\Api\Admin\ManagingTaxonImagesContext; +use Sylius\Behat\Context\Api\Admin\ManagingTaxonsContext; +use Sylius\Behat\Context\Api\Admin\ManagingTaxRatesContext; +use Sylius\Behat\Context\Api\Admin\ManagingZonesContext; use Sylius\Behat\Context\Api\Admin\RemovingProductContext; use Sylius\Behat\Context\Api\Admin\RemovingTaxonContext; -use Sylius\Behat\Context\Api\Admin\ManagingPromotionsContext; -use Sylius\Behat\Context\Api\Admin\ManagingCatalogPromotionsContext; -use Sylius\Behat\Context\Api\Admin\ManagingTaxRatesContext; use Sylius\Behat\Context\Api\Admin\ResettingPasswordContext; -use Sylius\Behat\Context\Api\Admin\ChannelPricingLogEntryContext; -use Sylius\Behat\Context\Api\Admin\ManagingCustomersContext; -use Sylius\Behat\Context\Api\Admin\ManagingCustomerGroupsContext; -use Sylius\Behat\Context\Api\Admin\ManagingPlacedOrderAddressesContext; -use Sylius\Behat\Context\Api\Admin\ManagingPromotionCouponsContext; -use Sylius\Behat\Context\Api\Admin\DashboardContext; -use Sylius\Behat\Context\Api\Admin\ManagingChannelPriceHistoryConfigContext; -use Sylius\Behat\Context\Api\Admin\ManagingPaymentRequestsContext; -use Sylius\Behat\Context\Api\Admin\LoginContext; use Sylius\Behat\Context\Api\Admin\TranslationContext; +use Sylius\Behat\Service\Converter\IriConverter; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use function Symfony\Component\DependencyInjection\Loader\Configurator\service;As per coding guidelines: "Sort PHP
useimports alphabetically and group by type (classes, functions, constants)"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Sylius/Behat/Resources/config/services/contexts/api/admin.php` around lines 14 - 63, The import list is unsorted: move Sylius\Behat\Service\Converter\IriConverter so it sits after all Sylius\Behat\Context\* imports and then reorder all Sylius\Behat\Context\Api\Admin\* imports alphabetically (e.g. ensure ManagingChannelsContext comes before ManagingProductTaxonsContext), and finally group and alphabetize the remaining imports (classes first, then functions like service) so the entire block follows the project's “classes, functions, constants” grouping and alphabetical ordering.
86-93: Inconsistent service ID naming: some services use FQCN constants, others use string IDs.Four services use
::classas their service ID (BrowsingCatalogPromotionProductVariantsContext,ManagingChannelsBillingDataContext,RemovingTaxonContext,ManagingChannelPriceHistoryConfigContext) while the majority use thesylius.behat.context.api.admin.*string convention. Consider standardizing to one approach for consistency.Also applies to: 141-147, 377-383, 480-488
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Sylius/Behat/Resources/config/services/contexts/api/admin.php` around lines 86 - 93, The service registrations for BrowsingCatalogPromotionProductVariantsContext, ManagingChannelsBillingDataContext, RemovingTaxonContext, and ManagingChannelPriceHistoryConfigContext are using ::class while most others use string IDs; change these four registrations to use the existing string ID convention (e.g. 'sylius.behat.context.api.admin.<appropriate_name>') and keep the same ->args([...]) and dependencies (service('sylius.behat.api_platform_client.admin'), service(ResponseCheckerInterface::class), service('api_platform.iri_converter')) so the service keys match the rest of the file; apply the same change to the other occurrences mentioned (lines around 141-147, 377-383, 480-488) for consistent naming.src/Sylius/Behat/Resources/config/services/contexts/api/shop.php (1)
14-42:useimports are not sorted alphabetically.Same issue as in
common.php— imports should be sorted alphabetically withSylius\Behat\Client\ResponseCheckerInterfacebefore allSylius\Behat\Context\*classes, and theContext\Api\Shop\*classes sorted alphabetically (e.g.,CartContextbeforeChannelContext,CheckoutContextbeforeContactContext, sub-namespaceCheckout\*grouped together, etc.).♻️ Suggested import order
-use Sylius\Behat\Context\Api\Shop\AddressContext; use Sylius\Behat\Client\ResponseCheckerInterface; -use Sylius\Behat\Context\Api\Shop\ChannelContext; -use Sylius\Behat\Context\Api\Shop\CurrencyContext; +use Sylius\Behat\Context\Api\Shop\AddressContext; use Sylius\Behat\Context\Api\Shop\CartContext; +use Sylius\Behat\Context\Api\Shop\ChannelContext; +use Sylius\Behat\Context\Api\Shop\Checkout\CheckoutCompleteContext; +use Sylius\Behat\Context\Api\Shop\Checkout\CheckoutOrderDetailsContext; +use Sylius\Behat\Context\Api\Shop\Checkout\CheckoutShippingContext; +use Sylius\Behat\Context\Api\Shop\CheckoutContext; +use Sylius\Behat\Context\Api\Shop\ContactContext; +use Sylius\Behat\Context\Api\Shop\CurrencyContext; use Sylius\Behat\Context\Api\Shop\CustomerContext; use Sylius\Behat\Context\Api\Shop\ExchangeRateContext; -use Sylius\Behat\Context\Api\Shop\PromotionContext; -use Sylius\Behat\Context\Api\Shop\CheckoutContext; use Sylius\Behat\Context\Api\Shop\HomepageContext; +use Sylius\Behat\Context\Api\Shop\LocaleContext; use Sylius\Behat\Context\Api\Shop\LoginContext; -use Sylius\Behat\Context\Api\Shop\ProductContext; -use Sylius\Behat\Context\Api\Shop\ProductAttributeContext; -use Sylius\Behat\Context\Api\Shop\ProductVariantContext; -use Sylius\Behat\Context\Api\Shop\ProductReviewContext; -use Sylius\Behat\Context\Api\Shop\RegistrationContext; use Sylius\Behat\Context\Api\Shop\OrderContext; use Sylius\Behat\Context\Api\Shop\OrderItemContext; -use Sylius\Behat\Context\Api\Shop\PaymentRequestContext; use Sylius\Behat\Context\Api\Shop\PaymentContext; +use Sylius\Behat\Context\Api\Shop\PaymentRequestContext; +use Sylius\Behat\Context\Api\Shop\ProductAttributeContext; +use Sylius\Behat\Context\Api\Shop\ProductContext; +use Sylius\Behat\Context\Api\Shop\ProductReviewContext; +use Sylius\Behat\Context\Api\Shop\ProductVariantContext; +use Sylius\Behat\Context\Api\Shop\PromotionContext; +use Sylius\Behat\Context\Api\Shop\RegistrationContext; use Sylius\Behat\Context\Api\Shop\ShipmentContext; -use Sylius\Behat\Context\Api\Shop\LocaleContext; -use Sylius\Behat\Context\Api\Shop\ContactContext; -use Sylius\Behat\Context\Api\Shop\Checkout\CheckoutShippingContext; -use Sylius\Behat\Context\Api\Shop\Checkout\CheckoutCompleteContext; -use Sylius\Behat\Context\Api\Shop\Checkout\CheckoutOrderDetailsContext; use Sylius\Behat\Context\Api\Shop\TaxonContext; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use function Symfony\Component\DependencyInjection\Loader\Configurator\service;As per coding guidelines: "Sort PHP
useimports alphabetically and group by type (classes, functions, constants)"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Sylius/Behat/Resources/config/services/contexts/api/shop.php` around lines 14 - 42, The import block is not alphabetized; reorder the `use` statements so PHP imports are sorted alphabetically and grouped by type: place `use Sylius\Behat\Client\ResponseCheckerInterface;` before all `Sylius\Behat\Context\*` imports, then alphabetize all `Sylius\Behat\Context\Api\Shop\*` classes (e.g., `CartContext` before `ChannelContext`, `CheckoutContext` before `ContactContext`), keep the `Checkout\*` sub-namespace grouped together (e.g., `CheckoutShippingContext`, `CheckoutCompleteContext`, `CheckoutOrderDetailsContext`), and leave the function import `use function Symfony\Component\DependencyInjection\Loader\Configurator\service;` in its own group; update the list containing `AddressContext`, `ChannelContext`, `CurrencyContext`, `CartContext`, `CustomerContext`, `ExchangeRateContext`, `PromotionContext`, `CheckoutContext`, `HomepageContext`, `LoginContext`, `ProductContext`, `ProductAttributeContext`, `ProductVariantContext`, `ProductReviewContext`, `RegistrationContext`, `OrderContext`, `OrderItemContext`, `PaymentRequestContext`, `PaymentContext`, `ShipmentContext`, `LocaleContext`, `ContactContext`, `TaxonContext`, and `ResponseCheckerInterface` accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/Sylius/Behat/Resources/config/services/contexts/api/admin.php`:
- Around line 14-63: The import list is unsorted: move
Sylius\Behat\Service\Converter\IriConverter so it sits after all
Sylius\Behat\Context\* imports and then reorder all
Sylius\Behat\Context\Api\Admin\* imports alphabetically (e.g. ensure
ManagingChannelsContext comes before ManagingProductTaxonsContext), and finally
group and alphabetize the remaining imports (classes first, then functions like
service) so the entire block follows the project's “classes, functions,
constants” grouping and alphabetical ordering.
- Around line 86-93: The service registrations for
BrowsingCatalogPromotionProductVariantsContext,
ManagingChannelsBillingDataContext, RemovingTaxonContext, and
ManagingChannelPriceHistoryConfigContext are using ::class while most others use
string IDs; change these four registrations to use the existing string ID
convention (e.g. 'sylius.behat.context.api.admin.<appropriate_name>') and keep
the same ->args([...]) and dependencies
(service('sylius.behat.api_platform_client.admin'),
service(ResponseCheckerInterface::class), service('api_platform.iri_converter'))
so the service keys match the rest of the file; apply the same change to the
other occurrences mentioned (lines around 141-147, 377-383, 480-488) for
consistent naming.
In `@src/Sylius/Behat/Resources/config/services/contexts/api/common.php`:
- Around line 14-19: The use imports are out of alphabetical order; reorder the
use statements so class imports are alphabetized and grouped together (e.g.
ResponseCheckerInterface before SaveContext, ResponseContext, DebugContext) and
place the function import (service) after the class imports; adjust the block
containing SaveContext, ResponseContext, ResponseCheckerInterface, DebugContext,
ContainerConfigurator and the function import service to follow this sorted
grouping.
In `@src/Sylius/Behat/Resources/config/services/contexts/api/shop.php`:
- Around line 14-42: The import block is not alphabetized; reorder the `use`
statements so PHP imports are sorted alphabetically and grouped by type: place
`use Sylius\Behat\Client\ResponseCheckerInterface;` before all
`Sylius\Behat\Context\*` imports, then alphabetize all
`Sylius\Behat\Context\Api\Shop\*` classes (e.g., `CartContext` before
`ChannelContext`, `CheckoutContext` before `ContactContext`), keep the
`Checkout\*` sub-namespace grouped together (e.g., `CheckoutShippingContext`,
`CheckoutCompleteContext`, `CheckoutOrderDetailsContext`), and leave the
function import `use function
Symfony\Component\DependencyInjection\Loader\Configurator\service;` in its own
group; update the list containing `AddressContext`, `ChannelContext`,
`CurrencyContext`, `CartContext`, `CustomerContext`, `ExchangeRateContext`,
`PromotionContext`, `CheckoutContext`, `HomepageContext`, `LoginContext`,
`ProductContext`, `ProductAttributeContext`, `ProductVariantContext`,
`ProductReviewContext`, `RegistrationContext`, `OrderContext`,
`OrderItemContext`, `PaymentRequestContext`, `PaymentContext`,
`ShipmentContext`, `LocaleContext`, `ContactContext`, `TaxonContext`, and
`ResponseCheckerInterface` accordingly.
Summary by CodeRabbit