Skip to content

Commit

Permalink
minor #15558 [ECS] Add Code Checking In the Tests Directory and Imple…
Browse files Browse the repository at this point in the history
…ment Fixes For the New Code (Rafikooo)

This PR was merged into the 1.13 branch.

Discussion
----------

| Q               | A                                                            |
|-----------------|--------------------------------------------------------------|
| Branch?         | 1.13 <!-- see the comment below -->                  |
| Bug fix?        | no                                                      |
| New feature?    | no                                                      |
| BC breaks?      | no                                                      |
| Deprecations?   | no<!-- don't forget to update the UPGRADE-*.md file --> |
| Related tickets |  #15532 (comment)                     |
| License         | MIT                                                          |

To save developers' effort during the code review, we added coding standards checks into the unit tests directory as well.

Commits
-------
  [ECS] Add checking in the tests directory
  [ECS] Apply ecs fixes in the tests directory
  [ECS] Apply ecs fixes
  [ECS] Apply another ecs fixes
  [Behat][UI] Add strong typing in the CartContext class
  • Loading branch information
NoResponseMate committed Dec 5, 2023
2 parents 41adfa8 + 2503a69 commit 812926f
Show file tree
Hide file tree
Showing 76 changed files with 421 additions and 312 deletions.
2 changes: 1 addition & 1 deletion ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
$config->import('vendor/sylius-labs/coding-standard/ecs.php');

$config->parallel();
$config->paths(['src/Sylius']);
$config->paths(['src/Sylius', 'tests']);
$config->skip([
InlineDocCommentDeclarationSniff::class . '.MissingVariable',
InlineDocCommentDeclarationSniff::class . '.NoAssignment',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ public function iShouldBeNotifiedThatTheCountryCodeIsRequired(string $constraint
{
Assert::contains(
$this->responseChecker->getError($this->client->getLastResponse()),
$constraint === 'required' ? 'Please enter country ISO code.' : 'Country ISO code is invalid.'
$constraint === 'required' ? 'Please enter country ISO code.' : 'Country ISO code is invalid.',
);
}

Expand Down
7 changes: 3 additions & 4 deletions src/Sylius/Behat/Context/Api/Admin/ManagingOrdersContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ public function iSpecifyFilterDateToAs(string $dateTime): void
$this->client->addFilter('checkoutCompletedAt[before]', $dateTime);
}


/**
* @When I filter by product :productName
* @When I filter by products :firstProduct and :secondProduct
Expand Down Expand Up @@ -147,7 +146,7 @@ public function iSpecifyFilterTotalBeingGreaterThan(string $total): void
*/
public function iSpecifyFilterTotalBeingLessThan(string $total): void
{
$this->client->addFilter('total[lt]', $total. '00');
$this->client->addFilter('total[lt]', $total . '00');
}

/**
Expand Down Expand Up @@ -488,7 +487,7 @@ public function theFirstOrderShouldHaveNumber(string $number): void
*/
public function iShouldSeeTheOrderWithTotal(string $orderNumber, int $total): void
{
$order = $this->responseChecker->getCollectionItemsWithValue(
$order = $this->responseChecker->getCollectionItemsWithValue(
$this->client->getLastResponse(),
'number',
trim($orderNumber, '#'),
Expand Down Expand Up @@ -528,7 +527,7 @@ public function theAdministratorShouldSeeTheOrderWithTotalInOrderList(string $to

private function getCurrencyCodeFromTotal(string $total): string
{
return match(true) {
return match (true) {
str_starts_with($total, '$') => 'USD',
str_starts_with($total, '€') => 'EUR',
str_starts_with($total, '£') => 'GBP',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,8 @@ public function thePaymentMethodWithElementValueShouldNotBeAdded(string $element
public function thisPaymentMethodNameShouldStillBeNamed(string $paymentMethodName): void
{
Assert::inArray(
$paymentMethodName, $this->getPaymentMethodNamesFromCollection(),
$paymentMethodName,
$this->getPaymentMethodNamesFromCollection(),
sprintf('Payment method with name %s does not exist', $paymentMethodName),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ public function thereShouldStillBeOnlyOneCouponWithCodeRelatedTo(string $code, P
$coupons = $this->responseChecker->getCollectionItemsWithValue(
$this->client->subResourceIndex(Resources::PROMOTIONS, Resources::PROMOTION_COUPONS, $promotion->getCode()),
'code',
$code
$code,
);

Assert::count($coupons, 1);
Expand Down
15 changes: 8 additions & 7 deletions src/Sylius/Behat/Context/Api/Admin/ManagingPromotionsContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function iSpecifyItsLabelWithAStringExceedingTheLimitInLocale(string $loc
public function iAddTheActionConfiguredWithAmountForChannel(
string $actionType,
int $amount,
ChannelInterface $channel
ChannelInterface $channel,
): void {
$actionTypeMapping = [
'Order fixed discount' => FixedDiscountPromotionActionCommand::TYPE,
Expand Down Expand Up @@ -214,8 +214,8 @@ public function iAddTheActionConfiguredWithAPercentageValueForChannel(
/**
* @When I add the "Item percentage discount" action configured without a percentage value for :channel channel
*/
public function iAddTheActionConfiguredWithoutAPercentageValueForChannel(ChannelInterface $channel): void {

public function iAddTheActionConfiguredWithoutAPercentageValueForChannel(ChannelInterface $channel): void
{
$this->addToRequestAction(
UnitPercentageDiscountPromotionActionCommand::TYPE,
[
Expand Down Expand Up @@ -358,7 +358,7 @@ public function iAddTheRuleConfiguredWith(TaxonInterface $taxon, int $amount, Ch
public function iAddTheItemTotalRuleConfiguredWithTwoChannel(
int $firstAmount,
ChannelInterface $firstChannel,
int$secondAmount,
int $secondAmount,
ChannelInterface $secondChannel,
): void {
$this->addToRequestRule(
Expand Down Expand Up @@ -640,7 +640,7 @@ public function iShouldNotBeAbleToEditItsCode(): void
public function thePromotionShouldBeAvailableFromTo(
PromotionInterface $promotion,
\DateTimeInterface $startsDate,
\DateTimeInterface $endsDate
\DateTimeInterface $endsDate,
): void {
Assert::true(
$this->responseChecker->hasItemWithValues(
Expand All @@ -650,7 +650,7 @@ public function thePromotionShouldBeAvailableFromTo(
'startsAt' => $startsDate->format('Y-m-d H:i:s'),
'endsAt' => $endsDate->format('Y-m-d H:i:s'),
],
)
),
);
}

Expand Down Expand Up @@ -680,6 +680,7 @@ public function thePromotionsShouldHavePriority(PromotionInterface $promotion, i
),
);
}

/**
* @Then I should be notified that it is in use and cannot be deleted
*/
Expand Down Expand Up @@ -836,7 +837,7 @@ private function addToRequestAction(string $type, array $configuration): void
$this->client->updateRequestData($data);
}

private function getActions(): array
private function getActions(): array
{
return $this->client->getContent()['actions'];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Sylius/Behat/Context/Setup/PromotionContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public function thereIsPromotionWithCoupon(string $promotionName, string $coupon
[
'code' => $couponCode,
'usage_limit' => $usageLimit,
]
],
],
couponBased: true,
startsAt: (new \DateTime('-3 day'))->format('Y-m-d'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public function iAddTheActionConfiguredWithAPercentageValueForChannel(
*/
public function iAddTheActionConfiguredWithoutAPercentageValueForChannel(
string $actionType,
ChannelInterface $channel
ChannelInterface $channel,
): void {
$this->createPage->addAction($actionType);
$this->createPage->fillActionOptionForChannel($channel->getCode(), 'Percentage', '');
Expand Down

0 comments on commit 812926f

Please sign in to comment.