ProductSearchKeywordAnalyzer example


    public function testAnalyze(array $productData, array $configFields, array $expected): void
    {
        $product = new ProductEntity();
        $product->assign($productData);

        $tokenizer = new Tokenizer(3);
        $tokenFilter = $this->createMock(TokenFilter::class);
        $tokenFilter->method('filter')->willReturnCallback(fn (array $tokens) => $tokens);

        $analyzer = new ProductSearchKeywordAnalyzer($tokenizer$tokenFilter);
        $analyzer = $analyzer->analyze($product$this->context, $configFields);
        $analyzerResult = $analyzer->getKeys();

        sort($analyzerResult);
        sort($expected);

        static::assertEquals($expected$analyzerResult);
    }

    /** * The old implementation relied on the error_reporting level, to also report notices as errors. * This test ensures that the new implementation does not rely on the error_reporting level. * * @dataProvider analyzeCases * * @param array<string, mixed> $productData * @param array<int, array{field: string, tokenize: bool, ranking: int}> $configFields * @param array<int, string> $expected */
Home | Imprint | This part of the site doesn't use cookies.