RedisStub example

/** * @internal * * @covers \Shopware\Core\Checkout\Cart\RedisCartPersister */
class RedisCartPersisterTest extends TestCase
{
    public function testDecorated(): void
    {
        $cartSerializationCleaner = $this->createMock(CartSerializationCleaner::class);
        $persister = new RedisCartPersister(new RedisStub()new CollectingEventDispatcher()$cartSerializationCleaner, true, 90);
        $this->expectException(DecorationPatternException::class);
        $persister->getDecorated();
    }

    public function testSave(): void
    {
        $token = Uuid::randomHex();
        $cart = new Cart($token);
        $cart->add(new LineItem('test', 'test'));

        $dispatcher = $this->createMock(EventDispatcher::class);

        
use Shopware\Core\Test\Stub\Redis\RedisStub;

/** * @internal * * @covers \Shopware\Core\Framework\Adapter\Cache\InvalidatorStorage\RedisInvalidatorStorage */
class RedisInvalidatorStorageTest extends TestCase
{
    public function testStorage(): void
    {
        $storage = new RedisInvalidatorStorage(new RedisStub());

        static::assertSame($storage->loadAndDelete()[]);

        $storage->store(['foo', 'bar']);

        static::assertSame(['bar', 'foo']$storage->loadAndDelete());
        static::assertSame([]$storage->loadAndDelete());
    }
}
Home | Imprint | This part of the site doesn't use cookies.