You are here

public function LegacyExecutionContextTest::testAddViolationAtUsesPassedNullValue in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/validator/Tests/LegacyExecutionContextTest.php \Symfony\Component\Validator\Tests\LegacyExecutionContextTest::testAddViolationAtUsesPassedNullValue()

File

vendor/symfony/validator/Tests/LegacyExecutionContextTest.php, line 213

Class

LegacyExecutionContextTest
@group legacy

Namespace

Symfony\Component\Validator\Tests

Code

public function testAddViolationAtUsesPassedNullValue() {
  $this->translator
    ->expects($this
    ->once())
    ->method('trans')
    ->with('Error', array(
    'foo' => 'bar',
  ))
    ->will($this
    ->returnValue('Translated error'));
  $this->translator
    ->expects($this
    ->once())
    ->method('transChoice')
    ->with('Choice error', 2, array(
    'foo' => 'bar',
  ))
    ->will($this
    ->returnValue('Translated choice error'));

  // passed null value should override preconfigured value "invalid"
  $this->context
    ->addViolationAt('bam.baz', 'Error', array(
    'foo' => 'bar',
  ), null);
  $this->context
    ->addViolationAt('bam.baz', 'Choice error', array(
    'foo' => 'bar',
  ), null, 2);
  $this
    ->assertEquals(new ConstraintViolationList(array(
    new ConstraintViolation('Translated error', 'Error', array(
      'foo' => 'bar',
    ), 'Root', 'foo.bar.bam.baz', null),
    new ConstraintViolation('Translated choice error', 'Choice error', array(
      'foo' => 'bar',
    ), 'Root', 'foo.bar.bam.baz', null, 2),
  )), $this->context
    ->getViolations());
}