Skip to content

Convert Behat annotations to PHP attributes in UI Admin contexts#18828

Merged
TheMilek merged 1 commit intoSylius:2.3from
loic425:behat-annotations-to-attributes/ui-admin
Feb 17, 2026
Merged

Convert Behat annotations to PHP attributes in UI Admin contexts#18828
TheMilek merged 1 commit intoSylius:2.3from
loic425:behat-annotations-to-attributes/ui-admin

Conversation

@loic425
Copy link
Copy Markdown
Member

@loic425 loic425 commented Feb 13, 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 Behat test step annotations from PHPDoc-style (@when, @then, @given) to PHP 8 native attributes across administrative UI test contexts.
    • Improved test infrastructure code quality, maintainability, and consistency through modernized annotation syntax.
    • Updated 50+ test context files with standardized attribute-based step definitions for enhanced clarity.

@loic425 loic425 requested review from a team as code owners February 13, 2026 19:35
@loic425 loic425 mentioned this pull request Feb 13, 2026
27 tasks
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 13, 2026

📝 Walkthrough

Walkthrough

This pull request systematically migrates Behat step declarations across approximately 50+ Admin UI context files from PHPDoc-style annotations (@Given, @When, @Then) to PHP 8 attributes (#[Given], #[When], #[Then]). Most files are purely annotation conversions with added Behat\Step* imports. Several files include minor logic enhancements, such as additional method parameters, improved validation assertions, or page navigation changes.

Changes

Cohort / File(s) Summary
Catalog & Product Variants
src/Sylius/Behat/Context/Ui/Admin/BrowsingCatalogPromotionProductVariantsContext.php, BrowsingProductVariantsContext.php
Replaced PHPDoc @Given/@When/@then annotations with PHP 8 attributes; no behavioral changes to step logic.
Pricing & Channel
ChannelPricingLogEntryContext.php, ManagingChannelsBillingDataContext.php, ManagingChannelsContext.php
Migrated Behat step declarations from docblocks to PHP 8 attributes; added Behat\Step* imports.
Administration & Locale Management
DashboardContext.php, LoginContext.php, ManagingAdministratorLocalesContext.php, ManagingAdministratorsContext.php
Converted step annotations to PHP 8 attributes. DashboardContext added five pending-action step methods and expanded interval parameter handling; ManagingAdministratorsContext enhanced validation with multi-field support.
Customer & Group Management
ManagingCustomersContext.php, ManagingCustomerGroupsContext.php
Replaced docblock annotations with attributes; ManagingCustomersContext implemented concrete group filter logic via setFilterGroup and filter invocation.
Promotions & Coupons
ManagingCatalogPromotionsContext.php, ManagingPromotionCouponsContext.php, ManagingPromotionsContext.php
Comprehensive annotation migration with added Behat\Step* imports; step definitions preserved under new attribute syntax.
Orders & Payments
ManagingOrdersContext.php, ManagingPaymentsContext.php, ManagingPaymentMethodsContext.php, ManagingPaymentRequestsContext.php
Converted step annotations to PHP 8 attributes. ManagingOrdersContext added iViewTheSummaryOfTheLastOrder method; ManagingPaymentsContext updated method signature to include CustomerInterface parameter; ManagingPaymentRequestsContext enhanced PaymentRequest retrieval logic.
Products & Variants
ManagingProductVariantsContext.php, ManagingProductVariantsPricesContext.php, ManagingProductsContext.php, ManagingProductAttributesContext.php, ManagingProductOptionsContext.php
Migrated all step declarations to PHP 8 attributes. ManagingProductVariantsPricesContext added ChannelInterface parameter; ManagingProductAttributesContext refined assertion logic for type validation; ManagingProductOptionsContext added navigation call before assertion.
Tax & Shipping
ManagingTaxRateContext.php, ManagingTaxCategoriesContext.php, ManagingShippingMethodsContext.php, ManagingShippingCategoriesContext.php
Converted docblock Behat annotations to PHP 8 attributes across all files; ManagingTaxRateContext added tax-rate inclusion assertion.
Inventory & Stock
ManagingInventoryContext.php
Replaced step annotations with attributes; added filter value specification logic before filtering.
Geography & Localization
ManagingCountriesContext.php, ManagingLocalesContext.php, ManagingTaxonsContext.php
Migrated annotations to PHP 8 attributes. ManagingCountriesContext adopted page resolution via CurrentPageResolver; ManagingTaxonsContext altered createPage type declaration.
Taxonomy & Context Utilities
ManagingProductReviewsContext.php, ManagingProductTaxonsContext.php, ManagingProductAssociationTypesContext.php, NavigatingBetweenProductShowAndEditPagesContext.php, ManagingTranslatableEntitiesContext.php
Replaced step annotations with attributes. ManagingProductTaxonsContext added precondition for page opening; NavigatingBetweenProductShowAndEditPagesContext extended with product-type–driven page selection logic.
Currencies, Exchange Rates & Miscellaneous
ManagingCurrenciesContext.php, ManagingExchangeRatesContext.php, LocaleContext.php, Helper/ValidationTrait.php, ImpersonatingCustomersContext.php, ErrorPageContext.php, NotificationContext.php, OrderHistoryContext.php, ProductCreationContext.php, ProductShowPageContext.php, ProductVariantsCreationContext.php, RemovingProductContext.php, RemovingTaxonContext.php, ResettingPasswordContext.php, SearchFilterContext.php
Converted PHPDoc step annotations to PHP 8 attributes across all files with added Behat\Step* imports. Minor functional tweaks in NotificationContext (dynamic message building) and ResettingPasswordContext (notification message improvements).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

DX, Admin

Suggested reviewers

  • GSadee
  • TheMilek

Poem

🐰 Hops and attributes dance in harmony,
PHP eight brings modern clarity,
Steps now shine in attribute's bright gleam,
No more docblocks in this test-driven dream!
Behat contexts bloom where annotations grew,
Refactoring magic, making code anew!

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.83% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and concisely summarizes the main change: converting Behat annotations to PHP attributes across UI Admin contexts, which is the primary objective of this extensive changeset.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into 2.3

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 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.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 13, 2026

❗ Preview Environment delete from Bunnyshell failed

Check https://github.com/Sylius/Sylius/actions/runs/22102104804 for details.

See: Environment Details

Available commands:

  • 🚀 /bns:deploy to redeploy the environment
  • /bns:delete to remove the environment

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.

Actionable comments posted: 12

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (5)
src/Sylius/Behat/Context/Ui/Admin/NavigatingBetweenProductShowAndEditPagesContext.php (1)

109-116: ⚠️ Potential issue | 🔴 Critical

Fix two issues: wrong page object checked and redundant enum conversion

Two bugs need to be fixed:

  1. Line 113 – wrong page object for simple product type: When iWantToCreateANewProduct('simple') is called, it opens $this->createSimpleProductPage, not the update page. The assertion should check $this->createSimpleProductPage->hasShowPageButton() to match the configurable case which correctly checks $this->createConfigurableProductPage.

  2. Line 112 – redundant enum conversion: $this->currentProductType is already a ProductTypeEnum, so the ProductTypeEnum::from($this->currentProductType->value) round-trip is unnecessary. Use $this->currentProductType directly in the match expression.

Proposed fix
     public function iShouldNotBeAbleToAccessTheProductShowPage(): void
     {
-        match (ProductTypeEnum::from($this->currentProductType->value)) {
-            ProductTypeEnum::simple => Assert::false($this->updateSimpleProductPage->hasShowPageButton()),
+        match ($this->currentProductType) {
+            ProductTypeEnum::simple => Assert::false($this->createSimpleProductPage->hasShowPageButton()),
             ProductTypeEnum::configurable => Assert::false($this->createConfigurableProductPage->hasShowPageButton()),
         };
     }
src/Sylius/Behat/Context/Ui/Admin/ManagingShipmentsContext.php (1)

59-61: ⚠️ Potential issue | 🔴 Critical

Fix channel filter to merge with existing parameters instead of replacing them.

Line 60 replaces the entire $parameters array (losing order, state, and customer keys) when a channel is provided, instead of adding the channel key to the existing filters. This bug affects test assertions since scenarios like the shipment of the "#00000001" order should be "Shipped" for "donald@duck.com" in "United States" channel would pass as long as any shipment with the matching channel exists, regardless of order, state, or customer.

         if ($channel !== null) {
-            $parameters = ['channel' => $channel->getName()];
+            $parameters['channel'] = $channel->getName();
         }
src/Sylius/Behat/Context/Ui/Admin/DashboardContext.php (1)

55-76: ⚠️ Potential issue | 🟠 Major

Step-text regex does not match the available dashboard visualization methods.

The regex at line 55 allows split by day as the interval, which produces the step text "I view statistics for … year split by day". However, line 67 dispatches this to chooseMonthSplitByDaysInterval(), which provides monthly granularity split by days — not yearly data split by days. No chooseYearSplitByDaysInterval() method exists in the DashboardPageInterface. Update the regex to reflect the actual available visualizations: either (year split by month|month split by day) or add a missing dashboard page method for yearly daily granularity.

src/Sylius/Behat/Context/Ui/Admin/ManagingInventoryContext.php (1)

36-43: ⚠️ Potential issue | 🟠 Major

Add type declarations to method parameters and return type.

The method iFilterTrackedVariantsWithCodeContaining on line 37 lacks type declarations for parameters $field, $value, and the return type. Per coding guidelines, add:

public function iFilterTrackedVariantsWithCodeContaining(string $field, string $value): void

The method iShouldSeeThatTheProductVariantHasQuantityOnHand on line 66 has the same issue and should be updated to:

public function iShouldSeeThatTheProductVariantHasQuantityOnHand(string $productVariantName, string $quantity): void
src/Sylius/Behat/Context/Ui/Admin/ManagingCustomersContext.php (1)

87-96: ⚠️ Potential issue | 🟡 Minor

Fix property type to match actual usage — $indexPage should be CustomerIndexPageInterface.

The property is declared as IndexPageInterface (line 38) but the code calls setFilterGroup() (line 92), which only exists on CustomerIndexPageInterface. While the constructor PHPDoc correctly hints at CustomerIndexPageInterface, the property type doesn't match the implementation or the static type contract. Change line 38 from private IndexPageInterface $indexPage to private CustomerIndexPageInterface $indexPage.

🤖 Fix all issues with AI agents
In `@src/Sylius/Behat/Context/Ui/Admin/LoginContext.php`:
- Around line 76-80: The step attribute on the assertion method
iShouldBeOnLoginPage is semantically wrong: change the attribute from #[Given('I
should be on login page')] to the appropriate #[Then('I should be on the login
page')] (or to match the existing #[Then] variant at the other definition) so
the assertion method uses a Then annotation; update the attribute string to
match the existing Then step text and remove or consolidate duplicate step
definitions if both methods now collide.

In `@src/Sylius/Behat/Context/Ui/Admin/ManagingCustomersContext.php`:
- Around line 292-298: The Assert::true call in
ManagingCustomersContext::thisCustomerShouldBeEnabled passes a boolean as the
message argument; change it to call Assert::true with a proper boolean
expression and an optional string message (or no message) — e.g., replace the
current Assert::true($this->indexPage->isCustomerEnabled($customer), true) by
Assert::true($this->indexPage->isCustomerEnabled($customer)) or
Assert::true($this->indexPage->isCustomerEnabled($customer), 'Customer should be
enabled') so the second parameter is a string if present; refer to the
thisCustomerShouldBeEnabled method and indexPage->isCustomerEnabled to locate
the spot.
- Around line 320-324: The step definition declares two placeholders but the
method iSortTheOrderByField currently only accepts $field; add a second
parameter $sortType to the method signature (e.g., iSortTheOrderByField(string
$sortType, string $field): void) so Behat binds placeholders correctly, leaving
$sortType unused if not needed, and keep the existing call to
$this->ordersIndexPage->sort(ucfirst($field)).

In `@src/Sylius/Behat/Context/Ui/Admin/ManagingOrdersContext.php`:
- Around line 627-632: The methods theOrderShouldHaveShippingState and
theOrderShouldHavePaymentState declare an OrderInterface $order parameter that
is not used; either remove the unused $order parameter if Behat doesn't require
it, or rename it to _order (or add a suppression annotation) to signal
intentional unused parameter for Behat regex argument matching—update both
method signatures accordingly and keep the rest of each method body unchanged.
- Around line 608-612: The step definition attribute for
thisOrderShipmentStateShouldBe declares two placeholders ('order :orderNumber
should have shipment state :shippingState') but the method signature only
accepts string $shippingState, causing a parameter mismatch; fix by aligning
signature and pattern: either add the missing first parameter (e.g.
OrderInterface $order or string $orderNumber) to thisOrderShipmentStateShouldBe
to accept the order placeholder, or remove ':orderNumber' from the attribute if
the order isn't needed—use theOrderShouldHavePaymentState as a reference for the
correct two-parameter pattern and ordering.

In `@src/Sylius/Behat/Context/Ui/Admin/ManagingProductOptionsContext.php`:
- Around line 188-192: The method iDoNotAddAnOptionValue in
ManagingProductOptionsContext lacks the explicit return type; update its
signature to declare a void return type (i.e., add ": void") to match the
analogous iDoNotNameIt method and comply with the project's type declaration
guideline, ensuring consistency across context methods.
- Around line 54-58: The step definition iSpecifyATooLong in class
ManagingProductOptionsContext duplicates the identical step in
Ui/Admin/Helper/ValidationTrait, causing ambiguous Behat matches; fix by
removing the iSpecifyATooLong method from ManagingProductOptionsContext and
relying on ValidationTrait (ensure the trait is used by the class), or
alternatively rename/change the step pattern in ManagingProductOptionsContext to
a unique pattern and update any scenarios that reference it; reference the
method name iSpecifyATooLong and the trait ValidationTrait when making the
change.

In `@src/Sylius/Behat/Context/Ui/Admin/ManagingPromotionsContext.php`:
- Around line 16-18: The three Behat import statements (Given, Then, When) in
ManagingPromotionsContext are out of alphabetical order; reorder the `use`
imports so they are sorted alphabetically (Given before Then before When) and
ensure imports are grouped by type (classes, functions, constants) per
guidelines so the block reads: Given, Then, When.
- Around line 250-258: The step definition
iAddTheItemPercentageDiscountActionConfiguredWithAPercentageValue has a
leftover/malformed docblock annotation and lacks the corresponding PHP attribute
for the variant without a percentage; remove the malformed "@WhenI ..." docblock
entry and add a second #[When(...)] attribute matching the no-percentage regex
(like the analogous Order percentage method uses) so both variants (with and
without percentage) are defined for
UnitPercentageDiscountPromotionActionCommand::TYPE and the method continues to
call formElement->addAction(...) and fillActionOption('Percentage', ...).
- Around line 127-132: Change the step attribute on the assertion method
thePromotionShouldHaveLabelInLocale from #[When('the :promotion promotion should
have a label :label in :localeCode locale')] to #[Then('the :promotion promotion
should have a label :label in :localeCode locale')] because this is a
verification step (it calls $this->formElement->hasLabel). Also make the
identical change for the matching assertion method in the Api Admin
ManagingPromotionsContext class (the method with the same step
text/thePromotionShouldHaveLabelInLocale) so both contexts use #[Then].

In `@src/Sylius/Behat/Context/Ui/Admin/ManagingTaxRateContext.php`:
- Around line 77-81: The step implementation iSetTheEndDateTo currently calls
$this->createPage->specifyStartDate(new \DateTime($endDate)) which overwrites
the start date; change the call to $this->createPage->specifyEndDate(new
\DateTime($endDate)) so the end date is set correctly, leaving the method
signature iSetTheEndDateTo(string $endDate): void and using the same DateTime
construction.

In `@src/Sylius/Behat/Context/Ui/Admin/ProductVariantsCreationContext.php`:
- Around line 16-17: Reorder the PHP use imports in
ProductVariantsCreationContext so they are alphabetized and grouped by type:
place "use Behat\Behat\Context\Context;" before "use Behat\Step\When;" (and
adjust any other class/function/constant imports in this file to follow the same
rule) to comply with the project's import-sorting guideline.
🧹 Nitpick comments (40)
src/Sylius/Behat/Context/Ui/Admin/OrderHistoryContext.php (1)

16-18: Imports are not sorted alphabetically.

The new use statements should be ordered alphabetically per the coding guidelines. Behat\Behat\Context\Context should come before Behat\Step\*.

Proposed fix
-use Behat\Step\When;
-use Behat\Step\Then;
 use Behat\Behat\Context\Context;
+use Behat\Step\Then;
+use Behat\Step\When;

As per coding guidelines: "Sort PHP use imports alphabetically and group by type (classes, functions, constants)."

src/Sylius/Behat/Context/Ui/Admin/SearchFilterContext.php (1)

16-17: Imports are not sorted alphabetically.

Behat\Behat\Context\Context should appear before Behat\Step\When. As per coding guidelines, "Sort PHP use imports alphabetically and group by type."

Proposed fix
-use Behat\Step\When;
 use Behat\Behat\Context\Context;
+use Behat\Step\When;
 use Sylius\Behat\Element\Admin\Crud\Index\SearchFilterElementInterface;
src/Sylius/Behat/Context/Ui/Admin/ManagingProductVariantsPricesContext.php (1)

16-17: Import order: Behat\Behat\… should precede Behat\Step\….

As per coding guidelines, use imports should be sorted alphabetically.

Proposed fix
-use Behat\Step\When;
 use Behat\Behat\Context\Context;
+use Behat\Step\When;
src/Sylius/Behat/Context/Ui/Admin/ManagingAdministratorLocalesContext.php (1)

16-17: Imports are not sorted alphabetically.

Behat\Behat\Context\Context should come before Behat\Step\When.

Proposed fix
-use Behat\Step\When;
 use Behat\Behat\Context\Context;
+use Behat\Step\When;

As per coding guidelines: "Sort PHP use imports alphabetically and group by type (classes, functions, constants)".

src/Sylius/Behat/Context/Ui/Admin/Helper/ValidationTrait.php (1)

16-17: Imports are not sorted alphabetically.

Behat\Step\Then should come before Behat\Step\When.

Proposed fix
-use Behat\Step\When;
-use Behat\Step\Then;
+use Behat\Step\Then;
+use Behat\Step\When;

As per coding guidelines: "Sort PHP use imports alphabetically and group by type (classes, functions, constants)."

src/Sylius/Behat/Context/Ui/Admin/ProductCreationContext.php (1)

16-17: Imports are not sorted alphabetically.

Behat\Behat\Context\Context should come before Behat\Step\When.

Proposed fix
-use Behat\Step\When;
 use Behat\Behat\Context\Context;
+use Behat\Step\When;

As per coding guidelines: "Sort PHP use imports alphabetically and group by type (classes, functions, constants)".

src/Sylius/Behat/Context/Ui/Admin/ManagingTranslatableEntitiesContext.php (1)

16-17: Imports are not in alphabetical order.

Behat\Step\Then should precede Behat\Step\When alphabetically.

Proposed fix
-use Behat\Step\When;
-use Behat\Step\Then;
+use Behat\Step\Then;
+use Behat\Step\When;

As per coding guidelines: "Sort PHP use imports alphabetically and group by type (classes, functions, constants)."

src/Sylius/Behat/Context/Ui/Admin/RemovingTaxonContext.php (1)

16-17: Imports are not sorted alphabetically.

Behat\Step\Then should come before Behat\Step\When.

Proposed fix
-use Behat\Step\When;
-use Behat\Step\Then;
+use Behat\Step\Then;
+use Behat\Step\When;

As per coding guidelines: "Sort PHP use imports alphabetically and group by type (classes, functions, constants)".

src/Sylius/Behat/Context/Ui/Admin/ManagingCurrenciesContext.php (1)

16-18: Imports are not sorted alphabetically.

The newly added use statements should be ordered so that Behat\Behat\Context\Context comes before the Behat\Step\* imports. As per coding guidelines: "Sort PHP use imports alphabetically and group by type."

Proposed fix
-use Behat\Step\When;
-use Behat\Step\Then;
 use Behat\Behat\Context\Context;
+use Behat\Step\Then;
+use Behat\Step\When;
src/Sylius/Behat/Context/Ui/Admin/ManagingProductReviewsContext.php (1)

16-18: Imports are not sorted alphabetically.

Behat\Step\Then should come before Behat\Step\When.

Proposed fix
 use Behat\Step\Given;
-use Behat\Step\When;
 use Behat\Step\Then;
+use Behat\Step\When;

As per coding guidelines: "Sort PHP use imports alphabetically and group by type (classes, functions, constants)."

src/Sylius/Behat/Context/Ui/Admin/ManagingZonesContext.php (3)

16-18: Imports are not sorted alphabetically.

The Behat\Step\* imports should be ordered Given, Then, When.

Proposed fix
-use Behat\Step\When;
-use Behat\Step\Then;
 use Behat\Step\Given;
+use Behat\Step\Then;
+use Behat\Step\When;

As per coding guidelines: "Sort PHP use imports alphabetically and group by type."


111-114: Missing type declaration for $scope parameter.

-    public function iSelectItsScopeAs($scope): void
+    public function iSelectItsScopeAs(string $scope): void

As per coding guidelines: "Add type declarations for all properties, arguments, and return values in PHP code."


313-319: Missing return type on theZoneShouldHavePriority.

-    public function theZoneShouldHavePriority(ZoneInterface $zone, int $priority)
+    public function theZoneShouldHavePriority(ZoneInterface $zone, int $priority): void

As per coding guidelines: "Add type declarations for all properties, arguments, and return values in PHP code."

src/Sylius/Behat/Context/Ui/Admin/ManagingProductTaxonsContext.php (1)

16-17: Import order: Then should come before When alphabetically.

As per coding guidelines, "Sort PHP use imports alphabetically and group by type."

Proposed fix
-use Behat\Step\When;
-use Behat\Step\Then;
+use Behat\Step\Then;
+use Behat\Step\When;
src/Sylius/Behat/Context/Ui/Admin/RemovingProductContext.php (1)

16-17: Imports are not sorted alphabetically.

Behat\Step\Then should come before Behat\Step\When.

Proposed fix
-use Behat\Step\When;
-use Behat\Step\Then;
+use Behat\Step\Then;
+use Behat\Step\When;

As per coding guidelines: "Sort PHP use imports alphabetically and group by type".

src/Sylius/Behat/Context/Ui/Admin/ResettingPasswordContext.php (1)

16-18: Imports are not sorted alphabetically.

Behat\Behat\Context\Context should precede Behat\Step\*, and Then should come before When. As per coding guidelines, "Sort PHP use imports alphabetically and group by type."

Proposed fix
-use Behat\Step\When;
-use Behat\Step\Then;
 use Behat\Behat\Context\Context;
+use Behat\Step\Then;
+use Behat\Step\When;
src/Sylius/Behat/Context/Ui/Admin/ManagingExchangeRatesContext.php (1)

16-19: Imports are not sorted alphabetically.

Behat\Behat\Context\Context should precede the Behat\Step\* imports, and within the Step group the order should be Given, Then, When.

Proposed fix
-use Behat\Step\When;
-use Behat\Step\Given;
-use Behat\Step\Then;
 use Behat\Behat\Context\Context;
+use Behat\Step\Given;
+use Behat\Step\Then;
+use Behat\Step\When;

As per coding guidelines: "Sort PHP use imports alphabetically and group by type (classes, functions, constants)".

src/Sylius/Behat/Context/Ui/Admin/ManagingPaymentRequestsContext.php (2)

16-18: Imports are not sorted alphabetically.

Behat\Behat\Context\Context (line 18) should precede the Behat\Step\* imports, and Then should come before When.

Proposed fix
-use Behat\Step\When;
-use Behat\Step\Then;
 use Behat\Behat\Context\Context;
+use Behat\Step\Then;
+use Behat\Step\When;

As per coding guidelines: "Sort PHP use imports alphabetically and group by type (classes, functions, constants)".


49-52: findOneBy may return null, leading to a potential NPE on line 52.

Pre-existing, but since you're touching this file — consider adding a null assertion or guard:

 $paymentRequest = $this->paymentRequestRepository->findOneBy(['payment' => $payment]);
+Assert::notNull($paymentRequest, 'No payment request found for this payment.');
src/Sylius/Behat/Context/Ui/Admin/ManagingCountriesContext.php (1)

16-17: Imports are not sorted alphabetically.

Behat\Step\Then and Behat\Step\When should be placed after Behat\Mink\Exception\ElementNotFoundException to maintain alphabetical order across all Behat\* imports.

Suggested order
-use Behat\Step\When;
-use Behat\Step\Then;
 use Behat\Behat\Context\Context;
 use Behat\Mink\Exception\ElementNotFoundException;
+use Behat\Step\Then;
+use Behat\Step\When;

As per coding guidelines: "Sort PHP use imports alphabetically and group by type (classes, functions, constants)."

src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php (2)

206-210: Unused $taxonName parameter.

PHPMD correctly flags that $taxonName is never used in the method body — only $slug is forwarded to thisTaxonElementShouldBe. The parameter is required by Behat's step pattern for matching purposes, but consider prefixing it or adding a suppression if this triggers CI warnings.

Suggested suppression
 #[Then('the slug of the :taxonName taxon should( still) be :slug')]
-    public function theSlugOfTheTaxonShouldBe(string $taxonName, string $slug): void
+    /** `@phpstan-ignore-next-line` */
+    public function theSlugOfTheTaxonShouldBe(string $taxonName, string $slug): void

Alternatively, if PHPMD is the linter in question, you could use @SuppressWarnings(PHPMD.UnusedFormalParameter).


349-356: Redundant (int) cast on an already-typed int parameter.

On line 355, $count is already declared as int in the method signature, making (int) $count a no-op cast.

Suggested fix
-        Assert::same($this->imageFormElement->countImages(), (int) $count);
+        Assert::same($this->imageFormElement->countImages(), $count);
src/Sylius/Behat/Context/Ui/Admin/ManagingTaxRateContext.php (1)

16-18: Import order: Behat step attributes are not sorted alphabetically.

As per coding guidelines, use imports should be sorted alphabetically: Given, Then, When.

Proposed fix
-use Behat\Step\When;
-use Behat\Step\Then;
-use Behat\Step\Given;
+use Behat\Step\Given;
+use Behat\Step\Then;
+use Behat\Step\When;
src/Sylius/Behat/Context/Ui/Admin/NavigatingBetweenProductShowAndEditPagesContext.php (1)

16-17: Import order: Then should precede When alphabetically.

As per coding guidelines, "Sort PHP use imports alphabetically and group by type."

Proposed fix
-use Behat\Step\When;
-use Behat\Step\Then;
+use Behat\Step\Then;
+use Behat\Step\When;
src/Sylius/Behat/Context/Ui/Admin/ManagingShippingCategoriesContext.php (1)

16-17: Imports are not sorted alphabetically.

Behat\Step\Then should precede Behat\Step\When.

Proposed fix
-use Behat\Step\When;
-use Behat\Step\Then;
+use Behat\Step\Then;
+use Behat\Step\When;

As per coding guidelines: "Sort PHP use imports alphabetically and group by type (classes, functions, constants)".

src/Sylius/Behat/Context/Ui/Admin/ManagingProductOptionsContext.php (2)

16-18: Imports are not sorted alphabetically.

The Behat step imports should be ordered alphabetically: Given, Then, When.

Suggested fix
-use Behat\Step\When;
-use Behat\Step\Given;
-use Behat\Step\Then;
+use Behat\Step\Given;
+use Behat\Step\Then;
+use Behat\Step\When;

As per coding guidelines: "Sort PHP use imports alphabetically and group by type."


74-78: Missing type declarations on $name and $language parameters.

The sibling method iRenameItToInLanguage (line 82) correctly types its parameters as string. Consider adding type hints here for consistency.

Suggested fix
-    public function iNameItInLanguage($name, $language): void
+    public function iNameItInLanguage(string $name, string $language): void

As per coding guidelines: "Add type declarations for all properties, arguments, and return values in PHP code."

src/Sylius/Behat/Context/Ui/Admin/ImpersonatingCustomersContext.php (1)

16-18: Nit: Imports are not sorted alphabetically.

Behat\Step\Then should come before Behat\Step\When. As per coding guidelines, use imports should be sorted alphabetically.

Suggested fix
 use Behat\Step\Given;
-use Behat\Step\When;
 use Behat\Step\Then;
+use Behat\Step\When;
src/Sylius/Behat/Context/Ui/Admin/ManagingTaxCategoriesContext.php (1)

16-18: Nit: Imports are not sorted alphabetically.

Should be Given, Then, When. As per coding guidelines, use imports should be sorted alphabetically.

Suggested fix
-use Behat\Step\When;
 use Behat\Step\Given;
 use Behat\Step\Then;
+use Behat\Step\When;
src/Sylius/Behat/Context/Ui/Admin/ProductShowPageContext.php (1)

16-18: Nit: Imports are not sorted alphabetically.

Then should come before When. As per coding guidelines, use imports should be sorted alphabetically.

Suggested fix
 use Behat\Step\Given;
-use Behat\Step\When;
 use Behat\Step\Then;
+use Behat\Step\When;
src/Sylius/Behat/Context/Ui/Admin/LoginContext.php (1)

16-18: Nit: Imports are not sorted alphabetically.

Should be Given, Then, When. As per coding guidelines, use imports should be sorted alphabetically.

Suggested fix
-use Behat\Step\When;
-use Behat\Step\Then;
 use Behat\Step\Given;
+use Behat\Step\Then;
+use Behat\Step\When;
src/Sylius/Behat/Context/Ui/Admin/ManagingShippingMethodsContext.php (3)

16-19: Nit: Behat\Step\* imports are split and not sorted alphabetically.

The When import ended up separated from Given and Then by the Behat\Behat\Context\Context import. Group them together and sort alphabetically. As per coding guidelines, use imports should be sorted alphabetically and grouped by type.

Suggested fix
-use Behat\Step\Then;
 use Behat\Step\Given;
-use Behat\Behat\Context\Context;
+use Behat\Step\Then;
 use Behat\Step\When;
+use Behat\Behat\Context\Context;

346-352: Unused parameter $sortType.

The $sortType parameter is accepted but never used — sorting direction is not passed to sortBy(). This is a pre-existing issue flagged by static analysis (PHPMD).


473-481: Unused variable $channel.

$channel is fetched from shared storage on line 476 but never referenced in the method body.

Suggested fix
 public function iShouldBeNotifiedThatTheWeightRuleHasAnInvalidConfiguration(): void
 {
-    $channel = $this->sharedStorage->get('channel');
     Assert::same(
         $this->shippingMethodFormElement->getValidationMessage('last_rule_weight'),
         'Please enter a number.',
     );
 }
src/Sylius/Behat/Context/Ui/Admin/ManagingLocalesContext.php (1)

16-18: Nit: Imports are not sorted alphabetically.

Then should come before When. As per coding guidelines, use imports should be sorted alphabetically.

Suggested fix
 use Behat\Step\Given;
-use Behat\Step\When;
 use Behat\Step\Then;
+use Behat\Step\When;
src/Sylius/Behat/Context/Ui/Admin/ManagingPaymentsContext.php (1)

16-18: Imports not sorted alphabetically.

The Behat\Step\* imports should be in alphabetical order: Given, Then, When. This same ordering issue appears consistently across all files in this PR.

Proposed fix
 use Behat\Step\Given;
-use Behat\Step\When;
 use Behat\Step\Then;
+use Behat\Step\When;

As per coding guidelines: "Sort PHP use imports alphabetically and group by type (classes, functions, constants)".

src/Sylius/Behat/Context/Ui/Admin/BrowsingProductVariantsContext.php (1)

16-17: Same alphabetical import ordering nit as noted in ManagingPaymentsContext.php.

Then should come before When.

Proposed fix
-use Behat\Step\When;
 use Behat\Step\Then;
+use Behat\Step\When;

As per coding guidelines: "Sort PHP use imports alphabetically and group by type".

src/Sylius/Behat/Context/Ui/Admin/ManagingProductsContext.php (1)

691-696: Unused $product parameter flagged by static analysis.

PHPMD flags $product as unused. The parameter is required by Behat's step argument transformation (it resolves (this product) / (product "[^"]+") from the regex), so it can't simply be removed. However, it might be worth navigating to the product's update page here to make the method self-contained, similar to how other assertion methods in this file call $this->updateSimpleProductPage->open(...) first. This is a pre-existing issue, not introduced by this PR.

src/Sylius/Behat/Context/Ui/Admin/ManagingInventoryContext.php (1)

37-37: Consider adding type declarations to untyped parameters.

iFilterTrackedVariantsWithCodeContaining($field, $value) (Line 37) and iShouldSeeThatTheProductVariantHasQuantityOnHand($productVariantName, $quantity) (Line 66) are missing type hints and return types. While pre-existing, this violates the guideline to add type declarations for all arguments and return values. As per coding guidelines, "Add type declarations for all properties, arguments, and return values in PHP code".

Proposed type hints
-    public function iFilterTrackedVariantsWithCodeContaining($field, $value)
+    public function iFilterTrackedVariantsWithCodeContaining(string $field, string $value): void
-    public function iShouldSeeThatTheProductVariantHasQuantityOnHand($productVariantName, $quantity)
+    public function iShouldSeeThatTheProductVariantHasQuantityOnHand(string $productVariantName, string $quantity): void

Also applies to: 66-66

src/Sylius/Behat/Context/Ui/Admin/ManagingCustomersContext.php (1)

16-18: Imports are not sorted alphabetically.

Behat\Step\Then (line 16) is placed before Behat\Behat\Context\Context (line 17). Per coding guidelines, use imports should be sorted alphabetically.

Proposed fix
-use Behat\Step\Then;
 use Behat\Behat\Context\Context;
 use Behat\Step\When;
+use Behat\Step\Then;
+use Behat\Step\When;

As per coding guidelines: "Sort PHP use imports alphabetically and group by type (classes, functions, constants)".

Comment on lines +76 to 80
#[Given('I should be on login page')]
public function iShouldBeOnLoginPage()
{
Assert::true($this->loginPage->isOpen());
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

#[Given] used on an assertion step — should this be #[Then]?

iShouldBeOnLoginPage asserts page state (Assert::true), which is a Then concern. Line 104 already defines #[Then('I should be on the login page')] for a nearly identical step. Using #[Given] here is semantically misleading and could cause confusion. If the original annotation was also @Given, this might be a good opportunity to correct it during the migration.

🤖 Prompt for AI Agents
In `@src/Sylius/Behat/Context/Ui/Admin/LoginContext.php` around lines 76 - 80, The
step attribute on the assertion method iShouldBeOnLoginPage is semantically
wrong: change the attribute from #[Given('I should be on login page')] to the
appropriate #[Then('I should be on the login page')] (or to match the existing
#[Then] variant at the other definition) so the assertion method uses a Then
annotation; update the attribute string to match the existing Then step text and
remove or consolidate duplicate step definitions if both methods now collide.

Comment on lines +292 to 298
#[Then('/^(this customer) should be enabled$/')]
public function thisCustomerShouldBeEnabled(CustomerInterface $customer): void
{
$this->indexPage->open();

Assert::true($this->indexPage->isCustomerEnabled($customer), true);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Assert::true() called with true as the message argument.

Line 297: Assert::true($this->indexPage->isCustomerEnabled($customer), true) — the second parameter of Assert::true expects a string message, but true (boolean) is passed. This is a pre-existing issue but should be cleaned up.

Proposed fix
-        Assert::true($this->indexPage->isCustomerEnabled($customer), true);
+        Assert::true($this->indexPage->isCustomerEnabled($customer));
🤖 Prompt for AI Agents
In `@src/Sylius/Behat/Context/Ui/Admin/ManagingCustomersContext.php` around lines
292 - 298, The Assert::true call in
ManagingCustomersContext::thisCustomerShouldBeEnabled passes a boolean as the
message argument; change it to call Assert::true with a proper boolean
expression and an optional string message (or no message) — e.g., replace the
current Assert::true($this->indexPage->isCustomerEnabled($customer), true) by
Assert::true($this->indexPage->isCustomerEnabled($customer)) or
Assert::true($this->indexPage->isCustomerEnabled($customer), 'Customer should be
enabled') so the second parameter is a string if present; refer to the
thisCustomerShouldBeEnabled method and indexPage->isCustomerEnabled to locate
the spot.

Comment on lines +320 to 324
#[When('I sort the orders :sortType by :field')]
public function iSortTheOrderByField(string $field): void
{
$this->ordersIndexPage->sort(ucfirst($field));
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check the current file first to see exact code
cat -n src/Sylius/Behat/Context/Ui/Admin/ManagingCustomersContext.php | sed -n '315,330p'

Repository: Sylius/Sylius

Length of output: 764


🏁 Script executed:

#!/bin/bash
# Check git history for this method
git log -p --all -- 'src/Sylius/Behat/Context/Ui/Admin/ManagingCustomersContext.php' | grep -B5 -A5 'sort the orders' | head -40

Repository: Sylius/Sylius

Length of output: 39


🏁 Script executed:

#!/bin/bash
# Search for usages of this step in feature files
find . -name "*.feature" -type f -exec grep -l "sort the orders" {} \;

Repository: Sylius/Sylius

Length of output: 133


🏁 Script executed:

#!/bin/bash
# Read the feature file to see how the step is actually called
cat features/admin/user/managing_customers/browsing_orders_of_customer.feature | grep -A2 -B2 "sort the orders"

Repository: Sylius/Sylius

Length of output: 348


🏁 Script executed:

#!/bin/bash
# Try a broader git log search for the method name
git log -p --all -- 'src/Sylius/Behat/Context/Ui/Admin/ManagingCustomersContext.php' | grep -B10 -A10 'iSortTheOrderByField' | head -60

Repository: Sylius/Sylius

Length of output: 39


🏁 Script executed:

#!/bin/bash
# Check if there's any other usage of :sortType in this file
rg "sortType" src/Sylius/Behat/Context/Ui/Admin/ManagingCustomersContext.php

Repository: Sylius/Sylius

Length of output: 109


🏁 Script executed:

#!/bin/bash
# Check git log for the attribute migration - look for #[When( changes
git log --oneline -p --all -- 'src/Sylius/Behat/Context/Ui/Admin/ManagingCustomersContext.php' | grep -B5 -A15 '#\[When.*sort the orders' | head -80

Repository: Sylius/Sylius

Length of output: 805


🏁 Script executed:

#!/bin/bash
# Search for the ordersIndexPage interface/implementation to understand sort() method
find . -name "*.php" -type f | xargs grep -l "ordersIndexPage" | head -10

Repository: Sylius/Sylius

Length of output: 121


🏁 Script executed:

#!/bin/bash
# Get more complete git history - look for the commit that added this
git log --oneline --all -- 'src/Sylius/Behat/Context/Ui/Admin/ManagingCustomersContext.php' | head -20

Repository: Sylius/Sylius

Length of output: 197


🏁 Script executed:

#!/bin/bash
# Find the ordersIndexPage class definition
find . -path ./vendor -prune -o -name "*.php" -type f -print | xargs grep -l "class.*OrdersIndexPage" | head -5

Repository: Sylius/Sylius

Length of output: 39


🏁 Script executed:

#!/bin/bash
# Also search for the interface
find . -path ./vendor -prune -o -name "*.php" -type f -print | xargs grep -l "OrdersIndexPageInterface" | head -5

Repository: Sylius/Sylius

Length of output: 39


🏁 Script executed:

#!/bin/bash
# Check the commit that converted annotations to attributes
git show ac55dda16e -- src/Sylius/Behat/Context/Ui/Admin/ManagingCustomersContext.php | grep -B15 -A15 'sort the orders' | head -60

Repository: Sylius/Sylius

Length of output: 1133


🏁 Script executed:

#!/bin/bash
# Search more broadly for ordersIndexPage property definition
rg "ordersIndexPage" src/Sylius/Behat/Context/Ui/Admin/ManagingCustomersContext.php -A3 -B3

Repository: Sylius/Sylius

Length of output: 1110


🏁 Script executed:

#!/bin/bash
# Search for sort method in context files
rg "function sort\(" src/Sylius/Behat/ -A3 -B1

Repository: Sylius/Sylius

Length of output: 2451


🏁 Script executed:

#!/bin/bash
# Check what the old annotation looked like before the conversion
git show ac55dda16e~1 -- src/Sylius/Behat/Context/Ui/Admin/ManagingCustomersContext.php | grep -B5 -A10 'sort the orders' | head -40

Repository: Sylius/Sylius

Length of output: 91


🏁 Script executed:

#!/bin/bash
# Look at the specific line in the previous commit
git show ac55dda16e~1:src/Sylius/Behat/Context/Ui/Admin/ManagingCustomersContext.php | sed -n '310,330p'

Repository: Sylius/Sylius

Length of output: 99


🏁 Script executed:

#!/bin/bash
# Get the full diff for this specific commit to see before/after
git show ac55dda16e -- src/Sylius/Behat/Context/Ui/Admin/ManagingCustomersContext.php | grep -B20 -A20 'iSortTheOrderByField'

Repository: Sylius/Sylius

Length of output: 1514


🏁 Script executed:

#!/bin/bash
# Check if there was an original method with `@When` annotation
git show ac55dda16e -- src/Sylius/Behat/Context/Ui/Admin/ManagingCustomersContext.php | head -200

Repository: Sylius/Sylius

Length of output: 6870


🏁 Script executed:

#!/bin/bash
# The commit shows the file as new (mode 100644). Let's check if there's an older version
git log --all --full-history -- src/Sylius/Behat/Context/Ui/Admin/ManagingCustomersContext.php | head -20

Repository: Sylius/Sylius

Length of output: 878


🏁 Script executed:

#!/bin/bash
# Check if file exists at all in an earlier commit
git show ac55dda16e:src/Sylius/Behat/Context/Ui/Admin/ManagingCustomersContext.php | grep -B10 -A10 'iSortTheOrderByField' | head -50

Repository: Sylius/Sylius

Length of output: 819


🏁 Script executed:

#!/bin/bash
# Let's check if this feature test actually runs and what it expects
cat features/admin/user/managing_customers/browsing_orders_of_customer.feature

Repository: Sylius/Sylius

Length of output: 1720


🏁 Script executed:

#!/bin/bash
# Check if sortType parameter should be used somewhere or if it's unused
# Look for how other similar sorting steps are implemented
rg "When.*sort.*by" src/Sylius/Behat/Context/ -A5 | grep -E "(When|function|sortType)" | head -40

Repository: Sylius/Sylius

Length of output: 5405


🏁 Script executed:

#!/bin/bash
# Let's look at the ManagingProductsContext case that also seems to have the issue
rg "I sort the products :sortType by :field" src/Sylius/Behat/Context/Ui/Admin/ManagingProductsContext.php -B2 -A8

Repository: Sylius/Sylius

Length of output: 496


🏁 Script executed:

#!/bin/bash
# And check a correct implementation to compare
rg "I sort the shipping methods :sortType by :field" src/Sylius/Behat/Context/Ui/Admin/ManagingShippingMethodsContext.php -B2 -A8

Repository: Sylius/Sylius

Length of output: 477


Add $sortType parameter to match the step pattern placeholders.

The step pattern #[When('I sort the orders :sortType by :field')] declares two placeholders (:sortType and :field), but the method signature only has a $field parameter. With Behat's positional argument binding, the :sortType value ("ascending") will be received as $field, and the actual field name ("channel") will be lost. This breaks the step matching and causes ordersIndexPage->sort(ucfirst("ascending")) instead of ordersIndexPage->sort(ucfirst("channel")).

Add the $sortType parameter to the method signature:

#[When('I sort the orders :sortType by :field')]
-public function iSortTheOrderByField(string $field): void
+public function iSortTheOrderByField(string $sortType, string $field): void

(The parameter may not be used internally, similar to other sorting methods in the codebase like ManagingShippingMethodsContext::iSortShippingMethodsBy, but it must be present for step matching to work correctly.)

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#[When('I sort the orders :sortType by :field')]
public function iSortTheOrderByField(string $field): void
{
$this->ordersIndexPage->sort(ucfirst($field));
}
#[When('I sort the orders :sortType by :field')]
public function iSortTheOrderByField(string $sortType, string $field): void
{
$this->ordersIndexPage->sort(ucfirst($field));
}
🤖 Prompt for AI Agents
In `@src/Sylius/Behat/Context/Ui/Admin/ManagingCustomersContext.php` around lines
320 - 324, The step definition declares two placeholders but the method
iSortTheOrderByField currently only accepts $field; add a second parameter
$sortType to the method signature (e.g., iSortTheOrderByField(string $sortType,
string $field): void) so Behat binds placeholders correctly, leaving $sortType
unused if not needed, and keep the existing call to
$this->ordersIndexPage->sort(ucfirst($field)).

Comment on lines +608 to 612
#[Then('order :orderNumber should have shipment state :shippingState')]
public function thisOrderShipmentStateShouldBe(string $shippingState): void
{
Assert::true($this->indexPage->isSingleResourceOnPage(['shippingState' => $shippingState]));
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check git history for the original annotation before attribute conversion
cd "$(git rev-parse --show-toplevel)"
git log --all --oneline -S "thisOrderShipmentStateShouldBe" -- "src/Sylius/Behat/Context/Ui/Admin/ManagingOrdersContext.php" | head -5

Repository: Sylius/Sylius

Length of output: 197


🏁 Script executed:

#!/bin/bash
# Look at the current file to see context around the flagged methods
cd "$(git rev-parse --show-toplevel)"
sed -n '600,635p' "src/Sylius/Behat/Context/Ui/Admin/ManagingOrdersContext.php"

Repository: Sylius/Sylius

Length of output: 1754


🏁 Script executed:

#!/bin/bash
# Search for other similar patterns with order parameter in the same file
cd "$(git rev-parse --show-toplevel)"
rg -n "order :orderNumber" --type php "src/Sylius/Behat/Context/Ui/Admin/ManagingOrdersContext.php"

Repository: Sylius/Sylius

Length of output: 209


🏁 Script executed:

#!/bin/bash
# Get the full diff for the relevant commit
cd "$(git rev-parse --show-toplevel)"
git show ac55dda16e:src/Sylius/Behat/Context/Ui/Admin/ManagingOrdersContext.php | sed -n '600,635p'

Repository: Sylius/Sylius

Length of output: 1754


🏁 Script executed:

#!/bin/bash
# Also check if there were any changes to the method signature or attribute in that commit
cd "$(git rev-parse --show-toplevel)"
git show ac55dda16e -- src/Sylius/Behat/Context/Ui/Admin/ManagingOrdersContext.php | grep -A5 -B5 "thisOrderShipmentStateShouldBe"

Repository: Sylius/Sylius

Length of output: 510


🏁 Script executed:

#!/bin/bash
# Check the state of the file BEFORE the attribute conversion
cd "$(git rev-parse --show-toplevel)"
git show ac55dda16e^:src/Sylius/Behat/Context/Ui/Admin/ManagingOrdersContext.php | sed -n '600,635p'

Repository: Sylius/Sylius

Length of output: 98


🏁 Script executed:

#!/bin/bash
# Also get more context - find the method in the previous version
cd "$(git rev-parse --show-toplevel)"
git show ac55dda16e^:src/Sylius/Behat/Context/Ui/Admin/ManagingOrdersContext.php | grep -n "thisOrderShipmentStateShouldBe" -A 5 -B 5

Repository: Sylius/Sylius

Length of output: 98


🏁 Script executed:

#!/bin/bash
# Find the commit before ac55dda16e
cd "$(git rev-parse --show-toplevel)"
git log --oneline --all | grep -A1 "ac55dda16e"

Repository: Sylius/Sylius

Length of output: 197


🏁 Script executed:

#!/bin/bash
# Try to see the full diff of the conversion commit
cd "$(git rev-parse --show-toplevel)"
git show ac55dda16e -- src/Sylius/Behat/Context/Ui/Admin/ManagingOrdersContext.php | head -300 | tail -150

Repository: Sylius/Sylius

Length of output: 5764


🏁 Script executed:

#!/bin/bash
# Look for the original annotation format by searching in git log before the conversion
cd "$(git rev-parse --show-toplevel)"
git log --all -p --diff-filter=M -S "@Then" -- "src/Sylius/Behat/Context/Ui/Admin/ManagingOrdersContext.php" | grep -A3 -B3 "thisOrderShipmentStateShouldBe" | head -40

Repository: Sylius/Sylius

Length of output: 39


🏁 Script executed:

#!/bin/bash
# Get the full diff of that commit focusing on the method
cd "$(git rev-parse --show-toplevel)"
git show ac55dda16e -- src/Sylius/Behat/Context/Ui/Admin/ManagingOrdersContext.php | grep -A10 "thisOrderShipmentStateShouldBe"

Repository: Sylius/Sylius

Length of output: 641


🏁 Script executed:

#!/bin/bash
# Try looking for `@Then` annotations from before the conversion
cd "$(git rev-parse --show-toplevel)"
git show ac55dda16e -- src/Sylius/Behat/Context/Ui/Admin/ManagingOrdersContext.php | grep -B2 "@Then.*orderNumber.*shipment"

Repository: Sylius/Sylius

Length of output: 39


🏁 Script executed:

#!/bin/bash
# Search for the entire diff section with both - and + lines to see the change
cd "$(git rev-parse --show-toplevel)"
git diff ac55dda16e~1 ac55dda16e -- src/Sylius/Behat/Context/Ui/Admin/ManagingOrdersContext.php | grep -A5 -B5 "thisOrderShipmentStateShouldBe"

Repository: Sylius/Sylius

Length of output: 91


🏁 Script executed:

#!/bin/bash
# Get the full diff for the commit to see both - and + lines
cd "$(git rev-parse --show-toplevel)"
git show ac55dda16e -- src/Sylius/Behat/Context/Ui/Admin/ManagingOrdersContext.php > /tmp/commit_diff.txt
grep -A10 -B10 "thisOrderShipmentStateShouldBe" /tmp/commit_diff.txt

Repository: Sylius/Sylius

Length of output: 1039


🏁 Script executed:

#!/bin/bash
# Check if the original file exists in a parent commit - look at git log
cd "$(git rev-parse --show-toplevel)"
git log --oneline --all -- src/Sylius/Behat/Context/Ui/Admin/ManagingOrdersContext.php | head -10

Repository: Sylius/Sylius

Length of output: 197


🏁 Script executed:

#!/bin/bash
# Check the file from the commit before the conversion
cd "$(git rev-parse --show-toplevel)"
git show 40c1e05e78:src/Sylius/Behat/Context/Ui/Admin/ManagingOrdersContext.php 2>/dev/null | grep -A5 -B5 "thisOrderShipmentStateShouldBe"

Repository: Sylius/Sylius

Length of output: 355


🏁 Script executed:

#!/bin/bash
# Also search for the method in any earlier commits
cd "$(git rev-parse --show-toplevel)"
git log --all -p --follow -S "thisOrderShipmentStateShouldBe" -- src/Sylius/Behat/Context/Ui/Admin/ManagingOrdersContext.php 2>/dev/null | grep -A8 -B2 "@Then.*order" | head -30

Repository: Sylius/Sylius

Length of output: 987


🏁 Script executed:

#!/bin/bash
# Examine the specific lines flagged for unused $order parameter
cd "$(git rev-parse --show-toplevel)"
sed -n '614,632p' src/Sylius/Behat/Context/Ui/Admin/ManagingOrdersContext.php

Repository: Sylius/Sylius

Length of output: 1110


Correct the step definition to match method parameters.

The attribute pattern 'order :orderNumber should have shipment state :shippingState' defines two placeholders but the method only accepts string $shippingState. Behat will pass both :orderNumber and :shippingState as arguments, causing a parameter count mismatch.

Either add OrderInterface $orderNumber (or similar) as the first parameter, or remove :orderNumber from the step pattern if the order number is not needed. Compare with similar methods like theOrderShouldHavePaymentState (lines 614–619) which correctly capture both :order and :orderPaymentState parameters.

🤖 Prompt for AI Agents
In `@src/Sylius/Behat/Context/Ui/Admin/ManagingOrdersContext.php` around lines 608
- 612, The step definition attribute for thisOrderShipmentStateShouldBe declares
two placeholders ('order :orderNumber should have shipment state
:shippingState') but the method signature only accepts string $shippingState,
causing a parameter mismatch; fix by aligning signature and pattern: either add
the missing first parameter (e.g. OrderInterface $order or string $orderNumber)
to thisOrderShipmentStateShouldBe to accept the order placeholder, or remove
':orderNumber' from the attribute if the order isn't needed—use
theOrderShouldHavePaymentState as a reference for the correct two-parameter
pattern and ordering.

Comment on lines +627 to 632
#[Then('the order :order should have order shipping state :orderShippingState')]
#[Then('/^(this order) should have order shipping state "([^"]+)"$/')]
public function theOrderShouldHaveShippingState(OrderInterface $order, string $orderShippingState): void
{
Assert::true($this->indexPage->isSingleResourceOnPage(['shippingState' => $orderShippingState]));
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Unused $order parameter — confirmed by static analysis.

The $order parameter is accepted but never used in the method body. The same issue applies to theOrderShouldHavePaymentState at line 616. If the parameter is required for Behat's argument matching from the regex group (this order), consider prefixing with an underscore or adding a suppression annotation to signal intent. Otherwise, remove it.

Proposed fix if the parameter is only needed for Behat matching

If Behat requires the positional parameter but the method doesn't use it, you could at minimum suppress the warning. Alternatively, if there's intended behavior (e.g., navigating to the order first), consider using it:

-    public function theOrderShouldHaveShippingState(OrderInterface $order, string $orderShippingState): void
+    public function theOrderShouldHaveShippingState(OrderInterface $_order, string $orderShippingState): void
     {
         Assert::true($this->indexPage->isSingleResourceOnPage(['shippingState' => $orderShippingState]));
     }

Apply the same pattern to theOrderShouldHavePaymentState at line 616.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#[Then('the order :order should have order shipping state :orderShippingState')]
#[Then('/^(this order) should have order shipping state "([^"]+)"$/')]
public function theOrderShouldHaveShippingState(OrderInterface $order, string $orderShippingState): void
{
Assert::true($this->indexPage->isSingleResourceOnPage(['shippingState' => $orderShippingState]));
}
#[Then('the order :order should have order shipping state :orderShippingState')]
#[Then('/^(this order) should have order shipping state "([^"]+)"$/')]
public function theOrderShouldHaveShippingState(OrderInterface $_order, string $orderShippingState): void
{
Assert::true($this->indexPage->isSingleResourceOnPage(['shippingState' => $orderShippingState]));
}
🧰 Tools
🪛 PHPMD (2.15.0)

[warning] 629-629: Avoid unused parameters such as '$order'. (undefined)

(UnusedFormalParameter)

🤖 Prompt for AI Agents
In `@src/Sylius/Behat/Context/Ui/Admin/ManagingOrdersContext.php` around lines 627
- 632, The methods theOrderShouldHaveShippingState and
theOrderShouldHavePaymentState declare an OrderInterface $order parameter that
is not used; either remove the unused $order parameter if Behat doesn't require
it, or rename it to _order (or add a suppression annotation) to signal
intentional unused parameter for Behat regex argument matching—update both
method signatures accordingly and keep the rest of each method body unchanged.

Comment on lines +16 to +18
use Behat\Step\When;
use Behat\Step\Then;
use Behat\Step\Given;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Imports are not sorted alphabetically.

Per coding guidelines, use imports should be sorted alphabetically. Given should come before Then and When.

Proposed fix
-use Behat\Step\When;
-use Behat\Step\Then;
-use Behat\Step\Given;
+use Behat\Step\Given;
+use Behat\Step\Then;
+use Behat\Step\When;

As per coding guidelines: "Sort PHP use imports alphabetically and group by type (classes, functions, constants)."

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
use Behat\Step\When;
use Behat\Step\Then;
use Behat\Step\Given;
use Behat\Step\Given;
use Behat\Step\Then;
use Behat\Step\When;
🤖 Prompt for AI Agents
In `@src/Sylius/Behat/Context/Ui/Admin/ManagingPromotionsContext.php` around lines
16 - 18, The three Behat import statements (Given, Then, When) in
ManagingPromotionsContext are out of alphabetical order; reorder the `use`
imports so they are sorted alphabetically (Given before Then before When) and
ensure imports are grouped by type (classes, functions, constants) per
guidelines so the block reads: Given, Then, When.

Comment on lines +127 to 132
#[When('the :promotion promotion should have a label :label in :localeCode locale')]
public function thePromotionShouldHaveLabelInLocale(PromotionInterface $promotion, string $label, string $localeCode): void
{
$this->updatePage->open(['id' => $promotion->getId()]);
$this->formElement->hasLabel($label, $localeCode);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for usage of this step in feature files
echo "=== Searching for step usage in feature files ==="
rg -n "the .* promotion should have a label" . 2>/dev/null || echo "Pattern search returned no results"

echo ""
echo "=== Searching for broader pattern ==="
rg "should have a label" . --type-add 'feature:*.feature' --type feature 2>/dev/null || echo "No feature files found with this pattern"

echo ""
echo "=== Finding all .feature files ==="
find . -name "*.feature" -type f | head -20

Repository: Sylius/Sylius

Length of output: 2429


🏁 Script executed:

#!/bin/bash
# Examine the context file for assertion patterns and similar steps
echo "=== Looking at the ManagingPromotionsContext file ==="
rg -n "assertion|hasLabel|#\[When\]|#\[Then\]" "src/Sylius/Behat/Context/Ui/Admin/ManagingPromotionsContext.php" -A 2

Repository: Sylius/Sylius

Length of output: 188


🏁 Script executed:

#!/bin/bash
# Check the immediate context around the method to understand its usage pattern
echo "=== Examining the method and its assertions ==="
sed -n '120,140p' "src/Sylius/Behat/Context/Ui/Admin/ManagingPromotionsContext.php"

Repository: Sylius/Sylius

Length of output: 1165


🏁 Script executed:

#!/bin/bash
# Check if similar assertion methods in the file use #[Then] or #[When]
echo "=== Looking for other assertion-like methods in the file ==="
rg -n "should|have" "src/Sylius/Behat/Context/Ui/Admin/ManagingPromotionsContext.php" | head -30

Repository: Sylius/Sylius

Length of output: 2692


Change #[When] to #[Then] for this assertion step.

The step text "should have a label" and the method implementation (which calls hasLabel()) both indicate this is a verification step, not an action. It should use #[Then] to match the semantic pattern used by other assertion steps in this file (e.g., lines 97, 99, 371, 391, 421, 485).

Note: The same issue exists in src/Sylius/Behat/Context/Api/Admin/ManagingPromotionsContext.php:546 with the identical step definition.

🤖 Prompt for AI Agents
In `@src/Sylius/Behat/Context/Ui/Admin/ManagingPromotionsContext.php` around lines
127 - 132, Change the step attribute on the assertion method
thePromotionShouldHaveLabelInLocale from #[When('the :promotion promotion should
have a label :label in :localeCode locale')] to #[Then('the :promotion promotion
should have a label :label in :localeCode locale')] because this is a
verification step (it calls $this->formElement->hasLabel). Also make the
identical change for the matching assertion method in the Api Admin
ManagingPromotionsContext class (the method with the same step
text/thePromotionShouldHaveLabelInLocale) so both contexts use #[Then].

Comment on lines 250 to 258
/**
* @When /^I add the "Item percentage discount" action configured with a percentage value of "(?:|-)([^"]+)%"$/
* @When I add the "Item percentage discount" action configured without a percentage value
* @WhenI add the "Item percentage discount" action configured without a percentage value
*/
#[When('/^I add the "Item percentage discount" action configured with a percentage value of "(?:|-)([^"]+)%"$/')]
public function iAddTheItemPercentageDiscountActionConfiguredWithAPercentageValue($percentage = null)
{
$this->formElement->addAction(UnitPercentageDiscountPromotionActionCommand::TYPE);
$this->formElement->fillActionOption('Percentage', $percentage ?? '');
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Leftover annotation not converted to PHP attribute — step definition is broken.

The @WhenI add the "Item percentage discount" action configured without a percentage value annotation on Line 251 was not converted to a #[When(...)] attribute. Additionally, the annotation itself is malformed (missing space between @When and I), so this step was likely already broken before this PR.

Compare with the analogous "Order percentage discount" method at Lines 242–248, which correctly has both variants as attributes. This method should follow the same pattern.

Proposed fix
-    /**
-     * `@WhenI` add the "Item percentage discount" action configured without a percentage value
-     */
     #[When('/^I add the "Item percentage discount" action configured with a percentage value of "(?:|-)([^"]+)%"$/')]
+    #[When('I add the "Item percentage discount" action configured without a percentage value')]
     public function iAddTheItemPercentageDiscountActionConfiguredWithAPercentageValue($percentage = null)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/**
* @When /^I add the "Item percentage discount" action configured with a percentage value of "(?:|-)([^"]+)%"$/
* @When I add the "Item percentage discount" action configured without a percentage value
* @WhenI add the "Item percentage discount" action configured without a percentage value
*/
#[When('/^I add the "Item percentage discount" action configured with a percentage value of "(?:|-)([^"]+)%"$/')]
public function iAddTheItemPercentageDiscountActionConfiguredWithAPercentageValue($percentage = null)
{
$this->formElement->addAction(UnitPercentageDiscountPromotionActionCommand::TYPE);
$this->formElement->fillActionOption('Percentage', $percentage ?? '');
}
#[When('/^I add the "Item percentage discount" action configured with a percentage value of "(?:|-)([^"]+)%"$/')]
#[When('I add the "Item percentage discount" action configured without a percentage value')]
public function iAddTheItemPercentageDiscountActionConfiguredWithAPercentageValue($percentage = null)
{
$this->formElement->addAction(UnitPercentageDiscountPromotionActionCommand::TYPE);
$this->formElement->fillActionOption('Percentage', $percentage ?? '');
}
🤖 Prompt for AI Agents
In `@src/Sylius/Behat/Context/Ui/Admin/ManagingPromotionsContext.php` around lines
250 - 258, The step definition
iAddTheItemPercentageDiscountActionConfiguredWithAPercentageValue has a
leftover/malformed docblock annotation and lacks the corresponding PHP attribute
for the variant without a percentage; remove the malformed "@WhenI ..." docblock
entry and add a second #[When(...)] attribute matching the no-percentage regex
(like the analogous Order percentage method uses) so both variants (with and
without percentage) are defined for
UnitPercentageDiscountPromotionActionCommand::TYPE and the method continues to
call formElement->addAction(...) and fillActionOption('Percentage', ...).

Comment on lines +77 to 81
#[When('I set the end date to :endDate')]
public function iSetTheEndDateTo(string $endDate): void
{
$this->createPage->specifyStartDate(new \DateTime($endDate));
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Bug: iSetTheEndDateTo calls specifyStartDate instead of specifyEndDate.

This is a copy-paste error from iSetTheStartDateTo above. The end date step will incorrectly overwrite the start date.

🐛 Proposed fix
     #[When('I set the end date to :endDate')]
     public function iSetTheEndDateTo(string $endDate): void
     {
-        $this->createPage->specifyStartDate(new \DateTime($endDate));
+        $this->createPage->specifyEndDate(new \DateTime($endDate));
     }
🤖 Prompt for AI Agents
In `@src/Sylius/Behat/Context/Ui/Admin/ManagingTaxRateContext.php` around lines 77
- 81, The step implementation iSetTheEndDateTo currently calls
$this->createPage->specifyStartDate(new \DateTime($endDate)) which overwrites
the start date; change the call to $this->createPage->specifyEndDate(new
\DateTime($endDate)) so the end date is set correctly, leaving the method
signature iSetTheEndDateTo(string $endDate): void and using the same DateTime
construction.

Comment on lines +16 to 17
use Behat\Step\When;
use Behat\Behat\Context\Context;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Imports are not sorted alphabetically.

Behat\Behat\Context\Context should precede Behat\Step\When alphabetically.

Proposed fix
-use Behat\Step\When;
 use Behat\Behat\Context\Context;
+use Behat\Step\When;

As per coding guidelines: "Sort PHP use imports alphabetically and group by type (classes, functions, constants)".

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
use Behat\Step\When;
use Behat\Behat\Context\Context;
use Behat\Behat\Context\Context;
use Behat\Step\When;
🤖 Prompt for AI Agents
In `@src/Sylius/Behat/Context/Ui/Admin/ProductVariantsCreationContext.php` around
lines 16 - 17, Reorder the PHP use imports in ProductVariantsCreationContext so
they are alphabetized and grouped by type: place "use
Behat\Behat\Context\Context;" before "use Behat\Step\When;" (and adjust any
other class/function/constant imports in this file to follow the same rule) to
comply with the project's import-sorting guideline.

@TheMilek TheMilek merged commit 055e163 into Sylius:2.3 Feb 17, 2026
36 checks passed
@loic425 loic425 deleted the behat-annotations-to-attributes/ui-admin branch February 25, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants