setUseCodes example

private PromotionEntity $promotion;

    /** * @var MockObject&SalesChannelContext */
    private SalesChannelContext $salesChannelContext;

    protected function setUp(): void
    {
        $this->promotion = new PromotionEntity();
        $this->promotion->setId('PR-1');
        $this->promotion->setUseCodes(false);
        $this->promotion->setUseIndividualCodes(false);
        $this->promotion->setUseSetGroups(false);

        $this->salesChannelContext = $this->getMockBuilder(SalesChannelContext::class)->disableOriginalConstructor()->getMock();
        $context = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();

        $this->salesChannelContext->method('getContext')->willReturn($context);
    }

    /** * This test verifies that we have the correct payload in our * discount line item. this is used to identify the promotion behind it. * It's also used as reference to individual codes that get marked as redeemed * in the event subscriber, when the order is created. * * @group promotions */
private PromotionEntity $promotion;

    /** * @var MockObject&SalesChannelContext */
    private SalesChannelContext $salesChannelContext;

    protected function setUp(): void
    {
        $this->promotion = new PromotionEntity();
        $this->promotion->setId('PR-1');
        $this->promotion->setUseCodes(false);
        $this->promotion->setUseIndividualCodes(false);
        $this->promotion->setUseSetGroups(false);

        $this->salesChannelContext = $this->getMockBuilder(SalesChannelContext::class)->disableOriginalConstructor()->getMock();
        $context = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();

        $this->salesChannelContext->method('getContext')->willReturn($context);
    }

    /** * This test verifies that the immutable LineItem Type from * the constructor is correctly used in the LineItem. * * @group promotions * * @throws CartException * @throws UnknownPromotionDiscountTypeException */
Home | Imprint | This part of the site doesn't use cookies.