Skip to content

Convert Behat annotations to PHP attributes in UI contexts#18843

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

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

Conversation

@loic425
Copy link
Copy Markdown
Member

@loic425 loic425 commented Feb 18, 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
    • Modernized test framework by migrating step definitions from docblock annotations to PHP 8 attributes across UI context test files (Browser, Channel, Customer, Email, Theme, and User contexts).

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

coderabbitai bot commented Feb 18, 2026

📝 Walkthrough

Walkthrough

This PR converts Behat step docblock annotations (@When, @Then) to PHP 8 attributes (#[When], #[Then]) across six UI context classes. The changes add necessary Behat\Step use statements and maintain all existing method signatures and behavior without functional modifications.

Changes

Cohort / File(s) Summary
Behat UI Context Annotations Migration
src/Sylius/Behat/Context/Ui/*Context.php (BrowserContext, ChannelContext, CustomerContext, EmailContext, ThemeContext, UserContext)
Converted Behat step docblock annotations (@When, @Then) to PHP 8 attributes (#[When], #[Then]) with corresponding use statement imports for Behat\Step namespace. No functional changes to method signatures, visibility, or behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

Maintenance

Suggested reviewers

  • TheMilek
  • GSadee

Poem

🐰 In burrows deep where code does dwell,
Old docblocks gave way—farewell, farewell!
With PHP 8's attributes bright,
The Behat steps now shine with might.
No logic changed, just style's delight!
Hop along, the refactor's tight! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Convert Behat annotations to PHP attributes in UI contexts' accurately summarizes the main change: migrating from docblock annotations to PHP 8 attributes across multiple UI context files.

✏️ 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.

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: 6

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/Sylius/Behat/Context/Ui/BrowserContext.php`:
- Around line 16-17: The two PHP import lines are not alphabetized: move "use
Behat\Behat\Context\Context;" above "use Behat\Step\When;" so the imports are in
alphabetical order; update the use statements in BrowserContext.php to list
Behat\Behat\Context\Context before Behat\Step\When (ensure no other import order
is disturbed).

In `@src/Sylius/Behat/Context/Ui/ChannelContext.php`:
- Around line 16-18: Reorder the PHP use imports in ChannelContext so they
follow the project's alphabetical ordering and the guideline that
Behat\Behat\Context\Context comes before Behat\Step imports: replace the current
block (using Behat\Step\When; use Behat\Step\Then; use
Behat\Behat\Context\Context;) with use Behat\Behat\Context\Context first, then
use Behat\Step\Then and finally use Behat\Step\When; mirror the same ordering
fix applied in ThemeContext and UserContext.

In `@src/Sylius/Behat/Context/Ui/CustomerContext.php`:
- Around line 16-17: The new import use Behat\Step\Then is out of alphabetical
order; reorder the use statements so PHP imports are alphabetized (e.g., ensure
Behat\Behat\Context\Context and Behat\Mink\Exception\ElementNotFoundException
come before Behat\Step\Then), updating the use block in CustomerContext.php so
all Behat-related use lines are sorted lexicographically.

In `@src/Sylius/Behat/Context/Ui/EmailContext.php`:
- Around line 16-17: Reorder the PHP use imports so they are alphabetized: move
the import "use Behat\Behat\Context\Context;" before "use Behat\Step\Then;" in
the imports block of EmailContext.php so that Context sorts before Then,
complying with the project's alphabetical use-import guideline.

In `@src/Sylius/Behat/Context/Ui/ThemeContext.php`:
- Around line 16-18: Reorder the PHP use imports so they are alphabetically
sorted: move Behat\Behat\Context\Context before the Behat\Step\* imports and
within the Behat\Step group place Then before When; update the use statements
for Context, Then, and When in ThemeContext.php accordingly (i.e., import
Context first, then Behat\Step\Then, then Behat\Step\When).

In `@src/Sylius/Behat/Context/Ui/UserContext.php`:
- Around line 16-18: The current use-import ordering in UserContext is
incorrect: move "use Behat\Behat\Context\Context;" before the Step imports and
reorder the Step imports so "use Behat\Step\Then;" comes before "use
Behat\Step\When;"; ensure all use statements in UserContext (and match pattern
used in ThemeContext/ChannelContext) are alphabetized per coding guidelines so
imports are consistently ordered.

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.

⚠️ Potential issue | 🟡 Minor

use Behat\Step\When is out of alphabetical order

Same issue as other files in this PR: Behat\Behat\Context\Context sorts before Behat\Step\When.

As per coding guidelines: "Sort PHP use imports alphabetically".

♻️ Proposed fix
-use Behat\Step\When;
 use Behat\Behat\Context\Context;
+use Behat\Step\When;
📝 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
Verify each finding against the current code and only fix it if needed.

In `@src/Sylius/Behat/Context/Ui/BrowserContext.php` around lines 16 - 17, The two
PHP import lines are not alphabetized: move "use Behat\Behat\Context\Context;"
above "use Behat\Step\When;" so the imports are in alphabetical order; update
the use statements in BrowserContext.php to list Behat\Behat\Context\Context
before Behat\Step\When (ensure no other import order is disturbed).

Comment on lines +16 to 18
use Behat\Step\When;
use Behat\Step\Then;
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.

⚠️ Potential issue | 🟡 Minor

use Behat\Step\* imports have two ordering violations

Same issue as ThemeContext and UserContext: both belong after Behat\Behat\Context\Context, and Then should precede When.

As per coding guidelines: "Sort PHP use imports alphabetically".

♻️ Proposed fix
-use Behat\Step\When;
-use Behat\Step\Then;
 use Behat\Behat\Context\Context;
+use Behat\Step\Then;
+use Behat\Step\When;
📝 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\Behat\Context\Context;
use Behat\Behat\Context\Context;
use Behat\Step\Then;
use Behat\Step\When;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Sylius/Behat/Context/Ui/ChannelContext.php` around lines 16 - 18, Reorder
the PHP use imports in ChannelContext so they follow the project's alphabetical
ordering and the guideline that Behat\Behat\Context\Context comes before
Behat\Step imports: replace the current block (using Behat\Step\When; use
Behat\Step\Then; use Behat\Behat\Context\Context;) with use
Behat\Behat\Context\Context first, then use Behat\Step\Then and finally use
Behat\Step\When; mirror the same ordering fix applied in ThemeContext and
UserContext.

Comment on lines +16 to 17
use Behat\Step\Then;
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.

⚠️ Potential issue | 🟡 Minor

use Behat\Step\Then is out of alphabetical order

Behat\Behat\* sorts before Behat\Step\*, so the new import should be placed after the existing Behat\Behat\Context\Context and Behat\Mink\Exception\ElementNotFoundException imports.

As per coding guidelines: "Sort PHP use imports alphabetically".

♻️ Proposed fix
-use Behat\Step\Then;
 use Behat\Behat\Context\Context;
 use Behat\Mink\Exception\ElementNotFoundException;
+use Behat\Step\Then;
📝 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\Then;
use Behat\Behat\Context\Context;
use Behat\Behat\Context\Context;
use Behat\Mink\Exception\ElementNotFoundException;
use Behat\Step\Then;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Sylius/Behat/Context/Ui/CustomerContext.php` around lines 16 - 17, The
new import use Behat\Step\Then is out of alphabetical order; reorder the use
statements so PHP imports are alphabetized (e.g., ensure
Behat\Behat\Context\Context and Behat\Mink\Exception\ElementNotFoundException
come before Behat\Step\Then), updating the use block in CustomerContext.php so
all Behat-related use lines are sorted lexicographically.

Comment on lines +16 to 17
use Behat\Step\Then;
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.

⚠️ Potential issue | 🟡 Minor

use Behat\Step\Then is out of alphabetical order

Behat\Behat\Context\Context sorts before Behat\Step\Then.

As per coding guidelines: "Sort PHP use imports alphabetically".

♻️ Proposed fix
-use Behat\Step\Then;
 use Behat\Behat\Context\Context;
+use Behat\Step\Then;
📝 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\Then;
use Behat\Behat\Context\Context;
use Behat\Behat\Context\Context;
use Behat\Step\Then;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Sylius/Behat/Context/Ui/EmailContext.php` around lines 16 - 17, Reorder
the PHP use imports so they are alphabetized: move the import "use
Behat\Behat\Context\Context;" before "use Behat\Step\Then;" in the imports block
of EmailContext.php so that Context sorts before Then, complying with the
project's alphabetical use-import guideline.

Comment on lines +16 to 18
use Behat\Step\When;
use Behat\Step\Then;
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.

⚠️ Potential issue | 🟡 Minor

use Behat\Step\* imports have two ordering violations

  1. Both Behat\Step\* entries should appear after Behat\Behat\Context\Context (B < S).
  2. Within the Behat\Step group, Then (T) sorts before When (W).

As per coding guidelines: "Sort PHP use imports alphabetically".

♻️ Proposed fix
-use Behat\Step\When;
-use Behat\Step\Then;
 use Behat\Behat\Context\Context;
+use Behat\Step\Then;
+use Behat\Step\When;
📝 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\Behat\Context\Context;
use Behat\Behat\Context\Context;
use Behat\Step\Then;
use Behat\Step\When;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Sylius/Behat/Context/Ui/ThemeContext.php` around lines 16 - 18, Reorder
the PHP use imports so they are alphabetically sorted: move
Behat\Behat\Context\Context before the Behat\Step\* imports and within the
Behat\Step group place Then before When; update the use statements for Context,
Then, and When in ThemeContext.php accordingly (i.e., import Context first, then
Behat\Step\Then, then Behat\Step\When).

Comment on lines +16 to 18
use Behat\Step\When;
use Behat\Step\Then;
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.

⚠️ Potential issue | 🟡 Minor

use Behat\Step\* imports have two ordering violations

Same pattern as ThemeContext and ChannelContext: both imports belong after Behat\Behat\Context\Context, and Then should precede When.

As per coding guidelines: "Sort PHP use imports alphabetically".

♻️ Proposed fix
-use Behat\Step\When;
-use Behat\Step\Then;
 use Behat\Behat\Context\Context;
+use Behat\Step\Then;
+use Behat\Step\When;
📝 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\Behat\Context\Context;
use Behat\Behat\Context\Context;
use Behat\Step\Then;
use Behat\Step\When;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Sylius/Behat/Context/Ui/UserContext.php` around lines 16 - 18, The
current use-import ordering in UserContext is incorrect: move "use
Behat\Behat\Context\Context;" before the Step imports and reorder the Step
imports so "use Behat\Step\Then;" comes before "use Behat\Step\When;"; ensure
all use statements in UserContext (and match pattern used in
ThemeContext/ChannelContext) are alphabetized per coding guidelines so imports
are consistently ordered.

@TheMilek TheMilek merged commit 2107823 into Sylius:2.3 Feb 18, 2026
36 checks passed
@github-actions
Copy link
Copy Markdown

❗ Preview Environment delete from Bunnyshell failed

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

See: Environment Details

Available commands:

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

@loic425 loic425 deleted the behat-annotations-to-attributes/ui branch February 18, 2026 14:09
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