TokenFilter example

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

    /** * @dataProvider cases * * @param list<string> $tokens * @param list<string> $expected */
    public function testExcludedFilterFilter(array $tokens, array $expected): void
    {
        $service = new StopwordTokenFilter(new TokenFilter($this->connection)$this->connection);
        $keywords = $service->filter($tokens$this->context);

        sort($expected);
        sort($keywords);
        static::assertEquals($expected$keywords);
    }

    /** * @return array<array{list<string>, list<string>}> */
    public static function cases(): array
    {
/** * @dataProvider cases * * @param list<string> $tokens * @param list<string> $excludedTerms * @param list<string> $expected */
    public function testExcludedFilterFilter(array $tokens, array $excludedTerms, array $expected): void
    {
        $this->updateProductSearchConfig($excludedTerms);

        $service = new TokenFilter($this->connection);
        $keywords = $service->filter($tokens$this->context);

        sort($expected);
        sort($keywords);
        static::assertEquals($expected$keywords);
    }

    /** * @return array<array{list<string>, list<string>, list<string>}> */
    public static function cases(): array
    {
Home | Imprint | This part of the site doesn't use cookies.