Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 22c58f5

Browse files
committed
[Validator] Fix tests
1 parent 155cfb2 commit 22c58f5

File tree

3 files changed

+3
-12
lines changed

3 files changed

+3
-12
lines changed

src/Symfony/Component/Validator/ConstraintViolation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function __toString()
8484
$class .= '.';
8585
}
8686

87-
if ('' !== $code = $this->code) {
87+
if ('' !== $code = (string) $this->code) {
8888
$code = ' (code '.$code.')';
8989
}
9090

src/Symfony/Component/Validator/Tests/ConstraintViolationTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,6 @@ public function testToStringOmitsEmptyCodes()
109109
$this->assertSame($expected, (string) $violation);
110110
}
111111

112-
/**
113-
* @group legacy
114-
* @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.
115-
*/
116112
public function testNonStringCode()
117113
{
118114
$violation = new ConstraintViolation(
@@ -126,6 +122,6 @@ public function testNonStringCode()
126122
42
127123
);
128124

129-
self::assertSame(42, $violation->getCode());
125+
self::assertSame('42', $violation->getCode());
130126
}
131127
}

src/Symfony/Component/Validator/Tests/Violation/ConstraintViolationBuilderTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,13 @@
1919

2020
class ConstraintViolationBuilderTest extends TestCase
2121
{
22-
/**
23-
* @group legacy
24-
* @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.
25-
* @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.
26-
*/
2722
public function testNonStringCode()
2823
{
2924
$constraintViolationList = new ConstraintViolationList();
3025
(new ConstraintViolationBuilder($constraintViolationList, new ConstraintA(), 'invalid message', [], null, 'foo', 'baz', new IdentityTranslator()))
3126
->setCode(42)
3227
->addViolation();
3328

34-
self::assertSame(42, $constraintViolationList->get(0)->getCode());
29+
self::assertSame('42', $constraintViolationList->get(0)->getCode());
3530
}
3631
}

0 commit comments

Comments
 (0)