NorFilter example

static::assertTrue($result->has($ids->get('manufacturer-1')));
        static::assertTrue($result->has($ids->get('manufacturer-2')));
    }

    /** * @depends testIndexing */
    public function testManyToOneTranslated(IdsCollection $ids): void
    {
        $criteria = new Criteria($ids->prefixed('product-'));
        $criteria->addFilter(
            new NorFilter([
                new EqualsFilter('product.manufacturer.id', null),
                new EqualsFilter('product.manufacturer.name', 'test'),
            ]),
        );

        $result = $this->getContainer()->get('product.repository')
            ->searchIds($criteria, Context::createDefaultContext());

        static::assertEquals(2, $result->getTotal());
        static::assertTrue($result->has($ids->get('product-2')));
        static::assertTrue($result->has($ids->get('product-1')));

        

        yield 'Test without queries' => [
            ['type' => 'and'],
            new AndFilter(),
        ];
        yield 'Test or filter' => [
            ['type' => 'or', 'queries' => [['type' => 'equals', 'field' => 'name', 'value' => 'foo']]],
            new OrFilter([new EqualsFilter('product.name', 'foo')]),
        ];
        yield 'Test nor filter' => [
            ['type' => 'nor', 'queries' => [['type' => 'equals', 'field' => 'name', 'value' => 'foo']]],
            new NorFilter([new EqualsFilter('product.name', 'foo')]),
        ];
        yield 'Test nand filter' => [
            ['type' => 'nand', 'queries' => [['type' => 'equals', 'field' => 'name', 'value' => 'foo']]],
            new NandFilter([new EqualsFilter('product.name', 'foo')]),
        ];
    }

    /** * @dataProvider equalsFilterDataProvider * * @param EqualsFilterType $filter */
if (!\is_scalar($query['value']) && $query['value'] !== null) {
                    throw DataAbstractionLayerException::invalidFilterQuery('Parameter "value" for equals filter must be scalar or null.', $path . '/value');
                }

                return new EqualsFilter(self::buildFieldName($definition$query['field'])$query['value']);
            case 'nand':
                return new NandFilter(
                    self::parseQueries($definition$path$exception$query['queries'] ?? [])
                );
            case 'nor':
                return new NorFilter(
                    self::parseQueries($definition$path$exception$query['queries'] ?? [])
                );
            case 'not':
                return new NotFilter(
                    $query['operator'] ?? 'AND',
                    self::parseQueries($definition$path$exception$query['queries'] ?? [])
                );
            case 'and':
                return new AndFilter(
                    self::parseQueries($definition$path$exception$query['queries'] ?? [])
                );
            
Home | Imprint | This part of the site doesn't use cookies.