Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ECS] Add Code Checking In the Tests Directory and Implement Fixes For the New Code #15558

Merged
merged 5 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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
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