Skip to content

Commit 632b5c5

Browse files
Merge branch '3.0' into 3.1
* 3.0: [HttpKernel] fixed internal subrequests having an if-modified-since-header [Security] Fix deprecated usage of DigestAuthenticationEntryPoint::getKey() in DigestAuthenticationListener [Validator] Added additional MasterCard range to the CardSchemeValidator Make the exception message more clear. [Form] fixed bug - name in ButtonBuilder [DoctrineBridge] added missing error code for constraint. [ClassLoader] Fix declared classes being computed when not needed [varDumper] Fix missing usage of ExceptionCaster::$traceArgs
2 parents 2a2a0d2 + eceea88 commit 632b5c5

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

Tests/Validator/Constraints/UniqueEntityValidatorTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ public function testValidateUniqueness()
166166
->atPath('property.path.name')
167167
->setParameter('{{ value }}', 'Foo')
168168
->setInvalidValue('Foo')
169+
->setCode(UniqueEntity::NOT_UNIQUE_ERROR)
169170
->assertRaised();
170171
}
171172

@@ -190,6 +191,7 @@ public function testValidateCustomErrorPath()
190191
->atPath('property.path.bar')
191192
->setParameter('{{ value }}', 'Foo')
192193
->setInvalidValue('Foo')
194+
->setCode(UniqueEntity::NOT_UNIQUE_ERROR)
193195
->assertRaised();
194196
}
195197

@@ -242,6 +244,7 @@ public function testValidateUniquenessWithIgnoreNull()
242244
->atPath('property.path.name')
243245
->setParameter('{{ value }}', 'Foo')
244246
->setInvalidValue('Foo')
247+
->setCode(UniqueEntity::NOT_UNIQUE_ERROR)
245248
->assertRaised();
246249
}
247250

@@ -274,6 +277,7 @@ public function testValidateUniquenessWithValidCustomErrorPath()
274277
->atPath('property.path.name2')
275278
->setParameter('{{ value }}', 'Bar')
276279
->setInvalidValue('Bar')
280+
->setCode(UniqueEntity::NOT_UNIQUE_ERROR)
277281
->assertRaised();
278282
}
279283

@@ -407,6 +411,7 @@ public function testAssociatedEntity()
407411
->atPath('property.path.single')
408412
->setParameter('{{ value }}', $entity1)
409413
->setInvalidValue($entity1)
414+
->setCode(UniqueEntity::NOT_UNIQUE_ERROR)
410415
->assertRaised();
411416
}
412417

Validator/Constraints/UniqueEntity.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
*/
2424
class UniqueEntity extends Constraint
2525
{
26+
const NOT_UNIQUE_ERROR = '23bd9dbf-6b9b-41cd-a99e-4844bcf3077f';
27+
2628
public $message = 'This value is already used.';
2729
public $service = 'doctrine.orm.validator.unique';
2830
public $em = null;
@@ -31,6 +33,10 @@ class UniqueEntity extends Constraint
3133
public $errorPath = null;
3234
public $ignoreNull = true;
3335

36+
protected static $errorNames = array(
37+
self::NOT_UNIQUE_ERROR => 'NOT_UNIQUE_ERROR',
38+
);
39+
3440
public function getRequiredOptions()
3541
{
3642
return array('fields');

Validator/Constraints/UniqueEntityValidator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ public function validate($entity, Constraint $constraint)
135135
->atPath($errorPath)
136136
->setParameter('{{ value }}', $invalidValue)
137137
->setInvalidValue($invalidValue)
138+
->setCode(UniqueEntity::NOT_UNIQUE_ERROR)
138139
->addViolation();
139140
}
140141
}

0 commit comments

Comments
 (0)