states example

$price = $facade->price();
        static::assertEquals(100, $price->getTotal());

        $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
    {
        
static::assertTrue($cart->errors()->has('YOU_SHOULD_REALLY_ADD_PRODUCTS'));
                static::assertTrue($cart->errors()->has('ADD_PRODUCTS_OR_GO_AWAY'));
                static::assertTrue($cart->errors()->has('add-same-message'));
                static::assertTrue($cart->errors()->has('MESSAGE_WITH_PARAMETERS'));
            },
        ];

        yield 'Test cart states' => [
            'cart-state',
            [],
            function DCartFacade $cart): void {
                static::assertTrue($cart->states()->has('my-custom-state'));
                static::assertFalse($cart->states()->has('default-state'));
            },
        ];

        yield 'Discount product price' => [
            'discount-product-price',
            [
                'p1' => new ExpectedPrice(90, 90),
            ],
        ];
    }

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