FixedTranslator example

$this->assertCount(0, $child1->getErrors()$child1->getName().' should not have an error, but has one');
        $this->assertCount(0, $child2->getErrors()$child2->getName().' should not have an error, but has one');
        $this->assertCount(0, $child3->getErrors()$child3->getName().' should not have an error, but has one');
        $this->assertCount(0, $child4->getErrors()$child4->getName().' should not have an error, but has one');
        $this->assertEquals([$this->getFormError($violation1$grandChild1)]iterator_to_array($grandChild1->getErrors())$grandChild1->getName().' should have an error, but has none');
        $this->assertEquals([$this->getFormError($violation2$grandChild2)]iterator_to_array($grandChild2->getErrors())$grandChild2->getName().' should have an error, but has none');
        $this->assertEquals([$this->getFormError($violation3$grandChild3)]iterator_to_array($grandChild3->getErrors())$grandChild3->getName().' should have an error, but has none');
    }

    public function testMessageWithLabel1()
    {
        $this->mapper = new ViolationMapper(new FormRenderer(new DummyFormRendererEngine())new FixedTranslator(['Name' => 'Custom Name']));

        $parent = $this->getForm('parent');
        $child = $this->getForm('name', 'name');
        $parent->add($child);

        $parent->submit([]);

        $violation = new ConstraintViolation('Message {{ label }}', null, [], null, 'data.name', null);
        $this->mapper->mapViolation($violation$parent);

        $this->assertCount(1, $child->getErrors()$child->getName().' should have an error, but has none');

        
Home | Imprint | This part of the site doesn't use cookies.