|
22 | 22 | use Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeObjectNoToStringIdEntity;
|
23 | 23 | use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity;
|
24 | 24 | use Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNameEntity;
|
| 25 | +use Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNullableNameEntity; |
25 | 26 | use Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity;
|
26 | 27 | use Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity2;
|
27 | 28 | use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity;
|
@@ -142,6 +143,7 @@ private function createSchema(ObjectManager $em)
|
142 | 143 | $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity'),
|
143 | 144 | $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity'),
|
144 | 145 | $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNameEntity'),
|
| 146 | + $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNullableNameEntity'), |
145 | 147 | $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeIntIdEntity'),
|
146 | 148 | $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity'),
|
147 | 149 | $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity2'),
|
@@ -231,7 +233,7 @@ public function testValidateUniquenessWithNull()
|
231 | 233 | $this->assertNoViolation();
|
232 | 234 | }
|
233 | 235 |
|
234 |
| - public function testValidateUniquenessWithIgnoreNull() |
| 236 | + public function testValidateUniquenessWithIgnoreNullDisabled() |
235 | 237 | {
|
236 | 238 | $constraint = new UniqueEntity(array(
|
237 | 239 | 'message' => 'myMessage',
|
@@ -281,6 +283,34 @@ public function testAllConfiguredFieldsAreCheckedOfBeingMappedByDoctrineWithIgno
|
281 | 283 | $this->validator->validate($entity1, $constraint);
|
282 | 284 | }
|
283 | 285 |
|
| 286 | + public function testNoValidationIfFirstFieldIsNullAndNullValuesAreIgnored() |
| 287 | + { |
| 288 | + $constraint = new UniqueEntity(array( |
| 289 | + 'message' => 'myMessage', |
| 290 | + 'fields' => array('name', 'name2'), |
| 291 | + 'em' => self::EM_NAME, |
| 292 | + 'ignoreNull' => true, |
| 293 | + )); |
| 294 | + |
| 295 | + $entity1 = new DoubleNullableNameEntity(1, null, 'Foo'); |
| 296 | + $entity2 = new DoubleNullableNameEntity(2, null, 'Foo'); |
| 297 | + |
| 298 | + $this->validator->validate($entity1, $constraint); |
| 299 | + |
| 300 | + $this->assertNoViolation(); |
| 301 | + |
| 302 | + $this->em->persist($entity1); |
| 303 | + $this->em->flush(); |
| 304 | + |
| 305 | + $this->validator->validate($entity1, $constraint); |
| 306 | + |
| 307 | + $this->assertNoViolation(); |
| 308 | + |
| 309 | + $this->validator->validate($entity2, $constraint); |
| 310 | + |
| 311 | + $this->assertNoViolation(); |
| 312 | + } |
| 313 | + |
284 | 314 | public function testValidateUniquenessWithValidCustomErrorPath()
|
285 | 315 | {
|
286 | 316 | $constraint = new UniqueEntity(array(
|
|
0 commit comments