[Behat][Shop] Update pages config from xml to php#18859
Conversation
📝 WalkthroughWalkthroughThis PR migrates Symfony Dependency Injection service configurations for Behat test pages from XML to PHP format. All XML definition files for shop page objects (account, checkout, contact, order, payment request, product) and test plugin pages are replaced with equivalent PHP configuration files. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 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 |
❌ Preview Environment deleted from BunnyshellAvailable commands:
|
There was a problem hiding this comment.
🧹 Nitpick comments (5)
src/Sylius/Behat/Resources/config/services/pages/shop/contact.php (1)
23-29:defaults()->public()is a no-op here and consistently appears across the entire pages configuration directory.
$services->defaults()->public()sets the default visibility to public, but every service in this file (and in all 7 similar page configuration files) immediately overrides it with->private(), making thedefaults()call have no practical effect. This pattern is consistent across the entire pages configuration directory, suggesting it may be intentional for consistency or future extensibility — but it could be removed to avoid misleading readers.♻️ Proposed simplification
- $services->defaults()->public(); - $services ->set('sylius.behat.page.shop.contact', '%sylius.behat.page.shop.contact.class%') - ->private() ->parent('sylius.behat.page.shop.page') ;🤖 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/shop/contact.php` around lines 23 - 29, The call to $services->defaults()->public() is redundant because every service defined here (e.g., 'sylius.behat.page.shop.contact' which immediately calls ->private() and sets parent 'sylius.behat.page.shop.page') overrides that default; remove the $services->defaults()->public() line from this file (and the same line from the other pages config files) so the configuration is not misleading, keeping the service definitions (set(...)->private()->parent(...)) intact.src/Sylius/Behat/Resources/config/services/pages/shop/product.php (1)
14-15:useimports withinSylius\Behat\Page\Shop\Product\*are not sorted alphabetically.
IndexPage(I) should precedeShowPage(S). As per coding guidelines, PHPuseimports must be sorted alphabetically.♻️ Proposed fix
-use Sylius\Behat\Page\Shop\Product\ShowPage; -use Sylius\Behat\Page\Shop\Product\IndexPage; +use Sylius\Behat\Page\Shop\Product\IndexPage; +use Sylius\Behat\Page\Shop\Product\ShowPage;🤖 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/shop/product.php` around lines 14 - 15, The two PHP use imports for Sylius\Behat\Page\Shop\Product are out of alphabetical order; update the use statements so IndexPage appears before ShowPage (swap the order of the use lines referencing IndexPage and ShowPage in the file) to comply with the project's import sorting guideline.src/Sylius/Behat/Resources/config/services/pages/shop/order.php (1)
14-15:useimports are not sorted alphabetically.
ShowPage(S) should precedeThankYouPage(T). As per coding guidelines, PHPuseimports must be sorted alphabetically.♻️ Proposed fix
-use Sylius\Behat\Page\Shop\Order\ThankYouPage; -use Sylius\Behat\Page\Shop\Order\ShowPage; +use Sylius\Behat\Page\Shop\Order\ShowPage; +use Sylius\Behat\Page\Shop\Order\ThankYouPage;🤖 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/shop/order.php` around lines 14 - 15, The two PHP use imports are not alphabetized: swap the order so ShowPage comes before ThankYouPage (i.e., ensure the use statements reference ShowPage then ThankYouPage) to comply with the project's alphabetical import convention; update the use block containing ShowPage and ThankYouPage accordingly (or run your project's PSR-12/CS fixer) so imports are sorted.src/Sylius/Behat/Resources/config/services/pages/shop/checkout.php (1)
14-18:useimports are not sorted alphabetically.
CompletePage(C) should precedeSelectPaymentPage/SelectShippingPage(S). As per coding guidelines, PHPuseimports must be sorted alphabetically.♻️ Proposed fix
use Sylius\Behat\Page\Shop\Checkout\AddressPage; -use Sylius\Behat\Page\Shop\Checkout\SelectPaymentPage; -use Sylius\Behat\Page\Shop\Checkout\SelectShippingPage; use Sylius\Behat\Page\Shop\Checkout\CompletePage; +use Sylius\Behat\Page\Shop\Checkout\SelectPaymentPage; +use Sylius\Behat\Page\Shop\Checkout\SelectShippingPage; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;🤖 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/shop/checkout.php` around lines 14 - 18, Reorder the PHP use imports so they are alphabetically sorted: move Sylius\Behat\Page\Shop\Checkout\CompletePage to come before Sylius\Behat\Page\Shop\Checkout\SelectPaymentPage and Sylius\Behat\Page\Shop\Checkout\SelectShippingPage; ensure the block containing AddressPage, CompletePage, SelectPaymentPage, SelectShippingPage and Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator is sorted lexicographically by full FQCN to satisfy the coding guideline.src/Sylius/Behat/Resources/config/services/pages/shop.php (1)
30-34: Add->abstract()to maintain consistency with peer parent services.
Sylius\Behat\Page\Shop\Pageis declaredabstract, and its peer parent services inpages.xml(sylius.behat.page,sylius.behat.symfony_page) are both markedabstract="true". The DI service should include->abstract()to preserve this semantic intent and align with the XML configuration pattern.♻️ Proposed fix
$services ->set('sylius.behat.page.shop.page', Page::class) ->private() + ->abstract() ->parent('sylius.behat.symfony_page') ;🤖 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/shop.php` around lines 30 - 34, The service definition for sylius.behat.page.shop.page currently sets Page::class, marks it private, and sets parent('sylius.behat.symfony_page') but omits ->abstract(); update the service definition for sylius.behat.page.shop.page (the one using Page::class and parent('sylius.behat.symfony_page')) to call ->abstract() so the DI definition matches the abstract PHP class and the peer parent services.
🤖 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/pages/shop.php`:
- Around line 30-34: The service definition for sylius.behat.page.shop.page
currently sets Page::class, marks it private, and sets
parent('sylius.behat.symfony_page') but omits ->abstract(); update the service
definition for sylius.behat.page.shop.page (the one using Page::class and
parent('sylius.behat.symfony_page')) to call ->abstract() so the DI definition
matches the abstract PHP class and the peer parent services.
In `@src/Sylius/Behat/Resources/config/services/pages/shop/checkout.php`:
- Around line 14-18: Reorder the PHP use imports so they are alphabetically
sorted: move Sylius\Behat\Page\Shop\Checkout\CompletePage to come before
Sylius\Behat\Page\Shop\Checkout\SelectPaymentPage and
Sylius\Behat\Page\Shop\Checkout\SelectShippingPage; ensure the block containing
AddressPage, CompletePage, SelectPaymentPage, SelectShippingPage and
Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator
is sorted lexicographically by full FQCN to satisfy the coding guideline.
In `@src/Sylius/Behat/Resources/config/services/pages/shop/contact.php`:
- Around line 23-29: The call to $services->defaults()->public() is redundant
because every service defined here (e.g., 'sylius.behat.page.shop.contact' which
immediately calls ->private() and sets parent 'sylius.behat.page.shop.page')
overrides that default; remove the $services->defaults()->public() line from
this file (and the same line from the other pages config files) so the
configuration is not misleading, keeping the service definitions
(set(...)->private()->parent(...)) intact.
In `@src/Sylius/Behat/Resources/config/services/pages/shop/order.php`:
- Around line 14-15: The two PHP use imports are not alphabetized: swap the
order so ShowPage comes before ThankYouPage (i.e., ensure the use statements
reference ShowPage then ThankYouPage) to comply with the project's alphabetical
import convention; update the use block containing ShowPage and ThankYouPage
accordingly (or run your project's PSR-12/CS fixer) so imports are sorted.
In `@src/Sylius/Behat/Resources/config/services/pages/shop/product.php`:
- Around line 14-15: The two PHP use imports for Sylius\Behat\Page\Shop\Product
are out of alphabetical order; update the use statements so IndexPage appears
before ShowPage (swap the order of the use lines referencing IndexPage and
ShowPage in the file) to comply with the project's import sorting guideline.
Summary by CodeRabbit