ElasticsearchIndexCreatedEvent example

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

/** * @internal * * @covers \Shopware\Elasticsearch\Framework\Indexing\Event\ElasticsearchIndexCreatedEvent */
class ElasticsearchIndexCreatedEventTest extends TestCase
{
    public function testEvent(): void
    {
        $event = new ElasticsearchIndexCreatedEvent('index', $this->createMock(AbstractElasticsearchDefinition::class));
        static::assertSame('index', $event->getIndexName());
        static::assertInstanceOf(AbstractElasticsearchDefinition::class$event->getDefinition());
    }
}
$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));
    }

    public function aliasExists(string $alias): bool
    {
        return $this->client->indices()->existsAlias(['name' => $alias]);
    }

    private function indexExists(string $index): bool
    {
        return $this->client->indices()->exists(['index' => $index]);
    }

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