-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #777 from divine/fix-depreciation
fix: UniqueEntity::$service is considered final
- Loading branch information
Showing
2 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Bundle\MongoDBBundle\Tests\Validator\Constraints; | ||
|
||
use Doctrine\Bundle\MongoDBBundle\Validator\Constraints\Unique; | ||
use Doctrine\Common\Annotations\AnnotationReader; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Validator\Mapping\ClassMetadata; | ||
use Symfony\Component\Validator\Mapping\Loader\AnnotationLoader; | ||
|
||
use function assert; | ||
|
||
use const PHP_VERSION_ID; | ||
|
||
final class UniqueTest extends TestCase | ||
{ | ||
public function testWithDefaultProperty(): void | ||
{ | ||
$metadata = new ClassMetadata(UniqueDocumentDummyOne::class); | ||
|
||
if (PHP_VERSION_ID >= 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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters