Convert Behat annotations to PHP attributes in Api Admin contexts#18821
Conversation
📝 WalkthroughWalkthroughThis pull request systematically migrates Behat step definitions across 46 Admin API context files from PHPDoc-based annotations ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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 delete from Bunnyshell failedCheck https://github.com/Sylius/Sylius/actions/runs/21981134062 for details. See: Environment Details Available commands:
|
There was a problem hiding this comment.
Actionable comments posted: 6
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/Sylius/Behat/Context/Api/Admin/ManagingCatalogPromotionsContext.php (1)
438-458:⚠️ Potential issue | 🔴 CriticalCritical: undefined variables and call to non-existent method
This method has multiple issues that will cause runtime failures:
- Lines 447–448:
$typeand$configurationare undefined variables. The method signature only declares$catalogPromotionand$productVariantparameters; these variables are never defined.- Line 453:
$this->changeFirstScopeConfigurationTo(...)does not exist in this class or in itsValidationTrait, nor anywhere in the Behat context codebase.- The method contains conflicting code paths — lines 446–452 perform manual scope manipulation and call
update(), while lines 453–457 attempt similar logic via a non-existent helper method.This appears to be a bad merge where two implementations were left in the same method. The code will crash at runtime with undefined variable notices and a fatal "Call to undefined method" error when any Behat scenario exercises this step.
Likely intended implementation
#[When('/^I edit ("[^"]+" catalog promotion) to be applied on ("[^"]+" variant)$/')] public function iEditCatalogPromotionToBeAppliedOnVariant( CatalogPromotionInterface $catalogPromotion, ProductVariantInterface $productVariant, ): void { $this->client->buildUpdateRequest(Resources::CATALOG_PROMOTIONS, $catalogPromotion->getCode()); $content = $this->client->getContent(); unset($content['scopes'][0]); - $content['scopes'][0]['type'] = $type; - $content['scopes'][0]['configuration'] = $configuration; - - $this->client->setRequestData($content); - - $this->client->update(); - $this->changeFirstScopeConfigurationTo( - $catalogPromotion, - InForVariantsScopeVariantChecker::TYPE, - ['variants' => [$productVariant->getCode()]], - ); + $content['scopes'][0] = [ + 'type' => InForVariantsScopeVariantChecker::TYPE, + 'configuration' => ['variants' => [$productVariant->getCode()]], + ]; + + $this->client->setRequestData($content); + $this->client->update(); }
🤖 Fix all issues with AI agents
In `@src/Sylius/Behat/Context/Api/Admin/ManagingCatalogPromotionsContext.php`:
- Around line 1265-1275: Replace the incorrect step annotations on the assertion
methods: change the attribute on the itShouldBeExclusive() method from
#[Given('it should be exclusive')] to #[Then('it should be exclusive')], and
likewise change the attribute on itShouldNotBeExclusive() from #[Given('it
should not be exclusive')] to #[Then('it should not be exclusive')], keeping the
method bodies (the Assert::true/false calls using
$this->responseChecker->hasValue and $this->client->getLastResponse())
unchanged.
In `@src/Sylius/Behat/Context/Api/Admin/ManagingLocalesContext.php`:
- Around line 132-136: The step definition
iShouldBeInformedThatLocaleHasBeenDeleted captures $localeCode but never
verifies it; enhance the assertion by extracting the response body from
$this->client->getLastResponse(), decode it (or read location header) and assert
it references the expected $localeCode (e.g., compare returned resource
identifier or Location header to $localeCode), or if there is no body/identifier
intentionally, add a PHPMD suppression comment for the unused parameter; update
the assertion in iShouldBeInformedThatLocaleHasBeenDeleted accordingly to either
validate the deleted locale matches $localeCode or explicitly document/suppress
the unused parameter.
In `@src/Sylius/Behat/Context/Api/Admin/ManagingProductOptionsContext.php`:
- Around line 213-216: Remove the leftover malformed PHPDoc block or convert it
to a proper attribute: delete the stray PHPDoc lines starting with "* *
`@Then`" that sit above the method in ManagingProductOptionsContext, or if the
locale-aware step is required replace that PHPDoc with a #[Then('/^(this product
option) should not have the "([^"]*)" option value in ("([^"]+)" locale)$/')]
attribute and update the corresponding method (the method currently annotated
with #[Then('/^(this product option) should not have the "([^"]*)" option
value$/')]) to accept the extra locale parameter (add a $locale string parameter
and handle it inside the method).
In `@src/Sylius/Behat/Context/Api/Admin/ManagingProductTaxonsContext.php`:
- Around line 16-18: Reorder the PHP use imports to follow the project's
alphabetical/grouping rules: move ApiPlatform\Metadata\IriConverterInterface and
Behat\Behat\Context\Context before the Behat\Step imports, and ensure
Behat\Step\Then appears before Behat\Step\When; update the use block in
ManagingProductTaxonsContext.php accordingly so imports are grouped and sorted
alphabetically.
In `@src/Sylius/Behat/Context/Api/Admin/ManagingPromotionsContext.php`:
- Around line 546-552: Change the Behat step attribute on the
thePromotionShouldHaveLabelInLocale method from #[When(...)] to #[Then(...)] to
reflect that it is an assertion/verification step; locate the method named
thePromotionShouldHaveLabelInLocale and update its attribute decorator
accordingly so the step uses #[Then('the :promotion promotion should have a
label :label in :localeCode locale')].
In `@src/Sylius/Behat/Context/Api/Admin/ManagingTaxRatesContext.php`:
- Around line 16-18: Reorder the PHP use imports in ManagingTaxRatesContext.php
to follow the project's alphabetical/grouping rules: place the ApiPlatform use
(IriConverterInterface) and any Behat\Behat\... groupings before the Behat\Step
imports, and within the Behat\Step group sort alphabetically so Then comes
before When; update the three imports (IriConverterInterface, Then, When) so
they are in the correct grouped order and alphabetically sorted.
🧹 Nitpick comments (31)
src/Sylius/Behat/Context/Api/Admin/TranslationContext.php (1)
16-17: Imports are not in alphabetical order.
Behat\Behat\Context\Contextshould come beforeBehat\Step\Then.Proposed fix
-use Behat\Step\Then; use Behat\Behat\Context\Context; +use Behat\Step\Then; use Sylius\Behat\Client\ApiClientInterface;As per coding guidelines: "Sort PHP
useimports alphabetically and group by type (classes, functions, constants)".src/Sylius/Behat/Context/Api/Admin/ManagingProductVariantsPricesContext.php (1)
16-17: Import order:Behat\Behat\Context\Contextshould precedeBehat\Step\Whenalphabetically.-use Behat\Step\When; use Behat\Behat\Context\Context; +use Behat\Step\When;As per coding guidelines: "Sort PHP
useimports alphabetically and group by type."src/Sylius/Behat/Context/Api/Admin/ManagingProductAssociationsContext.php (1)
16-17: Import statements are not sorted alphabetically.
Behat\Step\Thenshould come beforeBehat\Step\When.Proposed fix
-use Behat\Step\When; use Behat\Step\Then; +use Behat\Step\When;As per coding guidelines: "Sort PHP
useimports alphabetically and group by type (classes, functions, constants)".src/Sylius/Behat/Context/Api/Admin/ManagingTaxonImagesContext.php (1)
16-17: Import order:Thenshould precedeWhenalphabetically.As per coding guidelines,
useimports should be sorted alphabetically.Behat\Step\Thenshould come beforeBehat\Step\When.Suggested fix
-use Behat\Step\When; -use Behat\Step\Then; +use Behat\Step\Then; +use Behat\Step\When;src/Sylius/Behat/Context/Api/Admin/ManagingCustomerGroupsContext.php (1)
16-17: Import statements are not sorted alphabetically.
Behat\Step\Thenshould come beforeBehat\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
useimports alphabetically and group by type (classes, functions, constants)".src/Sylius/Behat/Context/Api/Admin/ManagingPaymentMethodsContext.php (1)
16-18: Imports are not sorted alphabetically.The
Behat\Step\*imports should be ordered alphabetically per the project's coding guidelines:Given,Then,When.Proposed 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
useimports alphabetically and group by type (classes, functions, constants)".src/Sylius/Behat/Context/Api/Admin/RemovingProductContext.php (1)
16-18: Imports are not sorted alphabetically.
Behat\Behat\Context\Contextshould precede theBehat\Step\*imports, andThenshould come beforeWhen.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
useimports alphabetically and group by type (classes, functions, constants)".src/Sylius/Behat/Context/Api/Admin/ManagingChannelsBillingDataContext.php (1)
16-17: Imports are not in alphabetical order.
Behat\Behat\Context\Contextshould precedeBehat\Step\Thenalphabetically.Suggested fix
-use Behat\Step\Then; use Behat\Behat\Context\Context; +use Behat\Step\Then; use Sylius\Behat\Client\ApiClientInterface;As per coding guidelines: "Sort PHP
useimports alphabetically and group by type (classes, functions, constants)."src/Sylius/Behat/Context/Api/Admin/ManagingShipmentsContext.php (1)
16-17: Import order:Thenshould precedeWhenalphabetically.Suggested fix
-use Behat\Step\When; -use Behat\Step\Then; +use Behat\Step\Then; +use Behat\Step\When;As per coding guidelines: "Sort PHP
useimports alphabetically and group by type."src/Sylius/Behat/Context/Api/Admin/ManagingProductImagesContext.php (1)
16-17: Imports are not sorted alphabetically.
Behat\Step\Thenshould come beforeBehat\Step\When. As per coding guidelines: "Sort PHPuseimports 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/Api/Admin/ManagingCurrenciesContext.php (1)
16-18: Imports are not sorted alphabetically.
Behat\Behat\Context\Contextshould come before theBehat\Step\*imports per alphabetical ordering.Suggested order
-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
useimports alphabetically and group by type (classes, functions, constants)."src/Sylius/Behat/Context/Api/Admin/ManagingExchangeRatesContext.php (1)
16-18: Imports not sorted alphabetically.
useimports should beGiven,Then,Whento respect alphabetical order.Proposed fix
use Behat\Step\Given; -use Behat\Step\When; use Behat\Step\Then; +use Behat\Step\When;As per coding guidelines: "Sort PHP
useimports alphabetically and group by type."src/Sylius/Behat/Context/Api/Admin/ManagingShippingCategoriesContext.php (1)
16-18: Imports are not sorted alphabetically.
Behat\Behat\Context\Contextshould precedeBehat\Step\*, andThenshould come beforeWhen. As per coding guidelines, PHPuseimports should be sorted alphabetically.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/Api/Admin/ManagingProductsContext.php (1)
16-18: Imports not sorted alphabetically:Thenshould come beforeWhen.As per coding guidelines,
useimports should be sorted alphabetically.Proposed fix
use Behat\Step\Given; -use Behat\Step\When; use Behat\Step\Then; +use Behat\Step\When;src/Sylius/Behat/Context/Api/Admin/ManagingProductAttributesContext.php (1)
16-18: Imports are not sorted alphabetically.
Behat\Step\WhenandBehat\Step\Thenshould followBehat\Behat\Context\Context, andThenshould precedeWhen.Suggested order
-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
useimports alphabetically and group by type (classes, functions, constants)".src/Sylius/Behat/Context/Api/Admin/ManagingOrdersContext.php (2)
16-17: Imports are not sorted alphabetically.
Behat\Step\Given(line 16) should come afterApiPlatform\Metadata\IriConverterInterface(line 17) to maintain alphabetical order.Proposed fix
-use Behat\Step\Given; use ApiPlatform\Metadata\IriConverterInterface; use Behat\Behat\Context\Context; +use Behat\Step\Given; use Behat\Step\Then;As per coding guidelines: "Sort PHP
useimports alphabetically and group by type (classes, functions, constants)".
590-599: Missing return type declaration.
iShouldNotSeeOrderWithNumberon line 591 is missing a: voidreturn type, unlike every other method in this class. This is likely a pre-existing oversight but worth fixing while touching this file.Proposed fix
- public function iShouldNotSeeOrderWithNumber(string $orderNumber) + public function iShouldNotSeeOrderWithNumber(string $orderNumber): voidAs per coding guidelines: "Add type declarations for all properties, arguments, and return values in PHP code".
src/Sylius/Behat/Context/Api/Admin/ManagingProductVariantsContext.php (1)
16-17: Import order:Thenshould come beforeWhenalphabetically.As per coding guidelines, "Sort PHP
useimports alphabetically and group by type."Behat\Step\Thenshould precedeBehat\Step\When.Proposed fix
-use Behat\Step\When; -use Behat\Step\Then; +use Behat\Step\Then; +use Behat\Step\When;src/Sylius/Behat/Context/Api/Admin/ManagingLocalesContext.php (1)
16-18: Import statements are not sorted alphabetically.
Thenshould come beforeWhenper alphabetical ordering.Proposed fix
use Behat\Step\Given; -use Behat\Step\When; use Behat\Step\Then; +use Behat\Step\When;As per coding guidelines: "Sort PHP
useimports alphabetically and group by type".src/Sylius/Behat/Context/Api/Admin/ManagingProductAssociationTypesContext.php (1)
164-164: Nit: unnecessary regex for a plain string pattern.Line 164 wraps the step pattern in regex delimiters (
/^...$/) but this pattern has no captures, optional groups, or wildcards. All other simple string patterns in this file use plain Turnip syntax (e.g., line 129). Consider using a plain string for consistency:Suggested change
- #[Then('/^I should be notified that it has been successfully deleted$/')] + #[Then('I should be notified that it has been successfully deleted')]src/Sylius/Behat/Context/Api/Admin/ManagingCustomersContext.php (1)
16-17: Import placement is out of alphabetical order, but otherwise correct.The new
use Behat\Step\Whenanduse Behat\Step\Thenimports should be placed afterBehat\Behat\Context\Context(andThenbeforeWhen) to maintain alphabetical ordering. Noting this as a nit since no linter/static analysis tool flagged it. As per coding guidelines, "Sort PHPuseimports alphabetically and group by type (classes, functions, constants)."Suggested reordering
-use Behat\Step\When; -use Behat\Step\Then; use ApiPlatform\Metadata\IriConverterInterface; use Behat\Behat\Context\Context; +use Behat\Step\Then; +use Behat\Step\When; use Sylius\Behat\Client\ApiClientInterface;src/Sylius/Behat/Context/Api/Admin/ManagingProductOptionsContext.php (1)
16-18: Nit:useimports forBehat\Stepare not sorted alphabetically.
Thenshould come beforeWhen.Suggested fix
use Behat\Step\Given; -use Behat\Step\When; use Behat\Step\Then; +use Behat\Step\When;As per coding guidelines, "Sort PHP
useimports alphabetically and group by type".src/Sylius/Behat/Context/Api/Admin/CreatingProductVariantContext.php (1)
16-17: Imports are not sorted alphabetically.
Behat\Step\When(Line 16) is placed beforeApiPlatform\Metadata\IriConverterInterface(Line 17). As per coding guidelines,useimports should be sorted alphabetically.Proposed fix
-use Behat\Step\When; use ApiPlatform\Metadata\IriConverterInterface; use Behat\Behat\Context\Context; +use Behat\Step\When;src/Sylius/Behat/Context/Api/Admin/ManagingChannelPriceHistoryConfigContext.php (1)
16-18: Imports are not sorted alphabetically.
Behat\Step\WhenandBehat\Step\Then(Lines 16–17) are placed beforeBehat\Behat\Context\Context(Line 18), andWhenprecedesThen. Alphabetically,Behat\Behat<Behat\Step\Then<Behat\Step\When.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/Api/Admin/DashboardContext.php (1)
16-18: Imports are not sorted alphabetically — same pattern as the other files.
Behat\Step\*imports should followBehat\Behat\Context\Context.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/Api/Admin/ManagingPaymentRequestsContext.php (1)
16-18: Imports are not sorted alphabetically — consistent with the other files in this PR.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/Api/Admin/ManagingTaxonsContext.php (1)
16-18: Imports are not sorted alphabetically — consistent with the other files in this PR.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/Api/Admin/ManagingTaxCategoriesContext.php (1)
16-19: Imports are not sorted alphabetically.
Behat\Step\*imports should followBehat\Behat\Context\Context, and within the group:Given<Then<When.Proposed fix
-use Behat\Step\Given; -use Behat\Step\When; -use Behat\Step\Then; use Behat\Behat\Context\Context; +use Behat\Step\Given; +use Behat\Step\Then; +use Behat\Step\When;src/Sylius/Behat/Context/Api/Admin/ManagingPaymentsContext.php (1)
16-19: Imports are not sorted alphabetically — consistent with the other files in this PR.Proposed fix
-use Behat\Step\Given; -use Behat\Step\When; -use Behat\Step\Then; use Behat\Behat\Context\Context; +use Behat\Step\Given; +use Behat\Step\Then; +use Behat\Step\When;src/Sylius/Behat/Context/Api/Admin/ManagingCountriesContext.php (1)
16-19: Imports are not sorted alphabetically.
Behat\Step\WhenandBehat\Step\Then(Lines 16–17) are placed beforeApiPlatform\Metadata\IriConverterInterface(Line 18). Alphabetically,ApiPlatform<Behat\Behat<Behat\Step\Then<Behat\Step\When.Proposed fix
-use Behat\Step\When; -use Behat\Step\Then; use ApiPlatform\Metadata\IriConverterInterface; use Behat\Behat\Context\Context; +use Behat\Step\Then; +use Behat\Step\When;src/Sylius/Behat/Context/Api/Admin/Helper/ValidationTrait.php (1)
16-17: Imports are not sorted alphabetically.
Behat\Step\Thenshould come beforeBehat\Step\When. This same issue applies to all files in this PR.Proposed fix
-use Behat\Step\When; use Behat\Step\Then; +use Behat\Step\When;As per coding guidelines: "Sort PHP
useimports alphabetically and group by type".
| #[Given('it should be exclusive')] | ||
| public function itShouldBeExclusive(): void | ||
| { | ||
| Assert::true($this->responseChecker->hasValue($this->client->getLastResponse(), 'exclusive', true)); | ||
| } | ||
|
|
||
| /** | ||
| * @Given it should not be exclusive | ||
| */ | ||
| #[Given('it should not be exclusive')] | ||
| public function itShouldNotBeExclusive(): void | ||
| { | ||
| Assert::false($this->responseChecker->hasValue($this->client->getLastResponse(), 'exclusive', true)); | ||
| } |
There was a problem hiding this comment.
#[Given] used for assertion steps — should be #[Then].
Lines 1265 and 1271 use #[Given('it should be exclusive')] and #[Given('it should not be exclusive')]. These are assertion steps and should use #[Then] to follow the Given-When-Then convention. Based on learnings, Behat scenarios should follow the Given-When-Then pattern strictly.
Suggested fix
- #[Given('it should be exclusive')]
+ #[Then('it should be exclusive')]
public function itShouldBeExclusive(): void
{
Assert::true($this->responseChecker->hasValue($this->client->getLastResponse(), 'exclusive', true));
}
- #[Given('it should not be exclusive')]
+ #[Then('it should not be exclusive')]
public function itShouldNotBeExclusive(): void🤖 Prompt for AI Agents
In `@src/Sylius/Behat/Context/Api/Admin/ManagingCatalogPromotionsContext.php`
around lines 1265 - 1275, Replace the incorrect step annotations on the
assertion methods: change the attribute on the itShouldBeExclusive() method from
#[Given('it should be exclusive')] to #[Then('it should be exclusive')], and
likewise change the attribute on itShouldNotBeExclusive() from #[Given('it
should not be exclusive')] to #[Then('it should not be exclusive')], keeping the
method bodies (the Assert::true/false calls using
$this->responseChecker->hasValue and $this->client->getLastResponse())
unchanged.
| #[Then('I should be informed that locale :localeCode has been deleted')] | ||
| public function iShouldBeInformedThatLocaleHasBeenDeleted(string $localeCode): void | ||
| { | ||
| Assert::same($this->client->getLastResponse()->getStatusCode(), Response::HTTP_NO_CONTENT); | ||
| } |
There was a problem hiding this comment.
$localeCode parameter is captured but never verified.
The method only asserts HTTP_NO_CONTENT without confirming the deleted locale matches $localeCode. While the preceding step likely targets the correct resource, this makes the assertion weaker than the step text implies. Consider whether validating the locale code adds value here, or suppress the PHPMD warning if this is intentional.
🧰 Tools
🪛 PHPMD (2.15.0)
[warning] 133-133: Avoid unused parameters such as '$localeCode'. (undefined)
(UnusedFormalParameter)
🤖 Prompt for AI Agents
In `@src/Sylius/Behat/Context/Api/Admin/ManagingLocalesContext.php` around lines
132 - 136, The step definition iShouldBeInformedThatLocaleHasBeenDeleted
captures $localeCode but never verifies it; enhance the assertion by extracting
the response body from $this->client->getLastResponse(), decode it (or read
location header) and assert it references the expected $localeCode (e.g.,
compare returned resource identifier or Location header to $localeCode), or if
there is no body/identifier intentionally, add a PHPMD suppression comment for
the unused parameter; update the assertion in
iShouldBeInformedThatLocaleHasBeenDeleted accordingly to either validate the
deleted locale matches $localeCode or explicitly document/suppress the unused
parameter.
| /** | ||
| * @Then /^(this product option) should not have the "([^"]*)" option value$/ | ||
| * @Then /^(this product option) should not have the "([^"]*)" option value in ("([^"]+)" locale)$/ | ||
| * * @Then /^(this product option) should not have the "([^"]*)" option value in ("([^"]+)" locale)$/ | ||
| */ | ||
| #[Then('/^(this product option) should not have the "([^"]*)" option value$/')] |
There was a problem hiding this comment.
Leftover malformed PHPDoc annotation not converted to attribute.
This PHPDoc block contains what appears to be an unconverted @Then annotation with a locale-aware pattern. The double * and extra indentation (* * @Then``) make it malformed — Behat won't match it either as an annotation or an attribute.
If this step pattern is still needed, convert it to a #[Then(...)] attribute (and update the method signature to accept a locale parameter). If it's intentionally dropped, remove the PHPDoc block entirely.
Suggested fix (remove dead annotation)
- /**
- * * `@Then` /^(this product option) should not have the "([^"]*)" option value in ("([^"]+)" locale)$/
- */
#[Then('/^(this product option) should not have the "([^"]*)" option value$/')]📝 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.
| /** | |
| * @Then /^(this product option) should not have the "([^"]*)" option value$/ | |
| * @Then /^(this product option) should not have the "([^"]*)" option value in ("([^"]+)" locale)$/ | |
| * * @Then /^(this product option) should not have the "([^"]*)" option value in ("([^"]+)" locale)$/ | |
| */ | |
| #[Then('/^(this product option) should not have the "([^"]*)" option value$/')] | |
| #[Then('/^(this product option) should not have the "([^"]*)" option value$/')] |
🤖 Prompt for AI Agents
In `@src/Sylius/Behat/Context/Api/Admin/ManagingProductOptionsContext.php` around
lines 213 - 216, Remove the leftover malformed PHPDoc block or convert it to a
proper attribute: delete the stray PHPDoc lines starting with "* * `@Then`"
that sit above the method in ManagingProductOptionsContext, or if the
locale-aware step is required replace that PHPDoc with a #[Then('/^(this product
option) should not have the "([^"]*)" option value in ("([^"]+)" locale)$/')]
attribute and update the corresponding method (the method currently annotated
with #[Then('/^(this product option) should not have the "([^"]*)" option
value$/')]) to accept the extra locale parameter (add a $locale string parameter
and handle it inside the method).
| use Behat\Step\When; | ||
| use Behat\Step\Then; | ||
| use ApiPlatform\Metadata\IriConverterInterface; |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
Imports are not sorted alphabetically.
Behat\Step\When and Behat\Step\Then should be placed after ApiPlatform\Metadata\IriConverterInterface and Behat\Behat\Context\Context, and Then should come before When.
♻️ Proposed fix
-use Behat\Step\When;
-use Behat\Step\Then;
use ApiPlatform\Metadata\IriConverterInterface;
use Behat\Behat\Context\Context;
+use Behat\Step\Then;
+use Behat\Step\When;
use Sylius\Behat\Client\ApiClientInterface;As per coding guidelines: "Sort PHP use imports alphabetically and group by type (classes, functions, constants)".
🤖 Prompt for AI Agents
In `@src/Sylius/Behat/Context/Api/Admin/ManagingProductTaxonsContext.php` around
lines 16 - 18, Reorder the PHP use imports to follow the project's
alphabetical/grouping rules: move ApiPlatform\Metadata\IriConverterInterface and
Behat\Behat\Context\Context before the Behat\Step imports, and ensure
Behat\Step\Then appears before Behat\Step\When; update the use block in
ManagingProductTaxonsContext.php accordingly so imports are grouped and sorted
alphabetically.
| #[When('the :promotion promotion should have a label :label in :localeCode locale')] | ||
| public function thePromotionShouldHaveLabelInLocale(PromotionInterface $promotion, string $label, string $localeCode): void | ||
| { | ||
| $response = $this->client->show(Resources::PROMOTIONS, $promotion->getCode()); | ||
|
|
||
| Assert::true($this->responseChecker->hasTranslation($response, $localeCode, 'label', $label)); | ||
| } |
There was a problem hiding this comment.
#[When] should likely be #[Then] for this assertion step.
The step text 'the :promotion promotion should have a label :label in :localeCode locale' reads as a verification/assertion, which conventionally maps to #[Then]. Using #[When] here will still work at runtime (Behat doesn't enforce Given/When/Then semantics), but it breaks the Given-When-Then convention.
Suggested fix
- #[When('the :promotion promotion should have a label :label in :localeCode locale')]
+ #[Then('the :promotion promotion should have a label :label in :localeCode locale')]🤖 Prompt for AI Agents
In `@src/Sylius/Behat/Context/Api/Admin/ManagingPromotionsContext.php` around
lines 546 - 552, Change the Behat step attribute on the
thePromotionShouldHaveLabelInLocale method from #[When(...)] to #[Then(...)] to
reflect that it is an assertion/verification step; locate the method named
thePromotionShouldHaveLabelInLocale and update its attribute decorator
accordingly so the step uses #[Then('the :promotion promotion should have a
label :label in :localeCode locale')].
| use Behat\Step\When; | ||
| use Behat\Step\Then; | ||
| use ApiPlatform\Metadata\IriConverterInterface; |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
Imports are not sorted alphabetically.
The new use statements should be placed after ApiPlatform\... and Behat\Behat\..., and Then should precede When.
Proposed fix
-use Behat\Step\When;
-use Behat\Step\Then;
use ApiPlatform\Metadata\IriConverterInterface;
use Behat\Behat\Context\Context;
+use Behat\Step\Then;
+use Behat\Step\When;
use Sylius\Behat\Client\ApiClientInterface;As per coding guidelines: "Sort PHP use imports alphabetically and group by type (classes, functions, constants)".
🤖 Prompt for AI Agents
In `@src/Sylius/Behat/Context/Api/Admin/ManagingTaxRatesContext.php` around lines
16 - 18, Reorder the PHP use imports in ManagingTaxRatesContext.php to follow
the project's alphabetical/grouping rules: place the ApiPlatform use
(IriConverterInterface) and any Behat\Behat\... groupings before the Behat\Step
imports, and within the Behat\Step group sort alphabetically so Then comes
before When; update the three imports (IriConverterInterface, Then, When) so
they are in the correct grouped order and alphabetically sorted.
Summary by CodeRabbit
Release Notes
Tests
Refactor