EntityNotExists example

$definition->add('id', new EntityExists([
                'entity' => 'product_review',
                'context' => $context,
                'criteria' => $criteria,
            ]));
        } else {
            $criteria = new Criteria();
            $criteria->addFilter(new EqualsFilter('customerId', $data->get('customerId')));
            $criteria->addFilter(new EqualsFilter('productId', $data->get('productId')));

            $definition->add('customerId', new EntityNotExists([
                'entity' => 'product_review',
                'context' => $context,
                'criteria' => $criteria,
            ]));
        }

        $this->validator->validate($data->all()$definition);

        $violations = $this->validator->getViolations($data->all()$definition);

        if (!$violations->count()) {
            

class EntityNotExistsValidatorTest extends TestCase
{
    use IntegrationTestBehaviour;

    public function testCriteriaObjectIsNotModified(): void
    {
        $criteria = new Criteria();
        $criteria->setLimit(50);

        $context = Context::createDefaultContext();
        $constraint = new EntityNotExists(
            ['context' => $context, 'entity' => LocaleDefinition::ENTITY_NAME, 'criteria' => $criteria]
        );

        $validator = $this->getValidator();

        $validator->validate(Uuid::randomHex()$constraint);

        static::assertCount(0, $criteria->getFilters());
        static::assertSame(50, $criteria->getLimit());
    }

    
Home | Imprint | This part of the site doesn't use cookies.