@@ -93,6 +93,36 @@ public function testCreateFromLoaderPropertyPath()
9393 $ this ->assertSame ('value ' , $ this ->factory ->createListFromLoader ($ loader , 'property ' ));
9494 }
9595
96+ // https://github.com/symfony/symfony/issues/5494
97+ public function testCreateFromChoicesAssumeNullIfValuePropertyPathUnreadable ()
98+ {
99+ $ choices = array (null );
100+
101+ $ this ->decoratedFactory ->expects ($ this ->once ())
102+ ->method ('createListFromChoices ' )
103+ ->with ($ choices , $ this ->isInstanceOf ('\Closure ' ))
104+ ->will ($ this ->returnCallback (function ($ choices , $ callback ) {
105+ return array_map ($ callback , $ choices );
106+ }));
107+
108+ $ this ->assertSame (array (null ), $ this ->factory ->createListFromChoices ($ choices , 'property ' ));
109+ }
110+
111+ // https://github.com/symfony/symfony/issues/5494
112+ public function testCreateFromChoiceLoaderAssumeNullIfValuePropertyPathUnreadable ()
113+ {
114+ $ loader = $ this ->getMock ('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface ' );
115+
116+ $ this ->decoratedFactory ->expects ($ this ->once ())
117+ ->method ('createListFromLoader ' )
118+ ->with ($ loader , $ this ->isInstanceOf ('\Closure ' ))
119+ ->will ($ this ->returnCallback (function ($ loader , $ callback ) {
120+ return $ callback (null );
121+ }));
122+
123+ $ this ->assertNull ($ this ->factory ->createListFromLoader ($ loader , 'property ' ));
124+ }
125+
96126 public function testCreateFromLoaderPropertyPathInstance ()
97127 {
98128 $ loader = $ this ->getMock ('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface ' );
0 commit comments