ErrorsFacade example

use Shopware\Core\Checkout\Cart\Facade\ErrorsFacade;

/** * @internal * * @covers \Shopware\Core\Checkout\Cart\Facade\ErrorsFacade */
class ErrorsFacadeTest extends TestCase
{
    public function testPublicApiAvailable(): void
    {
        $facade = new ErrorsFacade(new ErrorCollection());

        $facade->warning('warning');
        $facade->error('error');
        $facade->notice('notice');

        static::assertCount(3, $facade);
        static::assertTrue($facade->has('warning'));
        static::assertTrue($facade->has('error'));
        static::assertTrue($facade->has('notice'));

        $facade->warning('duplicate');
        
return new CartPriceFacade($this->cart->getPrice()$this->priceStubs);
    }

    /** * The `errors()` method returns the current errors of the cart. * You can use it to add new errors or warning or to remove existing ones. * * @return ErrorsFacade A `ErrorsFacade` containing all cart errors as a collection (may be an empty collection if there are no errors) */
    public function errors(): ErrorsFacade
    {
        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);
    }

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