|
17 | 17 | use Doctrine\Common\Persistence\ObjectRepository;
|
18 | 18 | use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
|
19 | 19 | use Symfony\Bridge\Doctrine\Test\TestRepositoryFactory;
|
| 20 | +use Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeObjectNoToStringIdEntity; |
20 | 21 | use Symfony\Bridge\Doctrine\Tests\Fixtures\Employee;
|
21 | 22 | use Symfony\Bridge\Doctrine\Tests\Fixtures\Person;
|
22 | 23 | use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity;
|
@@ -146,6 +147,7 @@ private function createSchema(ObjectManager $em)
|
146 | 147 | $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity2'),
|
147 | 148 | $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\Person'),
|
148 | 149 | $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\Employee'),
|
| 150 | + $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeObjectNoToStringIdEntity'), |
149 | 151 | ));
|
150 | 152 | }
|
151 | 153 |
|
@@ -617,4 +619,25 @@ public function testInvalidateRepositoryForInheritance()
|
617 | 619 | $entity = new Person(1, 'Foo');
|
618 | 620 | $this->validator->validate($entity, $constraint);
|
619 | 621 | }
|
| 622 | + |
| 623 | + public function testValidateUniquenessWithCompositeObjectNoToStringIdEntity() |
| 624 | + { |
| 625 | + $constraint = new UniqueEntity(array( |
| 626 | + 'message' => 'myMessage', |
| 627 | + 'fields' => array('objectOne', 'objectTwo'), |
| 628 | + 'em' => self::EM_NAME, |
| 629 | + 'entityClass' => 'Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeObjectNoToStringIdEntity', |
| 630 | + )); |
| 631 | + |
| 632 | + $objectOne = new SingleIntIdNoToStringEntity(1, 'foo'); |
| 633 | + $objectTwo = new SingleIntIdNoToStringEntity(2, 'bar'); |
| 634 | + $entity = new CompositeObjectNoToStringIdEntity($objectOne, $objectTwo); |
| 635 | + |
| 636 | + $this->em->persist($entity); |
| 637 | + $this->em->flush(); |
| 638 | + |
| 639 | + $newEntity = new CompositeObjectNoToStringIdEntity($objectOne, $objectTwo); |
| 640 | + |
| 641 | + $this->validator->validate($newEntity, $constraint); |
| 642 | + } |
620 | 643 | }
|
0 commit comments