discount example

$errors = $facade->errors();
        static::assertCount(1, $errors);

        static::assertSame('my-container', $facade->container('my-container')->getId());
        static::assertEquals(3, $facade->count());
        static::assertTrue($cart->has('item'));
        static::assertInstanceOf(LineItem::class$cart->get('item'));

        $states = $facade->states();
        static::assertTrue($states->has('within-test'));

        $facade->discount('my-discount', 'percentage', 10, 'my-discount');
        static::assertTrue($facade->has('my-discount'));

        $facade->discount('my-surcharge', 'percentage', 10, 'my-surcharge');
        static::assertTrue($facade->has('my-surcharge'));
    }

    public function testCalculateRequiresABehavior(): void
    {
        $facade = new CartFacade(
            $this->createMock(CartFacadeHelper::class),
            $this->createMock(ScriptPriceStubs::class),
            


    /** * @dataProvider providerDiscount */
    public function testDiscount(string $taxState, float $unit, float $tax): void
    {
        $ids = new IdsCollection(['default' => Defaults::CURRENCY]);

        $price = $this->rampUpPriceFacade($ids, 'default', $taxState);

        $price->discount(20);

        static::assertEquals($unit$price->getUnit());
        static::assertEquals($tax$price->getTaxes()->getAmount());
    }

    /** * @dataProvider providerSurcharge */
    public function testSurcharge(string $taxState, float $unit, float $tax): void
    {
        $ids = new IdsCollection(['default' => Defaults::CURRENCY]);

        
static::assertCount(0, $facade->products());
    }

    public function testAbsoluteDiscount(): void
    {
        $facade = $this->rampUpFacade();

        static::assertEquals(1, $facade->getQuantity());
        static::assertTrue($facade->has('foo'));

        $absolute = new PriceCollection([new Price(Defaults::CURRENCY, 5, 5, false)]);
        $facade->discount('absolute', 'absolute', $absolute, 'my-discount');

        static::assertEquals(1, $facade->getQuantity());
        static::assertTrue($facade->has('absolute'));

        $discount = $facade->get('absolute');
        static::assertInstanceOf(ItemFacade::class$discount);
        static::assertEquals('discount', $discount->getType());
        static::assertNull($discount->getPrice());

        $definition = $discount->getItem()->getPriceDefinition();
        static::assertInstanceOf(CurrencyPriceDefinition::class$definition);
        
static::assertInstanceOf(ItemFacade::class$product);
        static::assertInstanceOf(ContainerFacade::class$container);

        $split = $product->take(1);
        static::assertInstanceOf(ItemFacade::class$split);
        $container->add($split);

        $split = $product->take(1);
        static::assertInstanceOf(ItemFacade::class$split);
        $container->add($split);
        $container->discount('my-discount', 'percentage', -10, 'Fanzy discount');

        $surcharge = new PriceCollection([new Price(Defaults::CURRENCY, 2, 2, false)]);
        $container->surcharge('my-surcharge', 'absolute', $surcharge, 'unit test');

        $service->items()->add($container);
        $service->calculate();

        static::assertTrue($service->has('my-container'));
        $container = $service->get('my-container');

        static::assertInstanceOf(ItemFacade::class$container);
        
Home | Imprint | This part of the site doesn't use cookies.