[Validator] Rename issn constraint message option to be consistent with all constraints having a single message option

This commit is contained in:
Antonio J. García Lagar 2013-04-28 18:50:39 +02:00
parent 06d5fb171f
commit 57c724a37f
3 changed files with 7 additions and 7 deletions

View File

@ -20,7 +20,7 @@ use Symfony\Component\Validator\Constraint;
*/
class Issn extends Constraint
{
public $invalidMessage = 'This value is not a valid ISSN.';
public $message = 'This value is not a valid ISSN.';
public $caseSensitive = false;
public $requireHyphen = false;
}

View File

@ -43,7 +43,7 @@ class IssnValidator extends ConstraintValidator
$pattern = "/^".$digitsPattern.$checksumPattern."$/";
if (!preg_match($pattern, $value)) {
$this->context->addViolation($constraint->invalidMessage);
$this->context->addViolation($constraint->message);
} else {
$digits = str_split(strtoupper(str_replace('-', '', $value)));
@ -55,7 +55,7 @@ class IssnValidator extends ConstraintValidator
$checksum = 'X' == reset($digits) ? 10 : (int) reset($digits);
if (0 != ($sum + $checksum) % 11) {
$this->context->addViolation($constraint->invalidMessage);
$this->context->addViolation($constraint->message);
}
}
}

View File

@ -145,7 +145,7 @@ class IssnValidatorTest extends \PHPUnit_Framework_TestCase
$this->context
->expects($this->once())
->method('addViolation')
->with($constraint->invalidMessage);
->with($constraint->message);
$this->validator->validate($issn, $constraint);
}
@ -159,7 +159,7 @@ class IssnValidatorTest extends \PHPUnit_Framework_TestCase
$this->context
->expects($this->once())
->method('addViolation')
->with($constraint->invalidMessage);
->with($constraint->message);
$this->validator->validate($issn, $constraint);
}
@ -186,7 +186,7 @@ class IssnValidatorTest extends \PHPUnit_Framework_TestCase
$this->context
->expects($this->once())
->method('addViolation')
->with($constraint->invalidMessage);
->with($constraint->message);
$this->validator->validate($issn, $constraint);
}
@ -200,7 +200,7 @@ class IssnValidatorTest extends \PHPUnit_Framework_TestCase
$this->context
->expects($this->once())
->method('addViolation')
->with($constraint->invalidMessage);
->with($constraint->message);
$this->validator->validate($issn, $constraint);
}