clearElasticsearch example

use KernelTestBehaviour;
    use QueueTestBehaviour;

    private Connection $connection;

    private AdminSearchRegistry $registry;

    private Client $client;

    protected function setUp(): void
    {
        $this->clearElasticsearch();

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

        $this->client = $this->getContainer()->get(Client::class);

        $indexer = new PromotionAdminSearchIndexer(
            $this->connection,
            $this->getContainer()->get(IteratorFactory::class),
            $this->getContainer()->get('promotion.repository'),
            100
        );

        
use KernelTestBehaviour;
    use QueueTestBehaviour;

    private Connection $connection;

    private EntityRepository $promotionRepo;

    private AdminSearchController $controller;

    protected function setUp(): void
    {
        $this->clearElasticsearch();

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

        $this->promotionRepo = $this->getContainer()->get('promotion.repository');

        $this->controller = $this->getContainer()->get(AdminSearchController::class);
    }

    public function testElasticSearch(): void
    {
        if (!$this->getContainer()->getParameter('elasticsearch.administration.enabled')) {
            
->get(Connection::class);

        $connection->rollBack();
    }

    public function testIndexing(): IdsCollection
    {
        static::expectNotToPerformAssertions();

        $this->connection->executeStatement('DELETE FROM product');

        $this->clearElasticsearch();
        $this->registerCustomFieldsMapping();
        $this->indexElasticSearch();

        $ids = new TestDataCollection();
        $this->createData($ids);

        $this->refreshIndex();

        return $ids;
    }

    
$this->client = $this->getContainer()->get(Client::class);
        $this->indexDetector = $this->getContainer()->get(ElasticsearchOutdatedIndexDetector::class);
    }

    public function testCreateIndices(): void
    {
        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
        );

        

class ElasticsearchIndexerTest extends TestCase
{
    use BasicTestDataBehaviour;
    use ElasticsearchTestTestBehaviour;
    use KernelTestBehaviour;

    protected function setUp(): void
    {
        $this->clearElasticsearch();
    }

    protected function tearDown(): void
    {
        $this->clearElasticsearch();
    }

    public function testFirstIndexDoesNotCreateTask(): void
    {
        $c = $this->getContainer()->get(Connection::class);
        static::assertEmpty($c->fetchAllAssociative('SELECT * FROM elasticsearch_index_task'));

        
$connection->rollBack();
        $connection->executeStatement('DROP TABLE `extended_product`');
    }

    public function testIndexing(): IdsCollection
    {
        try {
            $this->connection->executeStatement('DELETE FROM product');

            $context = $this->context;

            $this->clearElasticsearch();

            $this->resetStopWords();

            $this->ids->set('currency', $this->currencyId);
            $this->ids->set('anotherCurrency', $this->anotherCurrencyId);
            $currencies = [
                [
                    'id' => $this->currencyId,
                    'name' => 'test',
                    'factor' => 1,
                    'symbol' => 'A',
                    
Home | Imprint | This part of the site doesn't use cookies.