CustomerIndexer example

$customerId = Uuid::randomHex();

        $event = $this->createMock(EntityWrittenContainerEvent::class);

        $event->method('getPrimaryKeys')->willReturn(['customer']);
        $event->expects(static::once())->method('getPrimaryKeysWithPropertyChange')->willReturn([
            $customerId,
        ]);

        $eventDispatcher = $this->createMock(EventDispatcherInterface::class);

        $indexer = new CustomerIndexer(
            $this->createMock(IteratorFactory::class),
            $this->createMock(EntityRepository::class),
            $this->createMock(ManyToManyIdFieldUpdater::class),
            $this->createMock(CustomerNewsletterSalesChannelsUpdater::class),
            $eventDispatcher
        );

        /** @var CustomerIndexingMessage $indexing */
        $indexing = $indexer->update($event);

        static::assertSame($indexing->getIds()[$customerId]);
    }
Home | Imprint | This part of the site doesn't use cookies.