[Behat] Update Setup, Transform and UI contexts config from xml to php#18857
Conversation
❌ Preview Environment deleted from BunnyshellAvailable commands:
|
📝 WalkthroughWalkthroughThis PR migrates Sylius Behat context service configurations from XML to PHP format. The setup, transform, and UI context definitions are converted to PHP using Symfony's DependencyInjection configurator pattern, maintaining equivalent service registrations and dependency wiring throughout. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes Possibly related PRs
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 (7)
src/Sylius/Behat/Resources/config/services/contexts/ui/common.php (1)
14-22:useimports are not sorted alphabetically.
EmailContext(line 19) andSaveContext(line 20) should be placed beforeThemeContext(line 17) to maintain alphabetical order. As per coding guidelines: "Sort PHPuseimports alphabetically and group by type".Suggested order
use Sylius\Behat\Context\Ui\BrowserContext; use Sylius\Behat\Context\Ui\ChannelContext; use Sylius\Behat\Context\Ui\CustomerContext; +use Sylius\Behat\Context\Ui\EmailContext; +use Sylius\Behat\Context\Ui\SaveContext; use Sylius\Behat\Context\Ui\ThemeContext; use Sylius\Behat\Context\Ui\UserContext; -use Sylius\Behat\Context\Ui\EmailContext; -use Sylius\Behat\Context\Ui\SaveContext; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use function Symfony\Component\DependencyInjection\Loader\Configurator\service;🤖 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/ui/common.php` around lines 14 - 22, Reorder the PHP use imports in this file to be alphabetically sorted and grouped by type; specifically move Sylius\Behat\Context\Ui\EmailContext and Sylius\Behat\Context\Ui\SaveContext so they appear before Sylius\Behat\Context\Ui\ThemeContext, ensuring all other use statements remain in the same grouping and alphabetical order (e.g., BrowserContext, ChannelContext, CustomerContext, EmailContext, SaveContext, ThemeContext, UserContext).src/Sylius/Behat/Resources/config/services/contexts/setup.php (2)
114-114: Inline FQCNs used to avoid naming collisions — consider using aliases instead.Lines 114, 242, and 401 use inline
\Sylius\Behat\Context\Setup\Checkout\AddressContext::class,\Sylius\Behat\Context\Setup\PaymentContext::class, and\Sylius\Behat\Context\Setup\ShippingContext::classrespectively, because the short class names collide with already-importedCheckout\PaymentContext,Checkout\ShippingContext, andSetup\AddressContext. Using import aliases (e.g.,use ... as SetupPaymentContext) would improve readability and consistency.Example alias approach
-use Sylius\Behat\Context\Setup\Checkout\ShippingContext; -use Sylius\Behat\Context\Setup\Checkout\PaymentContext; +use Sylius\Behat\Context\Setup\Checkout\AddressContext as CheckoutAddressContext; +use Sylius\Behat\Context\Setup\Checkout\PaymentContext as CheckoutPaymentContext; +use Sylius\Behat\Context\Setup\Checkout\ShippingContext as CheckoutShippingContext; +use Sylius\Behat\Context\Setup\PaymentContext; +use Sylius\Behat\Context\Setup\ShippingContext;Then replace inline FQCNs:
- ->set('sylius.behat.context.setup.checkout.address', \Sylius\Behat\Context\Setup\Checkout\AddressContext::class) + ->set('sylius.behat.context.setup.checkout.address', CheckoutAddressContext::class)- ->set('sylius.behat.context.setup.payment', \Sylius\Behat\Context\Setup\PaymentContext::class) + ->set('sylius.behat.context.setup.payment', PaymentContext::class)- ->set('sylius.behat.context.setup.shipping', \Sylius\Behat\Context\Setup\ShippingContext::class) + ->set('sylius.behat.context.setup.shipping', ShippingContext::class)Also applies to: 242-242, 401-401
🤖 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/setup.php` at line 114, Replace the inline fully-qualified class names with aliased imports to avoid name collisions and improve readability: add use statements with aliases like "use Sylius\Behat\Context\Setup\PaymentContext as SetupPaymentContext", "use Sylius\Behat\Context\Setup\ShippingContext as SetupShippingContext", and "use Sylius\Behat\Context\Setup\Checkout\AddressContext as SetupCheckoutAddressContext" at the top of the file, then update the service registrations that currently reference \Sylius\Behat\Context\Setup\Checkout\AddressContext::class, \Sylius\Behat\Context\Setup\PaymentContext::class, and \Sylius\Behat\Context\Setup\ShippingContext::class to use the new aliased class names (SetupCheckoutAddressContext, SetupPaymentContext, SetupShippingContext).
14-50:useimports are not sorted alphabetically and mix namespaces.Several issues:
ChannelContext(line 21) should come beforeCheckoutContext(line 18) andCheckout\*sub-namespace imports.Checkout\PaymentContext(line 20) should come beforeCheckout\ShippingContext(line 19).AdminSecurityContext(line 38) should come near the top ofSetup\*imports.CatalogPromotionContext(line 47) andPaymentRequestContext(line 48) are appended at the end.- Non-
Behatimports (RandomnessGeneratorInterfaceline 29,TestThemeConfigurationManagerInterfaceline 44) are interleaved withBehat\Context\Setup\*imports instead of being grouped separately.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/setup.php` around lines 14 - 50, Reorder the PHP use imports in this file to follow the project's guideline: group and alphabetize imports by type (class imports together, then functions/constants); within the Sylius\Behat\Context\Setup\* group, place ChannelContext before CheckoutContext and its subnamespaces, ensure Checkout\PaymentContext comes before Checkout\ShippingContext, move AdminSecurityContext up with the other Setup contexts, and insert CatalogPromotionContext and PaymentRequestContext in their alphabetical positions; also pull non-Behat imports (RandomnessGeneratorInterface, TestThemeConfigurationManagerInterface) out of the Behat Setup group into their own sorted group, and keep the service function import (service) in the functions group.src/Sylius/Behat/Resources/config/services/contexts/transform.php (1)
14-52:useimports are not sorted alphabetically.
AdminUserContext,CartContext,ShopUserContext,ZoneContext, andZoneMemberContext(lines 46–50) are appended at the end instead of being placed in their correct alphabetical positions. The same applies toProductAssociationTypeContext(line 29) andProductOptionValueContext(line 32) which should come afterProductContext.As per coding guidelines: "Sort PHP
useimports alphabetically and group by type (classes, functions, constants)".Suggested sorted order
-use Sylius\Behat\Context\Transform\AddressContext; -use Sylius\Behat\Context\Transform\CatalogPromotionContext; -use Sylius\Behat\Context\Transform\ChannelContext; -use Sylius\Behat\Context\Transform\CountryContext; -use Sylius\Behat\Context\Transform\CouponContext; -use Sylius\Behat\Context\Transform\CurrencyContext; -use Sylius\Behat\Context\Transform\CustomerContext; -use Sylius\Behat\Context\Transform\CustomerGroupContext; -use Sylius\Behat\Context\Transform\DateTimeContext; -use Sylius\Behat\Context\Transform\ExchangeRateContext; -use Sylius\Behat\Context\Transform\LexicalContext; -use Sylius\Behat\Context\Transform\LocaleContext; -use Sylius\Behat\Context\Transform\OrderContext; -use Sylius\Behat\Context\Transform\PaymentMethodContext; -use Sylius\Behat\Context\Transform\ProductContext; -use Sylius\Behat\Context\Transform\ProductAssociationTypeContext; -use Sylius\Behat\Context\Transform\ProductAttributeContext; -use Sylius\Behat\Context\Transform\ProductOptionContext; -use Sylius\Behat\Context\Transform\ProductOptionValueContext; -use Sylius\Behat\Context\Transform\ProductReviewContext; -use Sylius\Behat\Context\Transform\ProductVariantContext; -use Sylius\Behat\Context\Transform\PromotionContext; -use Sylius\Behat\Context\Transform\ProvinceContext; -use Sylius\Behat\Context\Transform\SharedStorageContext; -use Sylius\Behat\Context\Transform\ShippingCalculatorContext; -use Sylius\Behat\Context\Transform\ShippingCategoryContext; -use Sylius\Behat\Context\Transform\ShippingMethodContext; -use Sylius\Behat\Context\Transform\TaxCategoryContext; -use Sylius\Behat\Context\Transform\TaxRateContext; -use Sylius\Behat\Context\Transform\TaxonContext; -use Sylius\Behat\Context\Transform\ThemeContext; -use Sylius\Behat\Context\Transform\UserContext; -use Sylius\Behat\Context\Transform\AdminUserContext; -use Sylius\Behat\Context\Transform\CartContext; -use Sylius\Behat\Context\Transform\ZoneContext; -use Sylius\Behat\Context\Transform\ZoneMemberContext; -use Sylius\Behat\Context\Transform\ShopUserContext; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use function Symfony\Component\DependencyInjection\Loader\Configurator\service; +use Sylius\Behat\Context\Transform\AddressContext; +use Sylius\Behat\Context\Transform\AdminUserContext; +use Sylius\Behat\Context\Transform\CartContext; +use Sylius\Behat\Context\Transform\CatalogPromotionContext; +use Sylius\Behat\Context\Transform\ChannelContext; +use Sylius\Behat\Context\Transform\CountryContext; +use Sylius\Behat\Context\Transform\CouponContext; +use Sylius\Behat\Context\Transform\CurrencyContext; +use Sylius\Behat\Context\Transform\CustomerContext; +use Sylius\Behat\Context\Transform\CustomerGroupContext; +use Sylius\Behat\Context\Transform\DateTimeContext; +use Sylius\Behat\Context\Transform\ExchangeRateContext; +use Sylius\Behat\Context\Transform\LexicalContext; +use Sylius\Behat\Context\Transform\LocaleContext; +use Sylius\Behat\Context\Transform\OrderContext; +use Sylius\Behat\Context\Transform\PaymentMethodContext; +use Sylius\Behat\Context\Transform\ProductAssociationTypeContext; +use Sylius\Behat\Context\Transform\ProductAttributeContext; +use Sylius\Behat\Context\Transform\ProductContext; +use Sylius\Behat\Context\Transform\ProductOptionContext; +use Sylius\Behat\Context\Transform\ProductOptionValueContext; +use Sylius\Behat\Context\Transform\ProductReviewContext; +use Sylius\Behat\Context\Transform\ProductVariantContext; +use Sylius\Behat\Context\Transform\PromotionContext; +use Sylius\Behat\Context\Transform\ProvinceContext; +use Sylius\Behat\Context\Transform\SharedStorageContext; +use Sylius\Behat\Context\Transform\ShippingCalculatorContext; +use Sylius\Behat\Context\Transform\ShippingCategoryContext; +use Sylius\Behat\Context\Transform\ShippingMethodContext; +use Sylius\Behat\Context\Transform\ShopUserContext; +use Sylius\Behat\Context\Transform\TaxCategoryContext; +use Sylius\Behat\Context\Transform\TaxRateContext; +use Sylius\Behat\Context\Transform\TaxonContext; +use Sylius\Behat\Context\Transform\ThemeContext; +use Sylius\Behat\Context\Transform\UserContext; +use Sylius\Behat\Context\Transform\ZoneContext; +use Sylius\Behat\Context\Transform\ZoneMemberContext; +use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use function Symfony\Component\DependencyInjection\Loader\Configurator\service;🤖 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/transform.php` around lines 14 - 52, The PHP "use" imports in transform.php are not sorted alphabetically; reorder the class imports so they are alphabetized (e.g., move ProductAssociationTypeContext after ProductContext, ProductOptionValueContext after ProductOptionContext, and place AdminUserContext, CartContext, ShopUserContext, ZoneContext, ZoneMemberContext into their correct alphabetical positions among the other Sylius\Behat\Context\Transform\* imports) while keeping the function import (service) separate and after the class imports; ensure grouping (classes first, then functions/constants) and consistent ordering for all listed classes (AddressContext, CatalogPromotionContext, ChannelContext, ..., ZoneMemberContext).src/Sylius/Behat/Resources/config/services/contexts/ui/shop.php (1)
14-43:useimports are not sorted alphabetically; non-Context imports are interleaved.Same issue as in other files — imports are roughly grouped by functional area rather than sorted alphabetically. Element/Service interface imports (lines 29–31, 36) are interleaved with Context class imports. As per coding guidelines: "Sort PHP
useimports alphabetically and group by type".🤖 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/ui/shop.php` around lines 14 - 43, The use imports in this file are not alphabetized and mix Context classes with Element/Service interfaces; reorder the use statements so they are alphabetically sorted and grouped by type (Contexts first, then Elements, then Services/interfaces), for example ensure ErrorPageContext, LocaleContext, LoginContext, CheckoutContext, etc. appear in alphabetical order within the Context group and interfaces like CheckoutSubtotalElementInterface, CartWidgetElementInterface, LowestPriceInformationElementInterface, SessionManagerInterface are grouped and alphabetized in their own block; update the import list to follow this grouped alphabetical ordering.src/Sylius/Behat/Resources/config/services/contexts/ui/admin.php (2)
488-497: Inline FQCN forFilterElement— import the class for consistency.Line 495 uses
\Sylius\Behat\Element\Admin\TaxRate\FilterElement::classinline. Since there's already aFilterElementimported from theCatalogPromotionnamespace (line 22), you'll need an alias.Suggested fix
Add to imports:
use Sylius\Behat\Element\Admin\TaxRate\FilterElement as TaxRateFilterElement;Then update line 495:
- service(\Sylius\Behat\Element\Admin\TaxRate\FilterElement::class), + service(TaxRateFilterElement::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/contexts/ui/admin.php` around lines 488 - 497, The service definition for ManagingTaxRateContext uses an inline FQCN for \Sylius\Behat\Element\Admin\TaxRate\FilterElement::class; add an import alias for that class (e.g. use Sylius\Behat\Element\Admin\TaxRate\FilterElement as TaxRateFilterElement;) and then replace the inline FQCN in the args array with TaxRateFilterElement::class to match the existing imported FilterElement naming pattern and avoid the fully-qualified inline reference (refer to ManagingTaxRateContext and the args array where FilterElement is currently provided).
14-73:useimports are not sorted alphabetically; Element imports are interleaved with Context imports.This file has the most pronounced sorting issues. For example:
BrowsingCatalogPromotionProductVariantsContext(line 23) should precedeDashboardContext(line 14), and Element/interface imports (lines 21–22, 25–27, 52) are scattered among Context imports. As per coding guidelines: "Sort PHPuseimports alphabetically and group by type".🤖 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/ui/admin.php` around lines 14 - 73, The use imports are unsorted and Element/interface imports are interleaved with Context imports; reorder all use statements alphabetically and group by type (all Context classes first, then Element classes, then Element interfaces, then functions), e.g. move BrowsingCatalogPromotionProductVariantsContext so it appears before DashboardContext, place FormElement and FilterElement together with other Element imports, and group FormElementInterface, DiscountedProductsCheckingPeriodInputElementInterface, LowestPriceFlagElementInterface, ExcludeTaxonsFromShowingLowestPriceInputElementInterface with other interface imports; keep the "use function service" entry in the functions group.
🤖 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/setup.php`:
- Line 114: Replace the inline fully-qualified class names with aliased imports
to avoid name collisions and improve readability: add use statements with
aliases like "use Sylius\Behat\Context\Setup\PaymentContext as
SetupPaymentContext", "use Sylius\Behat\Context\Setup\ShippingContext as
SetupShippingContext", and "use
Sylius\Behat\Context\Setup\Checkout\AddressContext as
SetupCheckoutAddressContext" at the top of the file, then update the service
registrations that currently reference
\Sylius\Behat\Context\Setup\Checkout\AddressContext::class,
\Sylius\Behat\Context\Setup\PaymentContext::class, and
\Sylius\Behat\Context\Setup\ShippingContext::class to use the new aliased class
names (SetupCheckoutAddressContext, SetupPaymentContext, SetupShippingContext).
- Around line 14-50: Reorder the PHP use imports in this file to follow the
project's guideline: group and alphabetize imports by type (class imports
together, then functions/constants); within the Sylius\Behat\Context\Setup\*
group, place ChannelContext before CheckoutContext and its subnamespaces, ensure
Checkout\PaymentContext comes before Checkout\ShippingContext, move
AdminSecurityContext up with the other Setup contexts, and insert
CatalogPromotionContext and PaymentRequestContext in their alphabetical
positions; also pull non-Behat imports (RandomnessGeneratorInterface,
TestThemeConfigurationManagerInterface) out of the Behat Setup group into their
own sorted group, and keep the service function import (service) in the
functions group.
In `@src/Sylius/Behat/Resources/config/services/contexts/transform.php`:
- Around line 14-52: The PHP "use" imports in transform.php are not sorted
alphabetically; reorder the class imports so they are alphabetized (e.g., move
ProductAssociationTypeContext after ProductContext, ProductOptionValueContext
after ProductOptionContext, and place AdminUserContext, CartContext,
ShopUserContext, ZoneContext, ZoneMemberContext into their correct alphabetical
positions among the other Sylius\Behat\Context\Transform\* imports) while
keeping the function import (service) separate and after the class imports;
ensure grouping (classes first, then functions/constants) and consistent
ordering for all listed classes (AddressContext, CatalogPromotionContext,
ChannelContext, ..., ZoneMemberContext).
In `@src/Sylius/Behat/Resources/config/services/contexts/ui/admin.php`:
- Around line 488-497: The service definition for ManagingTaxRateContext uses an
inline FQCN for \Sylius\Behat\Element\Admin\TaxRate\FilterElement::class; add an
import alias for that class (e.g. use
Sylius\Behat\Element\Admin\TaxRate\FilterElement as TaxRateFilterElement;) and
then replace the inline FQCN in the args array with TaxRateFilterElement::class
to match the existing imported FilterElement naming pattern and avoid the
fully-qualified inline reference (refer to ManagingTaxRateContext and the args
array where FilterElement is currently provided).
- Around line 14-73: The use imports are unsorted and Element/interface imports
are interleaved with Context imports; reorder all use statements alphabetically
and group by type (all Context classes first, then Element classes, then Element
interfaces, then functions), e.g. move
BrowsingCatalogPromotionProductVariantsContext so it appears before
DashboardContext, place FormElement and FilterElement together with other
Element imports, and group FormElementInterface,
DiscountedProductsCheckingPeriodInputElementInterface,
LowestPriceFlagElementInterface,
ExcludeTaxonsFromShowingLowestPriceInputElementInterface with other interface
imports; keep the "use function service" entry in the functions group.
In `@src/Sylius/Behat/Resources/config/services/contexts/ui/common.php`:
- Around line 14-22: Reorder the PHP use imports in this file to be
alphabetically sorted and grouped by type; specifically move
Sylius\Behat\Context\Ui\EmailContext and Sylius\Behat\Context\Ui\SaveContext so
they appear before Sylius\Behat\Context\Ui\ThemeContext, ensuring all other use
statements remain in the same grouping and alphabetical order (e.g.,
BrowserContext, ChannelContext, CustomerContext, EmailContext, SaveContext,
ThemeContext, UserContext).
In `@src/Sylius/Behat/Resources/config/services/contexts/ui/shop.php`:
- Around line 14-43: The use imports in this file are not alphabetized and mix
Context classes with Element/Service interfaces; reorder the use statements so
they are alphabetically sorted and grouped by type (Contexts first, then
Elements, then Services/interfaces), for example ensure ErrorPageContext,
LocaleContext, LoginContext, CheckoutContext, etc. appear in alphabetical order
within the Context group and interfaces like CheckoutSubtotalElementInterface,
CartWidgetElementInterface, LowestPriceInformationElementInterface,
SessionManagerInterface are grouped and alphabetized in their own block; update
the import list to follow this grouped alphabetical ordering.
Summary by CodeRabbit