getIndexers example



    public function testMultipleEntriesAreMerged(): void
    {
        $connection = $this->getContainer()->get(Connection::class);

        IndexerQueuer::registerIndexer($connection, 'test.indexer', ['test1']);
        IndexerQueuer::registerIndexer($connection, 'test.indexer', ['test2']);
        IndexerQueuer::registerIndexer($connection, 'foo.indexer', []);
        IndexerQueuer::registerIndexer($connection, 'fooba.indexer', ['ba']);

        $all = (new IndexerQueuer($connection))->getIndexers();
        ksort($all);

        static::assertSame([
            'foo.indexer' => [],
            'fooba.indexer' => ['ba'],
            'test.indexer' => ['test1', 'test2'],
        ]$all);
    }

    public function testOldEntriesGetsMerged(): void
    {
        
return [
            UpdatePostFinishEvent::class => 'runRegisteredIndexers',
            FirstRunWizardFinishedEvent::class => 'runRegisteredIndexers',
        ];
    }

    /** * @internal */
    public function runRegisteredIndexers(): void
    {
        $queuedIndexers = $this->indexerQueuer->getIndexers();

        if (empty($queuedIndexers)) {
            return;
        }

        $this->indexerQueuer->finishIndexer(array_keys($queuedIndexers));

        foreach ($queuedIndexers as $indexerName => $options) {
            $indexer = $this->indexerRegistry->getIndexer($indexerName);

            if ($indexer === null) {
                
$searchHelper = new AdminElasticsearchHelper(true, false, 'sw-admin');
        $registry = new AdminSearchRegistry(
            ['promotion' => $this->indexer],
            $this->createMock(Connection::class),
            $this->createMock(MessageBusInterface::class),
            $this->createMock(EventDispatcherInterface::class),
            $this->createMock(Client::class),
            $searchHelper,
            [],
            []
        );
        $indexers = $registry->getIndexers();

        static::assertSame(['promotion' => $this->indexer]$indexers);
    }

    public function testUpdateMapping(): void
    {
        $searchHelper = new AdminElasticsearchHelper(true, false, 'sw-admin');
        $client = $this->createMock(Client::class);

        $indices = $this->createMock(IndicesNamespace::class);
        $indices->expects(static::once())
            
Home | Imprint | This part of the site doesn't use cookies.