StatesFacade example

/** * @internal * * @covers \Shopware\Core\Checkout\Cart\Facade\StatesFacade */
class StatesFacadeTest extends TestCase
{
    public function testPublicApi(): void
    {
        $cart = new Cart('test');

        $facade = new StatesFacade($cart);
        static::assertFalse($facade->has('foo'));

        $facade->add('foo');
        static::assertTrue($facade->has('foo'));
        static::assertEquals(['foo']$facade->get());

        $facade->remove('foo');
        static::assertFalse($facade->has('foo'));
    }
}

        return new ErrorsFacade($this->cart->getErrors());
    }

    /** * `states()` allows you to access the state functions of the current cart. * * @return StatesFacade A `StatesFacade` containing all cart states as a collection (maybe an empty collection if there are no states) */
    public function states(): StatesFacade
    {
        return new StatesFacade($this->cart);
    }

    private function getItems(): LineItemCollection
    {
        return $this->cart->getLineItems();
    }
}
Home | Imprint | This part of the site doesn't use cookies.