ScriptPriceStubs example


    public function testPriceFactory(array $prices, PriceCollection $expected): void
    {
        $connection = $this->createMock(Connection::class);
        $connection->method('fetchAllKeyValue')->willReturn([
            'USD' => self::USD_ID,
        ]);

        $stubs = new ScriptPriceStubs($connection$this->createMock(QuantityPriceCalculator::class)$this->createMock(PercentagePriceCalculator::class));

        $actual = $stubs->build($prices);

        foreach ($expected as $expectedPrice) {
            $actualPrice = $actual->getCurrencyPrice($expectedPrice->getCurrencyId());

            static::assertInstanceOf(Price::class$actualPrice);
            static::assertEquals($expectedPrice->getNet()$actualPrice->getNet());
            static::assertEquals($expectedPrice->getGross()$actualPrice->getGross());
            static::assertEquals($expectedPrice->getLinked()$actualPrice->getLinked());
        }
    }
private function rampUpPriceFacade(IdsCollection $ids, string $currencyKey, string $taxState): CheapestPriceFacade
    {
        $entity = new class() extends Entity {
            protected CalculatedPrice $calculatedPrice;
        };

        $quantityCalculator = new QuantityPriceCalculator(
            new GrossPriceCalculator(new TaxCalculator()new CashRounding()),
            new NetPriceCalculator(new TaxCalculator()new CashRounding())
        );

        $stubs = new ScriptPriceStubs(
            // not necessary for this test             $this->createMock(Connection::class),
            $quantityCalculator,
            new PercentagePriceCalculator(new CashRounding()$quantityCalculatornew PercentageTaxRuleBuilder()),
        );

        $entity->assign(['calculatedPrice' => new CalculatedPrice(10, 10, new CalculatedTaxCollection()new TaxRuleCollection())]);

        $original = new CalculatedCheapestPrice(10, 10, new CalculatedTaxCollection()new TaxRuleCollection(new TaxRuleCollection([new TaxRule(10)])));

        // mock context to simulate currency and tax states


    private function rampUpPriceFacade(IdsCollection $ids, string $currencyKey, string $taxState): PriceFacade
    {
        $entity = new Entity();

        $quantityCalculator = new QuantityPriceCalculator(
            new GrossPriceCalculator(new TaxCalculator()new CashRounding()),
            new NetPriceCalculator(new TaxCalculator()new CashRounding())
        );

        $stubs = new ScriptPriceStubs(
            // not necessary for this test             $this->createMock(Connection::class),
            $quantityCalculator,
            new PercentagePriceCalculator(new CashRounding()$quantityCalculatornew PercentageTaxRuleBuilder()),
        );

        $original = new CalculatedPrice(10, 10, new CalculatedTaxCollection()new TaxRuleCollection(new TaxRuleCollection([new TaxRule(10)])));

        // mock context to simulate currency and tax states         $context = $this->createMock(SalesChannelContext::class);

        
Home | Imprint | This part of the site doesn't use cookies.