Skip to content

Commit

Permalink
[CS][DX] Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylius Bot authored May 16, 2022
1 parent cd5ffe1 commit a5a1cb8
Show file tree
Hide file tree
Showing 311 changed files with 764 additions and 1,331 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
use Sylius\Bundle\CoreBundle\CatalogPromotion\Checker\InForProductScopeVariantChecker;
use Sylius\Bundle\CoreBundle\CatalogPromotion\Checker\InForTaxonsScopeVariantChecker;
use Sylius\Bundle\CoreBundle\CatalogPromotion\Checker\InForVariantsScopeVariantChecker;
use Sylius\Component\Core\Formatter\StringInflector;
use Sylius\Component\Core\Model\CatalogPromotionInterface;
use Sylius\Component\Promotion\Event\CatalogPromotionCreated;
use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Core\Model\ProductVariantInterface;
use Sylius\Component\Core\Model\TaxonInterface;
use Sylius\Component\Core\Formatter\StringInflector;
use Sylius\Component\Promotion\Event\CatalogPromotionCreated;
use Symfony\Component\Messenger\MessageBusInterface;
use Webmozart\Assert\Assert;

Expand Down Expand Up @@ -214,7 +214,7 @@ public function iAddActionThatGivesPercentageDiscount(float $amount): void
$actions = [[
'type' => PercentageDiscountPriceCalculator::TYPE,
'configuration' => [
'amount' => $amount
'amount' => $amount,
],
]];

Expand All @@ -230,7 +230,7 @@ public function iAddActionThatGivesFixedDiscount(int $amount, ChannelInterface $
'type' => FixedDiscountPriceCalculator::TYPE,
'configuration' => [
$channel->getCode() => [
'amount' => $amount
'amount' => $amount,
],
],
]];
Expand All @@ -248,7 +248,7 @@ public function iAddAnotherActionThatGivesPercentageDiscount(float $amount): voi
$additionalAction = [[
'type' => PercentageDiscountPriceCalculator::TYPE,
'configuration' => [
'amount' => $amount
'amount' => $amount,
],
]];

Expand Down Expand Up @@ -304,7 +304,7 @@ public function iAddInvalidPercentageDiscountActionWithNonNumberInAmount(): void
$actions = [[
'type' => PercentageDiscountPriceCalculator::TYPE,
'configuration' => [
'amount' => 'text'
'amount' => 'text',
],
]];

Expand All @@ -326,7 +326,7 @@ public function iMakeCatalogPromotionOperateBetweenYesterdayAndTomorrow(): void
{
$this->client->updateRequestData([
'startDate' => (new \DateTime('yesterday'))->format('Y-m-d H:i:s'),
'endDate' => (new \DateTime('tomorrow'))->format('Y-m-d H:i:s')
'endDate' => (new \DateTime('tomorrow'))->format('Y-m-d H:i:s'),
]);
}

Expand Down Expand Up @@ -366,7 +366,7 @@ public function iAddScopeThatAppliesOnVariants(ProductVariantInterface $firstVar
'variants' => [
$firstVariant->getCode(),
$secondVariant->getCode(),
]
],
],
]];

Expand Down Expand Up @@ -397,7 +397,7 @@ public function iAddCatalogPromotionScopeForTaxonWithNonexistentTaxons(): void
'taxons' => [
'BAD_TAXON',
'EVEN_WORSE_TAXON',
]
],
],
]];

Expand Down Expand Up @@ -428,7 +428,7 @@ public function iAddCatalogPromotionScopeForProductsWithNonexistentProducts(): v
'products' => [
'BAD_PRODUCT',
'EVEN_WORSE_PRODUCT',
]
],
],
]];

Expand All @@ -443,7 +443,7 @@ public function iAddScopeThatAppliesOnTaxon(TaxonInterface $taxon): void
$scopes = [[
'type' => InForTaxonsScopeVariantChecker::TYPE,
'configuration' => [
'taxons' => [$taxon->getCode()]
'taxons' => [$taxon->getCode()],
],
]];

Expand All @@ -458,7 +458,7 @@ public function iAddScopeThatAppliesOnProduct(ProductInterface $product): void
$scopes = [[
'type' => InForProductScopeVariantChecker::TYPE,
'configuration' => [
'products' => [$product->getCode()]
'products' => [$product->getCode()],
],
]];

Expand Down Expand Up @@ -514,7 +514,7 @@ public function iEditCatalogPromotionToBeAppliedOnVariant(
'configuration' => [
'variants' => [
$productVariant->getCode(),
]
],
],
]];

Expand All @@ -536,7 +536,7 @@ public function iEditCatalogPromotionToBeAppliedOnTaxon(
$content['scopes'][0]['type'] = InForTaxonsScopeVariantChecker::TYPE;
$content['scopes'][0]['configuration']['taxons'] = [$taxon->getCode()];

$this->client->setRequestData($content);;
$this->client->setRequestData($content);

$this->client->update();
}
Expand All @@ -555,7 +555,7 @@ public function iEditCatalogPromotionToBeAppliedOnProduct(
$content['scopes'][0]['type'] = InForProductScopeVariantChecker::TYPE;
$content['scopes'][0]['configuration']['products'] = [$product->getCode()];

$this->client->setRequestData($content);;
$this->client->setRequestData($content);

$this->client->update();
}
Expand Down Expand Up @@ -668,7 +668,7 @@ public function iAddCatalogPromotionScopeWithNonexistentType(): void
$scopes = [[
'type' => 'nonexistent_scope',
'configuration' => [
'config' => 'config'
'config' => 'config',
],
]];

Expand Down Expand Up @@ -980,7 +980,9 @@ public function theCatalogPromotionNamedShouldOperateBetweenDates(
),
sprintf(
'Cannot find catalog promotions with name "%s" operating between "%s" and "%s" in the list',
$catalogPromotion->getName(), $startDate, $endDate
$catalogPromotion->getName(),
$startDate,
$endDate
)
);
}
Expand All @@ -1001,7 +1003,8 @@ public function theCatalogPromotionNamedShouldHavePriority(
),
sprintf(
'Cannot find catalog promotions with name "%s" and priority "%s" in the list',
$catalogPromotion->getName(), $priority
$catalogPromotion->getName(),
$priority
)
);
}
Expand All @@ -1020,12 +1023,14 @@ public function theCatalogPromotionsNamedShouldOperateBetweenYesterdayAndTomorro
[
'name' => $catalogPromotion->getName(),
'startDate' => (new \DateTime('yesterday'))->format('Y-m-d H:i:s'),
'endDate' => (new \DateTime('tomorrow'))->format('Y-m-d H:i:s')
'endDate' => (new \DateTime('tomorrow'))->format('Y-m-d H:i:s'),
]
),
sprintf(
'Cannot find catalog promotions with name "%s" operating between "%s" and "%s" in the list',
$catalogPromotion->getName(), (new \DateTime('yesterday'))->format('Y-m-d H:i:s'), (new \DateTime('tomorrow'))->format('Y-m-d H:i:s')
$catalogPromotion->getName(),
(new \DateTime('yesterday'))->format('Y-m-d H:i:s'),
(new \DateTime('tomorrow'))->format('Y-m-d H:i:s')
)
);
}
Expand Down Expand Up @@ -1589,18 +1594,18 @@ private function createCatalogPromotion(
'exclusive' => $exclusive,
'translations' => ['en_US' => [
'locale' => 'en_US',
'label' => $name
'label' => $name,
]],
'actions' => [[
'type' => PercentageDiscountPriceCalculator::TYPE,
'configuration' => [
'amount' => $discount
'amount' => $discount,
],
]],
'scopes' => [[
'type' => InForProductScopeVariantChecker::TYPE,
'configuration' => [
'products' => [$product->getCode()]
'products' => [$product->getCode()],
],
]],
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ public function iShouldBeNotifiedThatItHasBeenSuccessfullyDeleted(): void
{
Assert::true(
$this->responseChecker->isDeletionSuccessful(
$this->client->getLastResponse()
),
$this->client->getLastResponse()
),
'Customer group could not be deleted'
);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Sylius/Behat/Context/Api/Admin/ManagingOrdersContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ public function iShouldSeeASingleOrderFromCustomer(CustomerInterface $customer):
{
Assert::true(
$this->responseChecker->hasItemWithValue(
$this->client->getLastResponse(),
'customer',
$this->iriConverter->getIriFromItem($customer)
),
$this->client->getLastResponse(),
'customer',
$this->iriConverter->getIriFromItem($customer)
),
sprintf('There is no order for customer %s', $customer->getEmail())
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ public function iShouldBeNotifiedThatItHasBeenSuccessfullyDeleted(): void
{
Assert::true(
$this->responseChecker->isDeletionSuccessful(
$this->client->getLastResponse()
),
$this->client->getLastResponse()
),
'Product association type could not be deleted'
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public function iSetItsPriceToForChannel(int $price, ChannelInterface $channel):
$this->client->addRequestData('channelPricings', [
$channel->getCode() => [
'price' => $price,
'channelCode' => $channel->getCode()
]
'channelCode' => $channel->getCode(),
],
]);
}

Expand Down Expand Up @@ -203,8 +203,8 @@ private function createNewVariantWithPrice(
$this->client->addRequestData('channelPricings', [
$channel->getCode() => [
'price' => $price,
'channelCode' => $channel->getCode()
]
'channelCode' => $channel->getCode(),
],
]);

$this->client->create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use Sylius\Behat\Client\ResponseCheckerInterface;
use Sylius\Behat\Service\SharedStorageInterface;
use Sylius\Component\Core\Model\AdminUserInterface;
use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Core\Model\TaxonInterface;
use Sylius\Component\Product\Model\ProductOption;
Expand Down
4 changes: 2 additions & 2 deletions src/Sylius/Behat/Context/Api/Admin/ManagingZonesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,8 @@ public function iShouldBeNotifiedThatItHasBeenSuccessfullyDeleted(): void
{
Assert::true(
$this->responseChecker->isDeletionSuccessful(
$this->client->getLastResponse()
),
$this->client->getLastResponse()
),
'Zone could not be deleted'
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Sylius/Behat/Context/Api/Shop/AddressContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,9 @@ public function iShouldBeNotifiedThatTheProvinceNeedsToBeSpecified(): void
{
Assert::true(
$this->responseChecker->hasViolationWithMessage(
$this->addressClient->getLastResponse(),
'Please select proper province.'
)
$this->addressClient->getLastResponse(),
'Please select proper province.'
)
);
}

Expand Down
1 change: 0 additions & 1 deletion src/Sylius/Behat/Context/Api/Shop/CartContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,6 @@ private function checkProductQuantityByAdmin(Response $cartResponse, string $pro

return;
}

}

throw new \InvalidArgumentException('Invalid item data');
Expand Down
6 changes: 3 additions & 3 deletions src/Sylius/Behat/Context/Api/Shop/ChannelContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ public function iShouldShopUsingTheCurrency(string $currencyCode): void
{
Assert::same(
$this->responseChecker->getValue(
$this->client->getLastResponse(),
'baseCurrency'
)['code'],
$this->client->getLastResponse(),
'baseCurrency'
)['code'],
$currencyCode
);
}
Expand Down
2 changes: 0 additions & 2 deletions src/Sylius/Behat/Context/Api/Shop/CurrencyContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\ResponseCheckerInterface;
use Sylius\Component\Currency\Model\CurrencyInterface;
use Webmozart\Assert\Assert;

final class CurrencyContext implements Context
{
Expand Down
2 changes: 1 addition & 1 deletion src/Sylius/Behat/Context/Api/Shop/HomepageContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function iShouldSeeAndInTheMenu(string ...$expectedMenuItems): void
{
$response = json_decode($this->taxonsClient->getLastResponse()->getContent(), true);
Assert::keyExists($response, 'hydra:member');
$menuItems = array_column($response['hydra:member'], 'name');
$menuItems = array_column($response['hydra:member'], 'name');

Assert::notEmpty($menuItems);
Assert::allOneOf($menuItems, $expectedMenuItems);
Expand Down
2 changes: 1 addition & 1 deletion src/Sylius/Behat/Context/Api/Shop/LocaleContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct(ApiClientInterface $client, ResponseCheckerInterface
*/
public function iGetAvailableLocales(): void
{
$this->client->index();
$this->client->index();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Sylius/Behat/Context/Api/Shop/LoginContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

namespace Sylius\Behat\Context\Api\Shop;

use Sylius\Behat\Client\RequestInterface;
use ApiPlatform\Core\Api\IriConverterInterface;
use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\ApiSecurityClientInterface;
use Sylius\Behat\Client\Request;
use Sylius\Behat\Client\RequestInterface;
use Sylius\Behat\Client\ResponseCheckerInterface;
use Sylius\Behat\Service\SharedStorageInterface;
use Sylius\Component\Core\Model\CustomerInterface;
Expand Down
1 change: 0 additions & 1 deletion src/Sylius/Behat/Context/Api/Shop/ProductContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

final class ProductContext implements Context
{

public function __construct(
private ApiClientInterface $client,
private ApiClientInterface $productVariantClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\ResponseCheckerInterface;
use Sylius\Behat\Service\SharedStorageInterface;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Core\Model\ProductVariantInterface;
use Webmozart\Assert\Assert;

Expand Down
2 changes: 0 additions & 2 deletions src/Sylius/Behat/Context/Api/Shop/PromotionContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@

use Behat\Behat\Context\Context;
use Sylius\Behat\Client\ApiClientInterface;
use Sylius\Behat\Client\Request;
use Sylius\Behat\Client\ResponseCheckerInterface;
use Sylius\Behat\Service\SharedStorageInterface;
use Symfony\Component\HttpFoundation\Request as HttpRequest;
use Webmozart\Assert\Assert;

final class PromotionContext implements Context
Expand Down
Loading

0 comments on commit a5a1cb8

Please sign in to comment.