@@ -1786,6 +1786,44 @@ public function testLabelPlaceholderTranslatedWithTranslationDomainDefinedByPare
1786
1786
$ this ->assertSame ('Message "translated foo label" ' , $ errors [0 ]->getMessage ());
1787
1787
}
1788
1788
1789
+ public function testLabelPlaceholderTranslatedWithTranslationParametersMergedFromParentForm ()
1790
+ {
1791
+ $ translator = $ this ->createMock (TranslatorInterface::class);
1792
+ $ translator ->expects ($ this ->any ())
1793
+ ->method ('trans ' )
1794
+ ->with ('foo ' , [
1795
+ '{{ param_defined_in_parent }} ' => 'param defined in parent value ' ,
1796
+ '{{ param_defined_in_child }} ' => 'param defined in child value ' ,
1797
+ '{{ param_defined_in_parent_overridden_in_child }} ' => 'param defined in parent overridden in child child value ' ,
1798
+ ])
1799
+ ->willReturn ('translated foo label ' )
1800
+ ;
1801
+ $ this ->mapper = new ViolationMapper (null , $ translator );
1802
+
1803
+ $ form = $ this ->getForm ('' , null , null , [], false , true , [
1804
+ 'label_translation_parameters ' => [
1805
+ '{{ param_defined_in_parent }} ' => 'param defined in parent value ' ,
1806
+ '{{ param_defined_in_parent_overridden_in_child }} ' => 'param defined in parent overridden in child parent value ' ,
1807
+ ],
1808
+ ]);
1809
+ $ child = $ this ->getForm ('foo ' , 'foo ' , null , [], false , true , [
1810
+ 'label ' => 'foo ' ,
1811
+ 'label_translation_parameters ' => [
1812
+ '{{ param_defined_in_child }} ' => 'param defined in child value ' ,
1813
+ '{{ param_defined_in_parent_overridden_in_child }} ' => 'param defined in parent overridden in child child value ' ,
1814
+ ],
1815
+ ]);
1816
+ $ form ->add ($ child );
1817
+
1818
+ $ violation = new ConstraintViolation ('Message "{{ label }}" ' , null , [], null , 'data.foo ' , null );
1819
+ $ this ->mapper ->mapViolation ($ violation , $ form );
1820
+
1821
+ $ errors = iterator_to_array ($ child ->getErrors ());
1822
+
1823
+ $ this ->assertCount (1 , $ errors , $ child ->getName ().' should have an error, but has none ' );
1824
+ $ this ->assertSame ('Message "translated foo label" ' , $ errors [0 ]->getMessage ());
1825
+ }
1826
+
1789
1827
public function testTranslatorNotCalledWithoutLabel ()
1790
1828
{
1791
1829
$ renderer = $ this ->getMockBuilder (FormRenderer::class)
0 commit comments