CartSerializationCleaner example


        $dispatcher = $this->getContainer()->get('event_dispatcher');

        $listener = $this->getMockBuilder(CallableClass::class)->getMock();
        $listener->expects(static::once())->method('__invoke');

        $this->addEventListener($dispatcher, CartBeforeSerializationEvent::class$listener);

        $connection = $this->createMock(Connection::class);
        $connection->expects(static::once())->method('fetchFirstColumn')->willReturn($allowed);

        $cleaner = new CartSerializationCleaner($connection$dispatcher);
        $cleaner->cleanupCart($cart);

        $items = $cart->getLineItems()->getFlat();
        foreach ($items as $item) {
            static::assertArrayHasKey($item->getId()$payloads);
            static::assertEquals($payloads[$item->getId()]$item->getPayload());
        }

        $delivery = $cart->getDeliveries()->first();
        $deliveryItems = $delivery !== null ? $delivery->getPositions()->getLineItems()->getFlat() : [];

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