remove tests for legacy behaviour

This commit is contained in:
Christian Flothmann 2019-07-06 11:53:46 +02:00
parent 123d5b23df
commit d6d4abaa03
3 changed files with 1 additions and 48 deletions

View File

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

View File

@ -108,20 +108,4 @@ EOF;
$this->assertSame($expected, (string) $violation);
}
public function testNonStringCode()
{
$violation = new ConstraintViolation(
'42 cannot be used here',
'this is the message template',
[],
['some_value' => 42],
'some_value',
null,
null,
42
);
self::assertSame('42', $violation->getCode());
}
}

View File

@ -1,31 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Tests\Violation;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Translation\IdentityTranslator;
use Symfony\Component\Validator\ConstraintViolationList;
use Symfony\Component\Validator\Tests\Fixtures\ConstraintA;
use Symfony\Component\Validator\Violation\ConstraintViolationBuilder;
class ConstraintViolationBuilderTest extends TestCase
{
public function testNonStringCode()
{
$constraintViolationList = new ConstraintViolationList();
(new ConstraintViolationBuilder($constraintViolationList, new ConstraintA(), 'invalid message', [], null, 'foo', 'baz', new IdentityTranslator()))
->setCode(42)
->addViolation();
self::assertSame('42', $constraintViolationList->get(0)->getCode());
}
}