[Validator] Fix tests

This commit is contained in:
Maxime Steinhausser 2019-07-04 17:27:57 +02:00
parent 155cfb273f
commit 22c58f59ce
3 changed files with 3 additions and 12 deletions

View File

@ -84,7 +84,7 @@ class ConstraintViolation implements ConstraintViolationInterface
$class .= '.';
}
if ('' !== $code = $this->code) {
if ('' !== $code = (string) $this->code) {
$code = ' (code '.$code.')';
}

View File

@ -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());
}
}

View File

@ -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());
}
}