TestSessionStorage example

'test.error.message',
            ['test' => 'error'],
            Error::LEVEL_ERROR,
            true,
            true
        );

        $cart = new Cart('foo');
        $cart->addErrors($error);

        $request = new Request();
        $session = new Session(new TestSessionStorage());

        $request->setSession($session);

        $stack = new RequestStack();
        $stack->push($request);

        $translator = static::createMock(TranslatorInterface::class);
        $translator
            ->expects(static::once())
            ->method('trans')
            ->with('checkout.test.error.message', ['%test%' => 'error'])
            
use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageFactoryInterface;
use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface;

/** * @internal */
#[Package('core')] class TestSessionStorageFactory implements SessionStorageFactoryInterface
{
    public function createStorage(?Request $request): SessionStorageInterface
    {
        return new TestSessionStorage();
    }
}
Home | Imprint | This part of the site doesn't use cookies.