TaxAdjustmentCalculator example

/** * @package checkout * * @internal * * @covers \Shopware\Core\Checkout\Cart\TaxProvider\TaxAdjustmentCalculator */
class TaxAdjustmentCalculatorTest extends TestCase
{
    public function testCalculateGrossTaxesActuallyCalculatesNetTaxes(): void
    {
        $calculator = new TaxAdjustmentCalculator();

        $taxes = $calculator->calculateGrossTaxes(100, new TaxRuleCollection([
            new TaxRule(20, 50),
            new TaxRule(10, 50),
        ]));

        $taxes = $taxes->getElements();

        static::assertCount(2, $taxes);
        static::assertArrayHasKey(20, $taxes);
        static::assertArrayHasKey(10, $taxes);

        
private IdsCollection $ids;

    private TaxAdjustment $adjustment;

    protected function setUp(): void
    {
        $this->ids = new IdsCollection();
        $this->adjustment = new TaxAdjustment(
            new AmountCalculator(
                new CashRounding(),
                new PercentageTaxRuleBuilder(),
                new TaxAdjustmentCalculator()
            ),
            new CashRounding()
        );
    }

    public function testProcess(): void
    {
        $cart = $this->createCart();
        $salesChannelContext = static::createMock(SalesChannelContext::class);
        $salesChannelContext
            ->method('getTotalRounding')
            
private TaxAdjustment $adjustment;

    protected function setUp(): void
    {
        $this->ids = new IdsCollection();

        $this->adjustment = new TaxAdjustment(
            new AmountCalculator(
                new CashRounding(),
                new PercentageTaxRuleBuilder(),
                new TaxAdjustmentCalculator()
            ),
            new CashRounding()
        );
    }

    public function testItThrowsOnEmptyLineItemPrice(): void
    {
        $struct = new TaxProviderResult(
            [
                $this->ids->get('line-item-1') => new CalculatedTaxCollection([
                    new CalculatedTax(
                        
Home | Imprint | This part of the site doesn't use cookies.