CriteriaParser example

->method('search')
            ->willThrowException(new NoNodesAvailableException());

        $helper = $this->createMock(ElasticsearchHelper::class);
        $helper->expects(static::once())->method('logAndThrowException');
        $helper->method('allowSearch')->willReturn(true);

        $searcher = new ElasticsearchEntitySearcher(
            $client,
            $this->createMock(EntitySearcherInterface::class),
            $helper,
            new CriteriaParser(new EntityDefinitionQueryHelper()$this->createMock(CustomFieldService::class)$this->createMock(AbstractKeyValueStorage::class)),
            $this->createMock(AbstractElasticsearchSearchHydrator::class),
            new EventDispatcher(),
        );

        $context = Context::createDefaultContext();
        $criteria->addState(Criteria::STATE_ELASTICSEARCH_AWARE);

        $result = $searcher->search(
            new ProductDefinition(),
            $criteria,
            $context
        );
class CriteriaParserTest extends TestCase
{
    private const SECOND_LANGUAGE = 'd5da80fc94874ea988eac8abdea44e0a';

    public function testAggregationWithSorting(): void
    {
        $aggs = new TermsAggregation('foo', 'test', null, new FieldSorting('abc', FieldSorting::ASCENDING)new TermsAggregation('foo', 'foo2'));

        $definition = $this->getDefinition();

        /** @var CompositeAggregation $esAgg */
        $esAgg = (new CriteriaParser(
            new EntityDefinitionQueryHelper(),
            $this->createMock(CustomFieldService::class),
            $this->createMock(AbstractKeyValueStorage::class)
        ))->parseAggregation($aggs$definition, Context::createDefaultContext());

        static::assertInstanceOf(CompositeAggregation::class$esAgg);
        static::assertSame([
            'composite' => [
                'sources' => [
                    [
                        'foo.sorting' => [
                            
Home | Imprint | This part of the site doesn't use cookies.