[Behat] Finish updating service definitions to php and cleanup#18861
Conversation
📝 WalkthroughWalkthroughThis pull request migrates Sylius Behat service container configuration files from XML to PHP format. It replaces XML service imports with PHP equivalents across API platform clients, context definitions, page services, and element configurations while adjusting service visibility declarations throughout the codebase. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 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 |
❌ Preview Environment deleted from BunnyshellAvailable commands:
|
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
src/Sylius/Behat/Resources/config/services/pages/admin/promotion.php (1)
19-43:⚠️ Potential issue | 🟠 MajorServices are now public due to missing explicit visibility declarations.
The global
defaults()->public()in mainservices.php(line 74) now makes these three promotion page services public—a behavior change from their previous private state. Compare withpayment.php(line 29-37): that file declaresdefaults()->public()locally and then explicitly marks each service->private().Add
$services->defaults()->public();after the parameters declaration, then add->private()to each service definition:Example fix
$parameters->set('sylius.behat.page.admin.promotion.create.class', CreatePage::class); // ... $services->defaults()->public(); $services ->set('sylius.behat.page.admin.promotion.create', '%sylius.behat.page.admin.promotion.create.class%') ->private() ->parent('sylius.behat.page.admin.crud.create') ->args(['sylius_admin_promotion_create']) ;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Sylius/Behat/Resources/config/services/pages/admin/promotion.php` around lines 19 - 43, The three promotion page services (CreatePage, UpdatePage, IndexPage) are unintentionally public due to the global defaults; after the parameter sets add $services->defaults()->public(); and mark each service definition (the ones calling ->set('sylius.behat.page.admin.promotion.create' / '.update' / '.index')) with ->private() before ->parent(...) so each service becomes private while keeping the local defaults->public() scope.src/Sylius/Behat/Resources/config/services/pages/admin/product.php (1)
33-33:⚠️ Potential issue | 🟡 MinorAlign parameter key and service ID naming for the
showpage.The parameter is keyed
sylius.behat.page.admin.product.show.class(line 33) while the service is registered assylius.behat.page.admin.product.show_page(line 90). Every other service in this file matches the parameter and service ID suffixes (e.g.,create_configurable/create_configurable.class). This naming mismatch should be resolved.The service ID
sylius.behat.page.admin.product.show_pageis actively used in three places insrc/Sylius/Behat/Resources/config/services/contexts/ui/admin.php, so consider the scope of the refactor:Option A — rename service ID to match parameter (3 files to update)
- ->set('sylius.behat.page.admin.product.show_page', '%sylius.behat.page.admin.product.show.class%') + ->set('sylius.behat.page.admin.product.show', '%sylius.behat.page.admin.product.show.class%')Also update references in
src/Sylius/Behat/Resources/config/services/contexts/ui/admin.phpat lines 147, 291, and 563.Option B — rename parameter key to match service ID (1 file to update)
-$parameters->set('sylius.behat.page.admin.product.show.class', ShowPage::class); +$parameters->set('sylius.behat.page.admin.product.show_page.class', ShowPage::class);- ->set('sylius.behat.page.admin.product.show_page', '%sylius.behat.page.admin.product.show.class%') + ->set('sylius.behat.page.admin.product.show_page', '%sylius.behat.page.admin.product.show_page.class%')🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Sylius/Behat/Resources/config/services/pages/admin/product.php` at line 33, The parameter key sylius.behat.page.admin.product.show.class does not match the service ID sylius.behat.page.admin.product.show_page; fix by choosing one of two actions: either rename the parameter to sylius.behat.page.admin.product.show_page.class (preferred, single-file change) so it matches the existing service ID, or rename the service to sylius.behat.page.admin.product.show (and update all usages of sylius.behat.page.admin.product.show_page in the admin contexts at the three call sites currently referencing it) so the parameter and service ID suffixes align consistently with other entries; update only the corresponding identifier(s) (parameter key or service ID and its three references) to restore consistent naming.src/Sylius/Behat/Resources/config/services/elements/admin.php (1)
125-128:⚠️ Potential issue | 🟠 MajorUse
sylius.behat.element.admin.crud.formparent for ShippingMethodFormElement.
ShippingMethodFormElementextendsCrud\FormElement, matching all other form elements in this file (Zone, Taxon, TaxCategory, PromotionCoupon, ProductOption, etc.), yet it usesparent('sylius.behat.element')instead ofparent('sylius.behat.element.admin.crud.form'). Update the parent service to match the pattern.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Sylius/Behat/Resources/config/services/elements/admin.php` around lines 125 - 128, The service declaration for sylius.behat.element.admin.shipping_method.form uses parent('sylius.behat.element') but ShippingMethodFormElement extends Crud\FormElement like other admin form elements; update the service for ShippingMethodFormElement (service id sylius.behat.element.admin.shipping_method.form) to use parent('sylius.behat.element.admin.crud.form') so it inherits the correct admin CRUD form configuration.
🧹 Nitpick comments (1)
src/Sylius/Behat/Resources/config/services/elements/admin/product.php (1)
28-32: Extractproduct_association_type.formto a dedicated configuration file.The codebase establishes a clear pattern where each distinct domain entity type has its own configuration file:
product_attribute.phpcontainsProductAttributeelements, and dedicated files organize other entity elements. Thesylius.behat.element.admin.product_association_type.formservice (lines 28-32) belongs to theProductAssociationTypedomain (fromAdmin\ProductAssociationType\FormElementnamespace), not theProductdomain. Extract it to a newsrc/Sylius/Behat/Resources/config/services/elements/admin/product_association_type.phpfile for consistency with the established organizational pattern.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Sylius/Behat/Resources/config/services/elements/admin/product.php` around lines 28 - 32, Remove the service definition for sylius.behat.element.admin.product_association_type.form from the current admin product elements file and move it into a new dedicated config file for the ProductAssociationType element; recreate the block with FormElement::class (the Admin\ProductAssociationType\FormElement class), keep ->parent('sylius.behat.element.admin.crud.form') and ->args([service(AutocompleteHelperInterface::class)]) exactly as-is, so the service id, parent and argument wiring remain identical but housed in its own product_association_type elements config.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/Sylius/Behat/Resources/config/services/api.php`:
- Around line 38-48: The child service definitions
sylius.behat.api_platform_client.shop and sylius.behat.api_platform_client.admin
are overriding the parent's full argument list by calling ->args(['shop']) which
replaces index 0 instead of setting the section string at the sixth constructor
parameter; change these to set only the sixth argument (index 5) using
replaceArgument(5, 'shop') and replaceArgument(5, 'admin') (or the equivalent
single-argument setter supported by the PHP service configurator) on the service
definitions that call ->parent('sylius.behat.api_platform_client') so the
parent's first five arguments (including the AbstractBrowser service) are
preserved while providing the section string to ApiPlatformClient::__construct.
In `@src/Sylius/Behat/Resources/config/services/elements/product.php`:
- Around line 82-90: The service for VerticalMenuElement is registered only
under the string ID 'sylius.behat.element.product.index.vertical_menu' but
ProductContext expects VerticalMenuElementInterface via autowiring; change the
service registration to register the interface by replacing that set call to use
VerticalMenuElementInterface::class as the service id and
VerticalMenuElement::class as the implementation, ensure the class import for
VerticalMenuElementInterface is added at the top of the file, and keep the
->parent('sylius.behat.element') chaining intact so Symfony can resolve the
interface injection.
In `@src/Sylius/Behat/Resources/config/services/elements/shop.php`:
- Around line 32-35: HomepageContext expects a MenuElementInterface but the
service is currently registered only as 'sylius.behat.element.shop.menu',
preventing autowiring; change the service registration to bind
MenuElementInterface to MenuElement (use MenuElementInterface::class as the
service id and MenuElement::class as the implementation) and add the use import
for Sylius\Behat\Element\Shop\MenuElementInterface so Symfony can autowire
MenuElement into HomepageContext.
In `@src/Sylius/Behat/Resources/config/services/pages.php`:
- Around line 30-49: The child service sylius.behat.symfony_page currently calls
->parent('sylius.behat.page')->args([service('router')]) which will replace the
parent's first arg; change this to explicitly set the router at the correct
index using ->arg(2, service('router')) so SymfonyPage's constructor
(SymfonyPage::__construct(Session $session, $parameters, RouterInterface
$router)) receives session at index 0, parameters at index 1 and router at index
2; keep sylius.behat.page and sylius.behat.page.error unchanged.
---
Outside diff comments:
In `@src/Sylius/Behat/Resources/config/services/elements/admin.php`:
- Around line 125-128: The service declaration for
sylius.behat.element.admin.shipping_method.form uses
parent('sylius.behat.element') but ShippingMethodFormElement extends
Crud\FormElement like other admin form elements; update the service for
ShippingMethodFormElement (service id
sylius.behat.element.admin.shipping_method.form) to use
parent('sylius.behat.element.admin.crud.form') so it inherits the correct admin
CRUD form configuration.
In `@src/Sylius/Behat/Resources/config/services/pages/admin/product.php`:
- Line 33: The parameter key sylius.behat.page.admin.product.show.class does not
match the service ID sylius.behat.page.admin.product.show_page; fix by choosing
one of two actions: either rename the parameter to
sylius.behat.page.admin.product.show_page.class (preferred, single-file change)
so it matches the existing service ID, or rename the service to
sylius.behat.page.admin.product.show (and update all usages of
sylius.behat.page.admin.product.show_page in the admin contexts at the three
call sites currently referencing it) so the parameter and service ID suffixes
align consistently with other entries; update only the corresponding
identifier(s) (parameter key or service ID and its three references) to restore
consistent naming.
In `@src/Sylius/Behat/Resources/config/services/pages/admin/promotion.php`:
- Around line 19-43: The three promotion page services (CreatePage, UpdatePage,
IndexPage) are unintentionally public due to the global defaults; after the
parameter sets add $services->defaults()->public(); and mark each service
definition (the ones calling ->set('sylius.behat.page.admin.promotion.create' /
'.update' / '.index')) with ->private() before ->parent(...) so each service
becomes private while keeping the local defaults->public() scope.
---
Nitpick comments:
In `@src/Sylius/Behat/Resources/config/services/elements/admin/product.php`:
- Around line 28-32: Remove the service definition for
sylius.behat.element.admin.product_association_type.form from the current admin
product elements file and move it into a new dedicated config file for the
ProductAssociationType element; recreate the block with FormElement::class (the
Admin\ProductAssociationType\FormElement class), keep
->parent('sylius.behat.element.admin.crud.form') and
->args([service(AutocompleteHelperInterface::class)]) exactly as-is, so the
service id, parent and argument wiring remain identical but housed in its own
product_association_type elements config.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (61)
src/Sylius/Behat/Resources/config/services.phpsrc/Sylius/Behat/Resources/config/services/api.phpsrc/Sylius/Behat/Resources/config/services/api.xmlsrc/Sylius/Behat/Resources/config/services/contexts.phpsrc/Sylius/Behat/Resources/config/services/contexts.xmlsrc/Sylius/Behat/Resources/config/services/contexts/api/admin.phpsrc/Sylius/Behat/Resources/config/services/contexts/api/common.phpsrc/Sylius/Behat/Resources/config/services/contexts/api/shop.phpsrc/Sylius/Behat/Resources/config/services/contexts/cli.phpsrc/Sylius/Behat/Resources/config/services/contexts/domain.phpsrc/Sylius/Behat/Resources/config/services/contexts/hook.phpsrc/Sylius/Behat/Resources/config/services/contexts/setup.phpsrc/Sylius/Behat/Resources/config/services/contexts/transform.phpsrc/Sylius/Behat/Resources/config/services/contexts/ui/admin.phpsrc/Sylius/Behat/Resources/config/services/contexts/ui/common.phpsrc/Sylius/Behat/Resources/config/services/contexts/ui/shop.phpsrc/Sylius/Behat/Resources/config/services/elements/admin.phpsrc/Sylius/Behat/Resources/config/services/elements/admin/product.phpsrc/Sylius/Behat/Resources/config/services/elements/admin/product_attribute.phpsrc/Sylius/Behat/Resources/config/services/elements/product.phpsrc/Sylius/Behat/Resources/config/services/elements/shop.phpsrc/Sylius/Behat/Resources/config/services/pages.phpsrc/Sylius/Behat/Resources/config/services/pages.xmlsrc/Sylius/Behat/Resources/config/services/pages/admin.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/account.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/admin_user.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/catalog_promotion.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/channel.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/country.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/currency.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/customer.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/customer_group.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/dashboard.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/exchange_rate.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/impersonate_user.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/inventory.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/locale.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/order.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/payment_method.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/product.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/product_association_type.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/product_attribute.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/product_option.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/product_review.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/product_variant.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/promotion.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/promotion_coupon.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/shipment.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/shipping_category.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/shipping_method.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/tax_category.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/tax_rate.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/taxon.phpsrc/Sylius/Behat/Resources/config/services/pages/admin/zone.phpsrc/Sylius/Behat/Resources/config/services/pages/shop.phpsrc/Sylius/Behat/Resources/config/services/pages/shop/account.phpsrc/Sylius/Behat/Resources/config/services/pages/shop/checkout.phpsrc/Sylius/Behat/Resources/config/services/pages/shop/contact.phpsrc/Sylius/Behat/Resources/config/services/pages/shop/order.phpsrc/Sylius/Behat/Resources/config/services/pages/shop/product.phpsrc/Sylius/Behat/Resources/config/services/pages/test_plugin.php
💤 Files with no reviewable changes (30)
- src/Sylius/Behat/Resources/config/services/pages/admin/taxon.php
- src/Sylius/Behat/Resources/config/services/pages/admin/inventory.php
- src/Sylius/Behat/Resources/config/services/pages/shop/contact.php
- src/Sylius/Behat/Resources/config/services/pages.xml
- src/Sylius/Behat/Resources/config/services/pages/admin/product_attribute.php
- src/Sylius/Behat/Resources/config/services/pages/admin/product_review.php
- src/Sylius/Behat/Resources/config/services/api.xml
- src/Sylius/Behat/Resources/config/services/pages/admin/country.php
- src/Sylius/Behat/Resources/config/services/pages/admin/impersonate_user.php
- src/Sylius/Behat/Resources/config/services/pages/admin/dashboard.php
- src/Sylius/Behat/Resources/config/services/contexts.xml
- src/Sylius/Behat/Resources/config/services/pages/admin/currency.php
- src/Sylius/Behat/Resources/config/services/pages/test_plugin.php
- src/Sylius/Behat/Resources/config/services/pages/admin/customer_group.php
- src/Sylius/Behat/Resources/config/services/pages/admin/locale.php
- src/Sylius/Behat/Resources/config/services/pages/admin/product_option.php
- src/Sylius/Behat/Resources/config/services/pages/admin/shipping_method.php
- src/Sylius/Behat/Resources/config/services/pages/admin/product_association_type.php
- src/Sylius/Behat/Resources/config/services/pages/admin/shipping_category.php
- src/Sylius/Behat/Resources/config/services/pages/admin/shipment.php
- src/Sylius/Behat/Resources/config/services/pages/shop/account.php
- src/Sylius/Behat/Resources/config/services/pages/admin/payment_method.php
- src/Sylius/Behat/Resources/config/services/pages/admin/product_variant.php
- src/Sylius/Behat/Resources/config/services/pages/shop.php
- src/Sylius/Behat/Resources/config/services/pages/admin/promotion_coupon.php
- src/Sylius/Behat/Resources/config/services/pages/admin/tax_category.php
- src/Sylius/Behat/Resources/config/services/pages/admin/tax_rate.php
- src/Sylius/Behat/Resources/config/services/pages/admin/exchange_rate.php
- src/Sylius/Behat/Resources/config/services/pages/admin/zone.php
- src/Sylius/Behat/Resources/config/services/pages/admin/customer.php
Summary by CodeRabbit
Release Notes