From bee93a3162f58eab763ba5bdbd9a00f3cebd9e68 Mon Sep 17 00:00:00 2001 From: Fran Moreno Date: Sat, 29 Jul 2023 09:40:38 +0200 Subject: [PATCH] Add UniqueTest --- Tests/Validator/Constraints/UniqueTest.php | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Tests/Validator/Constraints/UniqueTest.php diff --git a/Tests/Validator/Constraints/UniqueTest.php b/Tests/Validator/Constraints/UniqueTest.php new file mode 100644 index 00000000..8931700c --- /dev/null +++ b/Tests/Validator/Constraints/UniqueTest.php @@ -0,0 +1,43 @@ += 80000) { + $loader = new AnnotationLoader(); + } else { + $loader = new AnnotationLoader(new AnnotationReader()); + } + + self::assertTrue($loader->loadClassMetadata($metadata)); + + [$constraint] = $metadata->getConstraints(); + assert($constraint instanceof Unique); + self::assertSame(['email'], $constraint->fields); + self::assertSame('doctrine_odm.mongodb.unique', $constraint->validatedBy()); + } +} + +/** @Unique(fields={"email"}) */ +#[Unique(['email'])] +class UniqueDocumentDummyOne +{ + private string $email; +}