ElasticsearchIndexingCommand example


        if (Feature::isActive('ES_MULTILINGUAL_INDEX')) {
            $this->getContainer()->get(AbstractKeyValueStorage::class)->set(ElasticsearchIndexer::ENABLE_MULTILINGUAL_INDEX_KEY, 1);
        }

        $this->clearElasticsearch();

        $connection = $this->getContainer()->get(Connection::class);

        $connection->executeStatement('DELETE FROM custom_field');

        $command = new ElasticsearchIndexingCommand(
            $this->getContainer()->get(ElasticsearchIndexer::class),
            $this->getContainer()->get('messenger.bus.shopware'),
            $this->getContainer()->get(CreateAliasTaskHandler::class),
            true
        );

        $command->run(new ArrayInput([])new NullOutput());

        static::assertNotEmpty($this->indexDetector->getAllUsedIndices());
    }

    
/** * @DisabledFeatures(features={"v6.5.0.0"}) */
    public function testExecute(): void
    {
        $oldIndexer = $this->getMockBuilder(ElasticsearchIndexer::class)->disableOriginalConstructor()->getMock();

        $bus = $this->createMock(MessageBusInterface::class);
        $aliasHandler = $this->createMock(CreateAliasTaskHandler::class);
        $aliasHandler->expects(static::never())->method('run');

        $commandTester = new CommandTester(new ElasticsearchIndexingCommand($oldIndexer$bus$aliasHandler, true));
        $commandTester->execute([]);

        $commandTester->assertCommandIsSuccessful();
    }

    /** * @DisabledFeatures(features={"v6.5.0.0"}) */
    public function testExecuteQueue(): void
    {
        $oldIndexer = $this->getMockBuilder(ElasticsearchIndexer::class)->disableOriginalConstructor()->getMock();

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