[Validator] Fix tests
This commit is contained in:
parent
155cfb273f
commit
22c58f59ce
@ -84,7 +84,7 @@ class ConstraintViolation implements ConstraintViolationInterface
|
||||
$class .= '.';
|
||||
}
|
||||
|
||||
if ('' !== $code = $this->code) {
|
||||
if ('' !== $code = (string) $this->code) {
|
||||
$code = ' (code '.$code.')';
|
||||
}
|
||||
|
||||
|
@ -109,10 +109,6 @@ EOF;
|
||||
$this->assertSame($expected, (string) $violation);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Not using a string as the error code in Symfony\Component\Validator\ConstraintViolation::__construct() is deprecated since Symfony 4.4. A type-hint will be added in 5.0.
|
||||
*/
|
||||
public function testNonStringCode()
|
||||
{
|
||||
$violation = new ConstraintViolation(
|
||||
@ -126,6 +122,6 @@ EOF;
|
||||
42
|
||||
);
|
||||
|
||||
self::assertSame(42, $violation->getCode());
|
||||
self::assertSame('42', $violation->getCode());
|
||||
}
|
||||
}
|
||||
|
@ -19,11 +19,6 @@ use Symfony\Component\Validator\Violation\ConstraintViolationBuilder;
|
||||
|
||||
class ConstraintViolationBuilderTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Not using a string as the error code in Symfony\Component\Validator\Violation\ConstraintViolationBuilder::setCode() is deprecated since Symfony 4.4. A type-hint will be added in 5.0.
|
||||
* @expectedDeprecation Not using a string as the error code in Symfony\Component\Validator\ConstraintViolation::__construct() is deprecated since Symfony 4.4. A type-hint will be added in 5.0.
|
||||
*/
|
||||
public function testNonStringCode()
|
||||
{
|
||||
$constraintViolationList = new ConstraintViolationList();
|
||||
@ -31,6 +26,6 @@ class ConstraintViolationBuilderTest extends TestCase
|
||||
->setCode(42)
|
||||
->addViolation();
|
||||
|
||||
self::assertSame(42, $constraintViolationList->get(0)->getCode());
|
||||
self::assertSame('42', $constraintViolationList->get(0)->getCode());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user