generateMessages example

if (!$this->helper->allowIndexing()) {
            return;
        }

        $alias = $this->helper->getIndexName($definition, Defaults::LANGUAGE_SYSTEM);

        if (!$this->client->indices()->existsAlias(['name' => $alias])) {
            $this->init();
        }

        $messages = $this->generateMessages($definition$ids);

        /** @var ElasticsearchIndexingMessage $message */
        foreach ($messages as $message) {
            $this->__invoke($message);
        }
    }

    /** * @param array<string> $ids * * @return ElasticsearchIndexingMessage[] */
public function testWriteAnArrayOfMessages()
    {
        $output = new TestOutput();
        $output->writeln(['foo', 'bar']);
        $this->assertEquals("foo\nbar\n", $output->output, '->writeln() can take an array of messages to output');
    }

    public function testWriteAnIterableOfMessages()
    {
        $output = new TestOutput();
        $output->writeln($this->generateMessages());
        $this->assertEquals("foo\nbar\n", $output->output, '->writeln() can take an iterable of messages to output');
    }

    private function generateMessages(): iterable
    {
        yield 'foo';
        yield 'bar';
    }

    /** * @dataProvider provideWriteArguments */
Home | Imprint | This part of the site doesn't use cookies.