ElasticsearchIndexConfigEvent example

$this->client->indices()->delete(['index' => $index]);
        }
        // @codeCoverageIgnoreEnd
        $mapping = $this->mappingProvider->build($definition$context);

        $body = array_merge(
            $this->config,
            ['mappings' => $mapping]
        );

        $event = new ElasticsearchIndexConfigEvent($index$body$definition$context);
        $this->eventDispatcher->dispatch($event);

        $this->client->indices()->create([
            'index' => $index,
            'body' => $event->getConfig(),
        ]);

        $this->createAliasIfNotExisting($index$alias);

        $this->eventDispatcher->dispatch(new ElasticsearchIndexCreatedEvent($index$definition));
    }

    
use Shopware\Elasticsearch\Framework\Indexing\Event\ElasticsearchIndexConfigEvent;

/** * @internal * * @covers \Shopware\Elasticsearch\Framework\Indexing\Event\ElasticsearchIndexConfigEvent */
class ElasticsearchIndexConfigEventTest extends TestCase
{
    public function testEvent(): void
    {
        $event = new ElasticsearchIndexConfigEvent('index', ['config' => 'value']$this->createMock(AbstractElasticsearchDefinition::class), Context::createDefaultContext());
        static::assertSame('index', $event->getIndexName());
        static::assertSame(['config' => 'value']$event->getConfig());
        static::assertInstanceOf(AbstractElasticsearchDefinition::class$event->getDefinition());
        static::assertInstanceOf(Context::class$event->getContext());

        $event->setConfig(['config' => 'value2']);

        static::assertSame(['config' => 'value2']$event->getConfig());
    }
}
Home | Imprint | This part of the site doesn't use cookies.