Skip to content

Commit

Permalink
[ECS] Apply ecs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafikooo committed Nov 30, 2023
1 parent 3e1bae8 commit 3e391f6
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 43 deletions.
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
4 changes: 2 additions & 2 deletions src/Sylius/Behat/Context/Api/Admin/ManagingOrdersContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,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 @@ -400,7 +400,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
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
5 changes: 0 additions & 5 deletions src/Sylius/Behat/Element/Admin/Promotion/FormElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@

namespace Sylius\Behat\Element\Admin\Promotion;

use Behat\Mink\Element\NodeElement;
use Behat\Mink\Exception\ElementNotFoundException;
use FriendsOfBehat\PageObjectExtension\Element\Element;
use Sylius\Behat\Service\TabsHelper;
use Sylius\Component\Core\Model\ChannelInterface;
use Webmozart\Assert\Assert;

final class FormElement extends Element implements FormElementInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
/** @experimental */
final class PromotionDocumentationModifier implements DocumentationModifierInterface
{
const ROUTE_ADMIN_PROMOTIONS = '/admin/promotions';
const ROUTE_ADMIN_PROMOTION = '/admin/promotions/{code}';
public const ROUTE_ADMIN_PROMOTIONS = '/admin/promotions';

public const ROUTE_ADMIN_PROMOTION = '/admin/promotions/{code}';

/**
* @param string[] $actionTypes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Faker\Factory;
use Faker\Generator;
use Sylius\Bundle\CoreBundle\Fixture\OptionsResolver\LazyOption;
use Sylius\Component\Channel\Model\ChannelInterface;
use Sylius\Component\Channel\Repository\ChannelRepositoryInterface;
use Sylius\Component\Core\Formatter\StringInflector;
use Sylius\Component\Core\Model\PromotionCouponInterface;
Expand Down Expand Up @@ -197,7 +196,7 @@ private static function getCouponNormalizer(?FactoryInterface $couponFactory): \
};
}

/** @return iterable<null|string> */
/** @return iterable<string|null> */
private function getLocales(): iterable
{
if (null === $this->localeRepository) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ final class ChannelCodeCollection extends Constraint
{
/** @var array<Constraint> */
public array $constraints = [];

public bool $allowExtraFields = false;

public bool $allowMissingFields = false;

public ?string $extraFieldsMessage = null;

public ?string $missingFieldsMessage = null;

public function validatedBy(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct(private ChannelRepositoryInterface $channelRepositor
{
}

/** @param null|array<array-key, mixed> $value */
/** @param array<array-key, mixed>|null $value */
public function validate($value, Constraint $constraint): void
{
if (!$constraint instanceof ChannelCodeCollection) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(private CustomerGroupRepositoryInterface $customerGr
{
}

public function validate(mixed$value, Constraint $constraint): void
public function validate(mixed $value, Constraint $constraint): void
{
if (!$constraint instanceof CustomerGroupCodeExists) {
throw new UnexpectedTypeException($constraint, CustomerGroupCodeExists::class);
Expand Down
4 changes: 2 additions & 2 deletions tests/Api/Admin/ProductImagesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public function it_updates_only_the_type_and_variants_of_the_existing_product_im
sprintf('/api/v2/admin/product-variants/%s', $productVariantBlue->getCode()),
sprintf('/api/v2/admin/product-variants/%s', $productVariantRed->getCode()),
],
], JSON_THROW_ON_ERROR),
], \JSON_THROW_ON_ERROR),
);

$this->assertResponse(
Expand Down Expand Up @@ -269,7 +269,7 @@ public function it_prevents_product_image_update_with_unrelated_variant(): void
'productVariants' => [
sprintf('/api/v2/admin/product-variants/%s', $productVariant->getCode()),
],
], JSON_THROW_ON_ERROR),
], \JSON_THROW_ON_ERROR),
);

$this->assertResponse(
Expand Down
34 changes: 17 additions & 17 deletions tests/Api/Admin/PromotionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,25 +116,25 @@ public function it_creates_promotion(): void
[
'type' => CustomerGroupRuleChecker::TYPE,
'configuration' => [
'group_code' => 'vip'
'group_code' => 'vip',
],
],
[
'type' => NthOrderRuleChecker::TYPE,
'configuration' => [
'nth' => 2
'nth' => 2,
],
],
[
'type' => ShippingCountryRuleChecker::TYPE,
'configuration' => [
'country' => 'US'
'country' => 'US',
],
],
[
'type' => HasTaxonRuleChecker::TYPE,
'configuration' => [
'taxons' => ['MUGS', 'CAPS']
'taxons' => ['MUGS', 'CAPS'],
],
],
[
Expand All @@ -147,7 +147,7 @@ public function it_creates_promotion(): void
'MOBILE' => [
'taxon' => 'CAPS',
'amount' => 2000,
]
],
],
],
[
Expand All @@ -164,7 +164,7 @@ public function it_creates_promotion(): void
],
'MOBILE' => [
'amount' => 222,
]
],
],
],
],
Expand Down Expand Up @@ -316,31 +316,31 @@ public function it_does_not_create_a_promotion_with_invalid_rules(): void
[
'type' => CartQuantityRuleChecker::TYPE,
'configuration' => [
'count' => 'invalid'
'count' => 'invalid',
],
],
[
'type' => CustomerGroupRuleChecker::TYPE,
'configuration' => [
'group_code' => 'wrong'
'group_code' => 'wrong',
],
],
[
'type' => NthOrderRuleChecker::TYPE,
'configuration' => [
'nth' => 'invalid'
'nth' => 'invalid',
],
],
[
'type' => ShippingCountryRuleChecker::TYPE,
'configuration' => [
'country' => 'wrong'
'country' => 'wrong',
],
],
[
'type' => HasTaxonRuleChecker::TYPE,
'configuration' => [
'taxons' => ['wrong']
'taxons' => ['wrong'],
],
],
[
Expand All @@ -349,7 +349,7 @@ public function it_does_not_create_a_promotion_with_invalid_rules(): void
'WEB' => [
'taxon' => 'wrong',
'amount' => 'invalid',
]
],
],
],
[
Expand All @@ -362,11 +362,11 @@ public function it_does_not_create_a_promotion_with_invalid_rules(): void
'type' => ItemTotalRuleChecker::TYPE,
'configuration' => [
'MOBILE' => [
]
],
],
],
],
], JSON_THROW_ON_ERROR),
], \JSON_THROW_ON_ERROR),
);

$this->assertResponse(
Expand Down Expand Up @@ -402,7 +402,7 @@ public function it_does_not_create_a_promotion_with_invalid_actions(): void
'type' => UnitFixedDiscountPromotionActionCommand::TYPE,
'configuration' => [
'WEB' => [
'filters' => 'invalid'
'filters' => 'invalid',
],
],
],
Expand All @@ -428,7 +428,7 @@ public function it_does_not_create_a_promotion_with_invalid_actions(): void
],
],
],
], JSON_THROW_ON_ERROR),
], \JSON_THROW_ON_ERROR),
);

$this->assertResponse(
Expand Down Expand Up @@ -511,7 +511,7 @@ public function it_updates_promotion_to_last_priority_when_priority_is_minus_one
server: $header,
content: json_encode([
'priority' => -1,
], JSON_THROW_ON_ERROR),
], \JSON_THROW_ON_ERROR),
);

$this->assertResponse(
Expand Down

0 comments on commit 3e391f6

Please sign in to comment.