public function LegacyExecutionContextTest::testAddViolationUsesPassedNullValue in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/validator/Tests/LegacyExecutionContextTest.php \Symfony\Component\Validator\Tests\LegacyExecutionContextTest::testAddViolationUsesPassedNullValue()
File
- vendor/
symfony/ validator/ Tests/ LegacyExecutionContextTest.php, line 134
Class
- LegacyExecutionContextTest
- @group legacy
Namespace
Symfony\Component\Validator\TestsCode
public function testAddViolationUsesPassedNullValue() {
$this->translator
->expects($this
->once())
->method('trans')
->with('Error', array(
'foo1' => 'bar1',
))
->will($this
->returnValue('Translated error'));
$this->translator
->expects($this
->once())
->method('transChoice')
->with('Choice error', 1, array(
'foo2' => 'bar2',
))
->will($this
->returnValue('Translated choice error'));
// passed null value should override preconfigured value "invalid"
$this->context
->addViolation('Error', array(
'foo1' => 'bar1',
), null);
$this->context
->addViolation('Choice error', array(
'foo2' => 'bar2',
), null, 1);
$this
->assertEquals(new ConstraintViolationList(array(
new ConstraintViolation('Translated error', 'Error', array(
'foo1' => 'bar1',
), 'Root', 'foo.bar', null),
new ConstraintViolation('Translated choice error', 'Choice error', array(
'foo2' => 'bar2',
), 'Root', 'foo.bar', null, 1),
)), $this->context
->getViolations());
}