CollectingEventDispatcher 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);

        
$context->getCustomer()->assign([
            'activeBillingAddress' => null,
            'activeShippingAddress' => null,
        ]);

        $checkoutConfirmPageLoader->load(new Request()$context);
    }

    public function testValidationEventIsDispatched(): void
    {
        $eventDispatcher = new CollectingEventDispatcher();

        $checkoutConfirmPageLoader = new CheckoutConfirmPageLoader(
            $eventDispatcher,
            $this->createMock(StorefrontCartFacade::class),
            $this->createMock(ShippingMethodRoute::class),
            $this->createMock(PaymentMethodRoute::class),
            $this->createMock(GenericPageLoader::class),
            $this->createMock(AddressValidationFactory::class),
            $this->createMock(DataValidator::class)
        );

        
private MockObject&PluginService $pluginServiceMock;

    /** * @var (object&MockObject)|MockObject|CommandExecutor|(CommandExecutor&object&MockObject)|(CommandExecutor&MockObject) */
    private CommandExecutor&MockObject $commandExecutor;

    protected function setUp(): void
    {
        $this->pluginRepoMock = $this->createMock(EntityRepository::class);
        $this->eventDispatcher = new CollectingEventDispatcher();
        $this->kernelPluginCollectionMock = $this->createMock(KernelPluginCollection::class);
        $this->containerMock = $this->createMock(Container::class);
        $this->migrationLoaderMock = $this->createMock(MigrationCollectionLoader::class);
        $this->requirementsValidatorMock = $this->createMock(RequirementsValidator::class);
        $this->cacheItemPoolInterfaceMock = $this->createMock(CacheItemPoolInterface::class);
        $this->pluginServiceMock = $this->createMock(PluginService::class);
        $this->commandExecutor = $this->createMock(CommandExecutor::class);

        $this->pluginMock = $this->createMock(Plugin::class);

        $this->pluginMock->method('getNamespace')->willReturn('MockPlugin');
        
private CollectingEventDispatcher $eventDispatcher;

    /** * @var OrderRoute&MockObject */
    private OrderRoute $orderRoute;

    private AccountOverviewPageLoader $pageLoader;

    protected function setUp(): void
    {
        $this->eventDispatcher = new CollectingEventDispatcher();

        $this->orderRoute = $this->createMock(OrderRoute::class);

        $this->pageLoader = new AccountOverviewPageLoader(
            $this->createMock(GenericPageLoader::class),
            $this->eventDispatcher,
            $this->orderRoute,
            $this->createMock(CustomerRoute::class),
            $this->createMock(NewsletterAccountPageletLoader::class)
        );
    }

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