mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
minor #13953 [API] This same cart promotion discount in different channels (Rafikooo)
This PR was merged into the 1.12-dev branch. Discussion ---------- | Q | A | |-----------------|--------------------------------------------------------------| | Branch? | master <!-- see the comment below --> | | Bug fix? | no | | New feature? | no | | BC breaks? | no | | Deprecations? | no <!-- don't forget to update the UPGRADE-*.md file --> | | License | MIT | <!-- - Bug fixes must be submitted against the 1.10 or 1.11 branch(the lowest possible) - Features and deprecations must be submitted against the master branch - Make sure that the correct base branch is set To be sure you are not breaking any Backward Compatibilities, check the documentation: https://docs.sylius.com/en/latest/book/organization/backward-compatibility-promise.html --> API scenarios covered and some code maintenance Commits -------830f06d672[API] Receiving fixed discount dependent on channel on cart82996b9b29[Maintenance] Up-to-date yarn.lock, constructor property promotion in some behat classes
This commit is contained in:
commit
72c58e0888
7 changed files with 169 additions and 777 deletions
|
|
@ -5,21 +5,21 @@ Feature: Receiving fixed discount dependent on channel on cart
|
|||
I want to have promotions applied to my cart
|
||||
|
||||
Background:
|
||||
Given the store operates on a channel named "Web-US" in "USD" currency
|
||||
And the store operates on another channel named "Web-GB" in "GBP" currency
|
||||
Given the store operates on a channel named "Web-US" in "USD" currency and with hostname "united.states"
|
||||
And the store operates on another channel named "Web-GB" in "GBP" currency and with hostname "great.britain"
|
||||
And the store has a product "PHP T-Shirt" priced at "$100.00" in "Web-US" channel
|
||||
And this product is also priced at "£80.00" in "Web-GB" channel
|
||||
And there is a promotion "Holiday promotion"
|
||||
And this promotion gives "$10.00" discount to every order in the "Web-US" channel and "£12.00" discount to every order in the "Web-GB" channel
|
||||
|
||||
@ui
|
||||
@api @ui
|
||||
Scenario: Receiving fixed discount in proper currency for channel
|
||||
When I change my current channel to "Web-US"
|
||||
And I add product "PHP T-Shirt" to the cart
|
||||
Then my cart total should be "$90.00"
|
||||
And my discount should be "-$10.00"
|
||||
|
||||
@ui
|
||||
@api @ui
|
||||
Scenario: Receiving fixed discount in proper currency after channel change
|
||||
When I change my current channel to "Web-GB"
|
||||
And I add product "PHP T-Shirt" to the cart
|
||||
|
|
|
|||
|
|
@ -47,55 +47,22 @@ final class CheckoutContext implements Context
|
|||
'payment' => OrderCheckoutStates::STATE_PAYMENT_SELECTED,
|
||||
];
|
||||
|
||||
private ApiClientInterface $client;
|
||||
|
||||
private ResponseCheckerInterface $responseChecker;
|
||||
|
||||
private RepositoryInterface $shippingMethodRepository;
|
||||
|
||||
private OrderRepositoryInterface $orderRepository;
|
||||
|
||||
private RepositoryInterface $paymentMethodRepository;
|
||||
|
||||
private ProductVariantResolverInterface $productVariantResolver;
|
||||
|
||||
private IriConverterInterface $iriConverter;
|
||||
|
||||
private SharedStorageInterface $sharedStorage;
|
||||
|
||||
private RequestFactoryInterface $requestFactory;
|
||||
|
||||
/** @var string[] */
|
||||
private array $content = [];
|
||||
|
||||
private string $paymentMethodClass;
|
||||
|
||||
private string $shippingMethodClass;
|
||||
|
||||
public function __construct(
|
||||
ApiClientInterface $client,
|
||||
ResponseCheckerInterface $responseChecker,
|
||||
RepositoryInterface $shippingMethodRepository,
|
||||
OrderRepositoryInterface $orderRepository,
|
||||
RepositoryInterface $paymentMethodRepository,
|
||||
ProductVariantResolverInterface $productVariantResolver,
|
||||
IriConverterInterface $iriConverter,
|
||||
SharedStorageInterface $sharedStorage,
|
||||
RequestFactoryInterface $requestFactory,
|
||||
string $paymentMethodClass,
|
||||
string $shippingMethodClass
|
||||
private ApiClientInterface $client,
|
||||
private ResponseCheckerInterface $responseChecker,
|
||||
private RepositoryInterface $shippingMethodRepository,
|
||||
private OrderRepositoryInterface $orderRepository,
|
||||
private RepositoryInterface $paymentMethodRepository,
|
||||
private ProductVariantResolverInterface $productVariantResolver,
|
||||
private IriConverterInterface $iriConverter,
|
||||
private SharedStorageInterface $sharedStorage,
|
||||
private RequestFactoryInterface $requestFactory,
|
||||
private string $paymentMethodClass,
|
||||
private string $shippingMethodClass
|
||||
) {
|
||||
$this->client = $client;
|
||||
$this->responseChecker = $responseChecker;
|
||||
$this->shippingMethodRepository = $shippingMethodRepository;
|
||||
$this->orderRepository = $orderRepository;
|
||||
$this->paymentMethodRepository = $paymentMethodRepository;
|
||||
$this->productVariantResolver = $productVariantResolver;
|
||||
$this->iriConverter = $iriConverter;
|
||||
$this->sharedStorage = $sharedStorage;
|
||||
$this->requestFactory = $requestFactory;
|
||||
$this->paymentMethodClass = $paymentMethodClass;
|
||||
$this->shippingMethodClass = $shippingMethodClass;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -28,32 +28,14 @@ use Sylius\Component\Core\Test\Services\DefaultChannelFactoryInterface;
|
|||
|
||||
final class ChannelContext implements Context
|
||||
{
|
||||
private SharedStorageInterface $sharedStorage;
|
||||
|
||||
private ChannelContextSetterInterface $channelContextSetter;
|
||||
|
||||
private DefaultChannelFactoryInterface $unitedStatesChannelFactory;
|
||||
|
||||
private DefaultChannelFactoryInterface $defaultChannelFactory;
|
||||
|
||||
private ChannelRepositoryInterface $channelRepository;
|
||||
|
||||
private ObjectManager $channelManager;
|
||||
|
||||
public function __construct(
|
||||
SharedStorageInterface $sharedStorage,
|
||||
ChannelContextSetterInterface $channelContextSetter,
|
||||
DefaultChannelFactoryInterface $unitedStatesChannelFactory,
|
||||
DefaultChannelFactoryInterface $defaultChannelFactory,
|
||||
ChannelRepositoryInterface $channelRepository,
|
||||
ObjectManager $channelManager
|
||||
private SharedStorageInterface $sharedStorage,
|
||||
private ChannelContextSetterInterface $channelContextSetter,
|
||||
private DefaultChannelFactoryInterface $unitedStatesChannelFactory,
|
||||
private DefaultChannelFactoryInterface $defaultChannelFactory,
|
||||
private ChannelRepositoryInterface $channelRepository,
|
||||
private ObjectManager $channelManager
|
||||
) {
|
||||
$this->sharedStorage = $sharedStorage;
|
||||
$this->channelContextSetter = $channelContextSetter;
|
||||
$this->unitedStatesChannelFactory = $unitedStatesChannelFactory;
|
||||
$this->defaultChannelFactory = $defaultChannelFactory;
|
||||
$this->channelRepository = $channelRepository;
|
||||
$this->channelManager = $channelManager;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -43,55 +43,25 @@ use Webmozart\Assert\Assert;
|
|||
|
||||
final class ProductContext implements Context
|
||||
{
|
||||
private SharedStorageInterface $sharedStorage;
|
||||
|
||||
private ProductRepositoryInterface $productRepository;
|
||||
|
||||
private ProductFactoryInterface $productFactory;
|
||||
|
||||
private FactoryInterface $productTranslationFactory;
|
||||
|
||||
private FactoryInterface $productVariantFactory;
|
||||
|
||||
private FactoryInterface $productVariantTranslationFactory;
|
||||
|
||||
private FactoryInterface $channelPricingFactory;
|
||||
|
||||
private FactoryInterface $productOptionFactory;
|
||||
|
||||
private FactoryInterface $productOptionValueFactory;
|
||||
|
||||
private FactoryInterface $productImageFactory;
|
||||
|
||||
private ObjectManager $objectManager;
|
||||
|
||||
private ProductVariantGeneratorInterface $productVariantGenerator;
|
||||
|
||||
private ProductVariantResolverInterface $defaultVariantResolver;
|
||||
|
||||
private ImageUploaderInterface $imageUploader;
|
||||
|
||||
private SlugGeneratorInterface $slugGenerator;
|
||||
|
||||
/** @var array */
|
||||
private $minkParameters;
|
||||
|
||||
public function __construct(
|
||||
SharedStorageInterface $sharedStorage,
|
||||
ProductRepositoryInterface $productRepository,
|
||||
ProductFactoryInterface $productFactory,
|
||||
FactoryInterface $productTranslationFactory,
|
||||
FactoryInterface $productVariantFactory,
|
||||
FactoryInterface $productVariantTranslationFactory,
|
||||
FactoryInterface $channelPricingFactory,
|
||||
FactoryInterface $productOptionFactory,
|
||||
FactoryInterface $productOptionValueFactory,
|
||||
FactoryInterface $productImageFactory,
|
||||
ObjectManager $objectManager,
|
||||
ProductVariantGeneratorInterface $productVariantGenerator,
|
||||
ProductVariantResolverInterface $defaultVariantResolver,
|
||||
ImageUploaderInterface $imageUploader,
|
||||
SlugGeneratorInterface $slugGenerator,
|
||||
private SharedStorageInterface $sharedStorage,
|
||||
private ProductRepositoryInterface $productRepository,
|
||||
private ProductFactoryInterface $productFactory,
|
||||
private FactoryInterface $productTranslationFactory,
|
||||
private FactoryInterface $productVariantFactory,
|
||||
private FactoryInterface $productVariantTranslationFactory,
|
||||
private FactoryInterface $channelPricingFactory,
|
||||
private FactoryInterface $productOptionFactory,
|
||||
private FactoryInterface $productOptionValueFactory,
|
||||
private FactoryInterface $productImageFactory,
|
||||
private ObjectManager $objectManager,
|
||||
private ProductVariantGeneratorInterface $productVariantGenerator,
|
||||
private ProductVariantResolverInterface $defaultVariantResolver,
|
||||
private ImageUploaderInterface $imageUploader,
|
||||
private SlugGeneratorInterface $slugGenerator,
|
||||
$minkParameters
|
||||
) {
|
||||
if (!is_array($minkParameters) && !$minkParameters instanceof \ArrayAccess) {
|
||||
|
|
@ -102,21 +72,6 @@ final class ProductContext implements Context
|
|||
));
|
||||
}
|
||||
|
||||
$this->sharedStorage = $sharedStorage;
|
||||
$this->productRepository = $productRepository;
|
||||
$this->productFactory = $productFactory;
|
||||
$this->productTranslationFactory = $productTranslationFactory;
|
||||
$this->productVariantFactory = $productVariantFactory;
|
||||
$this->productVariantTranslationFactory = $productVariantTranslationFactory;
|
||||
$this->channelPricingFactory = $channelPricingFactory;
|
||||
$this->productOptionFactory = $productOptionFactory;
|
||||
$this->productOptionValueFactory = $productOptionValueFactory;
|
||||
$this->productImageFactory = $productImageFactory;
|
||||
$this->objectManager = $objectManager;
|
||||
$this->productVariantGenerator = $productVariantGenerator;
|
||||
$this->defaultVariantResolver = $defaultVariantResolver;
|
||||
$this->imageUploader = $imageUploader;
|
||||
$this->slugGenerator = $slugGenerator;
|
||||
$this->minkParameters = $minkParameters;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,40 +35,16 @@ use Sylius\Component\Promotion\Repository\PromotionRepositoryInterface;
|
|||
|
||||
final class PromotionContext implements Context
|
||||
{
|
||||
private SharedStorageInterface $sharedStorage;
|
||||
|
||||
private PromotionActionFactoryInterface $actionFactory;
|
||||
|
||||
private PromotionCouponFactoryInterface $couponFactory;
|
||||
|
||||
private PromotionRuleFactoryInterface $ruleFactory;
|
||||
|
||||
private TestPromotionFactoryInterface $testPromotionFactory;
|
||||
|
||||
private PromotionRepositoryInterface $promotionRepository;
|
||||
|
||||
private PromotionCouponGeneratorInterface $couponGenerator;
|
||||
|
||||
private ObjectManager $objectManager;
|
||||
|
||||
public function __construct(
|
||||
SharedStorageInterface $sharedStorage,
|
||||
PromotionActionFactoryInterface $actionFactory,
|
||||
PromotionCouponFactoryInterface $couponFactory,
|
||||
PromotionRuleFactoryInterface $ruleFactory,
|
||||
TestPromotionFactoryInterface $testPromotionFactory,
|
||||
PromotionRepositoryInterface $promotionRepository,
|
||||
PromotionCouponGeneratorInterface $couponGenerator,
|
||||
ObjectManager $objectManager
|
||||
private SharedStorageInterface $sharedStorage,
|
||||
private PromotionActionFactoryInterface $actionFactory,
|
||||
private PromotionCouponFactoryInterface $couponFactory,
|
||||
private PromotionRuleFactoryInterface $ruleFactory,
|
||||
private TestPromotionFactoryInterface $testPromotionFactory,
|
||||
private PromotionRepositoryInterface $promotionRepository,
|
||||
private PromotionCouponGeneratorInterface $couponGenerator,
|
||||
private ObjectManager $objectManager
|
||||
) {
|
||||
$this->sharedStorage = $sharedStorage;
|
||||
$this->actionFactory = $actionFactory;
|
||||
$this->couponFactory = $couponFactory;
|
||||
$this->ruleFactory = $ruleFactory;
|
||||
$this->testPromotionFactory = $testPromotionFactory;
|
||||
$this->promotionRepository = $promotionRepository;
|
||||
$this->couponGenerator = $couponGenerator;
|
||||
$this->objectManager = $objectManager;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -27,28 +27,13 @@ use Webmozart\Assert\Assert;
|
|||
|
||||
final class CartContext implements Context
|
||||
{
|
||||
private SharedStorageInterface $sharedStorage;
|
||||
|
||||
private SummaryPageInterface $summaryPage;
|
||||
|
||||
private ShowPageInterface $productShowPage;
|
||||
|
||||
private NotificationCheckerInterface $notificationChecker;
|
||||
|
||||
private SessionManagerInterface $sessionManager;
|
||||
|
||||
public function __construct(
|
||||
SharedStorageInterface $sharedStorage,
|
||||
SummaryPageInterface $summaryPage,
|
||||
ShowPageInterface $productShowPage,
|
||||
NotificationCheckerInterface $notificationChecker,
|
||||
SessionManagerInterface $sessionManager
|
||||
private SharedStorageInterface $sharedStorage,
|
||||
private SummaryPageInterface $summaryPage,
|
||||
private ShowPageInterface $productShowPage,
|
||||
private NotificationCheckerInterface $notificationChecker,
|
||||
private SessionManagerInterface $sessionManager
|
||||
) {
|
||||
$this->sharedStorage = $sharedStorage;
|
||||
$this->summaryPage = $summaryPage;
|
||||
$this->productShowPage = $productShowPage;
|
||||
$this->notificationChecker = $notificationChecker;
|
||||
$this->sessionManager = $sessionManager;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue