Skip to content

[Behat] Update API context services config from xml to php#18855

Merged
TheMilek merged 4 commits intoSylius:2.3from
NoResponseMate:behat/update-services-definition-to-php-api-contexts
Feb 23, 2026
Merged

[Behat] Update API context services config from xml to php#18855
TheMilek merged 4 commits intoSylius:2.3from
NoResponseMate:behat/update-services-definition-to-php-api-contexts

Conversation

@NoResponseMate
Copy link
Copy Markdown
Contributor

@NoResponseMate NoResponseMate commented Feb 20, 2026

Q A
Branch? 2.3
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Related tickets partially #18822
License MIT

Summary by CodeRabbit

  • Refactor
    • Migrated API test service configuration files from XML to PHP format for improved maintainability and consistency in the testing infrastructure.

@NoResponseMate NoResponseMate requested review from a team as code owners February 20, 2026 14:29
@NoResponseMate NoResponseMate added Behat Issues and PRs aimed at improving Behat usage. Maintenance CI configurations, READMEs, releases, etc. labels Feb 20, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 20, 2026

❌ Preview Environment deleted from Bunnyshell

Available commands:

  • 🚀 /bns:deploy to redeploy the environment

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 20, 2026

📝 Walkthrough

Walkthrough

This 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

Cohort / File(s) Summary
Service Loader Configuration
src/Sylius/Behat/Resources/config/services/contexts.xml
Updated import directive from api.xml to api.php to use the new PHP-based API contexts loader.
API Contexts Aggregator
src/Sylius/Behat/Resources/config/services/contexts/api.php, src/Sylius/Behat/Resources/config/services/contexts/api.xml
Converted API contexts loader from XML to PHP. The new api.php uses a static function to import all api/**/*.php files via container configuration.
Admin API Contexts
src/Sylius/Behat/Resources/config/services/contexts/api/admin.php, src/Sylius/Behat/Resources/config/services/contexts/api/admin.xml
Migrated admin context service definitions (LoginContext, TranslationContext, 40+ managing/browsing contexts) from XML to PHP with complete dependency wiring preserved.
Common API Contexts
src/Sylius/Behat/Resources/config/services/contexts/api/common.php, src/Sylius/Behat/Resources/config/services/contexts/api/common.xml
Converted common context services (SaveContext for admin/shop, ResponseContext, DebugContext) from XML to PHP configuration.
Email API Contexts
src/Sylius/Behat/Resources/config/services/contexts/api/email.php, src/Sylius/Behat/Resources/config/services/contexts/api/email.xml
Migrated EmailContext service definition from XML to PHP with required dependencies (shared storage, email checker, translator).
Shop API Contexts
src/Sylius/Behat/Resources/config/services/contexts/api/shop.php, src/Sylius/Behat/Resources/config/services/contexts/api/shop.xml
Converted shop context service definitions (20+ contexts including address, product, order, payment, shipment) from XML to PHP format.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~35 minutes

Possibly related PRs

Suggested labels

API, Admin, Shop

Suggested reviewers

  • TheMilek

Poem

🐰 Hops of joy! XML files take their flight,
PHP configs now gleam so bright,
Services wired with elegant grace,
Dependencies dancing in their rightful place!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: migrating Behat API context service configurations from XML to PHP format across multiple files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (4)
src/Sylius/Behat/Resources/config/services/contexts/api/common.php (1)

14-19: use imports are not sorted alphabetically.

As per coding guidelines, use imports should be sorted alphabetically and grouped by type. Sylius\Behat\Client\ResponseCheckerInterface should come before the Sylius\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 use imports 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: use imports are not sorted alphabetically, with IriConverter misplaced among Context imports.

Sylius\Behat\Service\Converter\IriConverter (line 27) is interleaved between Context\Api\Admin\* imports. It belongs after all Sylius\Behat\Context\* imports since Service sorts after Context. Additionally, the Context\Api\Admin\* imports themselves are not in alphabetical order (e.g., ManagingProductTaxonsContext before ManagingChannelsContext).

♻️ 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 use imports 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 ::class as their service ID (BrowsingCatalogPromotionProductVariantsContext, ManagingChannelsBillingDataContext, RemovingTaxonContext, ManagingChannelPriceHistoryConfigContext) while the majority use the sylius.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: use imports are not sorted alphabetically.

Same issue as in common.php — imports should be sorted alphabetically with Sylius\Behat\Client\ResponseCheckerInterface before all Sylius\Behat\Context\* classes, and the Context\Api\Shop\* classes sorted alphabetically (e.g., CartContext before ChannelContext, CheckoutContext before ContactContext, sub-namespace Checkout\* 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 use imports 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.

@TheMilek TheMilek merged commit afbb6be into Sylius:2.3 Feb 23, 2026
36 checks passed
@NoResponseMate NoResponseMate deleted the behat/update-services-definition-to-php-api-contexts branch February 23, 2026 10:25
@NoResponseMate NoResponseMate mentioned this pull request Feb 26, 2026
27 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Behat Issues and PRs aimed at improving Behat usage. Maintenance CI configurations, READMEs, releases, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants