1313
1414use PHPUnit \Framework \MockObject \MockObject ;
1515use PHPUnit \Framework \TestCase ;
16+ use Symfony \Component \Form \ChoiceList \ArrayChoiceList ;
1617use Symfony \Component \Form \ChoiceList \Factory \CachingFactoryDecorator ;
18+ use Symfony \Component \Form \ChoiceList \View \ChoiceListView ;
1719
1820/**
1921 * @author Bernhard Schussek <[email protected] > @@ -38,7 +40,7 @@ protected function setUp()
3840
3941 public function testCreateFromChoicesEmpty ()
4042 {
41- $ list = new \ stdClass ( );
43+ $ list = new ArrayChoiceList ([] );
4244
4345 $ this ->decoratedFactory ->expects ($ this ->once ())
4446 ->method ('createListFromChoices ' )
@@ -54,7 +56,7 @@ public function testCreateFromChoicesComparesTraversableChoicesAsArray()
5456 // The top-most traversable is converted to an array
5557 $ choices1 = new \ArrayIterator (['A ' => 'a ' ]);
5658 $ choices2 = ['A ' => 'a ' ];
57- $ list = new \ stdClass ( );
59+ $ list = new ArrayChoiceList ([] );
5860
5961 $ this ->decoratedFactory ->expects ($ this ->once ())
6062 ->method ('createListFromChoices ' )
@@ -69,8 +71,8 @@ public function testCreateFromChoicesGroupedChoices()
6971 {
7072 $ choices1 = ['key ' => ['A ' => 'a ' ]];
7173 $ choices2 = ['A ' => 'a ' ];
72- $ list1 = new \ stdClass ( );
73- $ list2 = new \ stdClass ( );
74+ $ list1 = new ArrayChoiceList ([] );
75+ $ list2 = new ArrayChoiceList ([] );
7476
7577 $ this ->decoratedFactory ->expects ($ this ->at (0 ))
7678 ->method ('createListFromChoices ' )
@@ -92,7 +94,7 @@ public function testCreateFromChoicesSameChoices($choice1, $choice2)
9294 {
9395 $ choices1 = [$ choice1 ];
9496 $ choices2 = [$ choice2 ];
95- $ list = new \ stdClass ( );
97+ $ list = new ArrayChoiceList ([] );
9698
9799 $ this ->decoratedFactory ->expects ($ this ->once ())
98100 ->method ('createListFromChoices ' )
@@ -110,8 +112,8 @@ public function testCreateFromChoicesDifferentChoices($choice1, $choice2)
110112 {
111113 $ choices1 = [$ choice1 ];
112114 $ choices2 = [$ choice2 ];
113- $ list1 = new \ stdClass ( );
114- $ list2 = new \ stdClass ( );
115+ $ list1 = new ArrayChoiceList ([] );
116+ $ list2 = new ArrayChoiceList ([] );
115117
116118 $ this ->decoratedFactory ->expects ($ this ->at (0 ))
117119 ->method ('createListFromChoices ' )
@@ -129,7 +131,7 @@ public function testCreateFromChoicesDifferentChoices($choice1, $choice2)
129131 public function testCreateFromChoicesSameValueClosure ()
130132 {
131133 $ choices = [1 ];
132- $ list = new \ stdClass ( );
134+ $ list = new ArrayChoiceList ([] );
133135 $ closure = function () {};
134136
135137 $ this ->decoratedFactory ->expects ($ this ->once ())
@@ -144,8 +146,8 @@ public function testCreateFromChoicesSameValueClosure()
144146 public function testCreateFromChoicesDifferentValueClosure ()
145147 {
146148 $ choices = [1 ];
147- $ list1 = new \ stdClass ( );
148- $ list2 = new \ stdClass ( );
149+ $ list1 = new ArrayChoiceList ([] );
150+ $ list2 = new ArrayChoiceList ([] );
149151 $ closure1 = function () {};
150152 $ closure2 = function () {};
151153
@@ -165,7 +167,7 @@ public function testCreateFromChoicesDifferentValueClosure()
165167 public function testCreateFromLoaderSameLoader ()
166168 {
167169 $ loader = $ this ->getMockBuilder ('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface ' )->getMock ();
168- $ list = new \ stdClass ( );
170+ $ list = new ArrayChoiceList ([] );
169171
170172 $ this ->decoratedFactory ->expects ($ this ->once ())
171173 ->method ('createListFromLoader ' )
@@ -180,8 +182,8 @@ public function testCreateFromLoaderDifferentLoader()
180182 {
181183 $ loader1 = $ this ->getMockBuilder ('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface ' )->getMock ();
182184 $ loader2 = $ this ->getMockBuilder ('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface ' )->getMock ();
183- $ list1 = new \ stdClass ( );
184- $ list2 = new \ stdClass ( );
185+ $ list1 = new ArrayChoiceList ([] );
186+ $ list2 = new ArrayChoiceList ([] );
185187
186188 $ this ->decoratedFactory ->expects ($ this ->at (0 ))
187189 ->method ('createListFromLoader ' )
@@ -199,7 +201,7 @@ public function testCreateFromLoaderDifferentLoader()
199201 public function testCreateFromLoaderSameValueClosure ()
200202 {
201203 $ loader = $ this ->getMockBuilder ('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface ' )->getMock ();
202- $ list = new \ stdClass ( );
204+ $ list = new ArrayChoiceList ([] );
203205 $ closure = function () {};
204206
205207 $ this ->decoratedFactory ->expects ($ this ->once ())
@@ -214,8 +216,8 @@ public function testCreateFromLoaderSameValueClosure()
214216 public function testCreateFromLoaderDifferentValueClosure ()
215217 {
216218 $ loader = $ this ->getMockBuilder ('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface ' )->getMock ();
217- $ list1 = new \ stdClass ( );
218- $ list2 = new \ stdClass ( );
219+ $ list1 = new ArrayChoiceList ([] );
220+ $ list2 = new ArrayChoiceList ([] );
219221 $ closure1 = function () {};
220222 $ closure2 = function () {};
221223
@@ -236,7 +238,7 @@ public function testCreateViewSamePreferredChoices()
236238 {
237239 $ preferred = ['a ' ];
238240 $ list = $ this ->getMockBuilder ('Symfony\Component\Form\ChoiceList\ChoiceListInterface ' )->getMock ();
239- $ view = new \ stdClass ();
241+ $ view = new ChoiceListView ();
240242
241243 $ this ->decoratedFactory ->expects ($ this ->once ())
242244 ->method ('createView ' )
@@ -252,8 +254,8 @@ public function testCreateViewDifferentPreferredChoices()
252254 $ preferred1 = ['a ' ];
253255 $ preferred2 = ['b ' ];
254256 $ list = $ this ->getMockBuilder ('Symfony\Component\Form\ChoiceList\ChoiceListInterface ' )->getMock ();
255- $ view1 = new \ stdClass ();
256- $ view2 = new \ stdClass ();
257+ $ view1 = new ChoiceListView ();
258+ $ view2 = new ChoiceListView ();
257259
258260 $ this ->decoratedFactory ->expects ($ this ->at (0 ))
259261 ->method ('createView ' )
@@ -272,7 +274,7 @@ public function testCreateViewSamePreferredChoicesClosure()
272274 {
273275 $ preferred = function () {};
274276 $ list = $ this ->getMockBuilder ('Symfony\Component\Form\ChoiceList\ChoiceListInterface ' )->getMock ();
275- $ view = new \ stdClass ();
277+ $ view = new ChoiceListView ();
276278
277279 $ this ->decoratedFactory ->expects ($ this ->once ())
278280 ->method ('createView ' )
@@ -288,8 +290,8 @@ public function testCreateViewDifferentPreferredChoicesClosure()
288290 $ preferred1 = function () {};
289291 $ preferred2 = function () {};
290292 $ list = $ this ->getMockBuilder ('Symfony\Component\Form\ChoiceList\ChoiceListInterface ' )->getMock ();
291- $ view1 = new \ stdClass ();
292- $ view2 = new \ stdClass ();
293+ $ view1 = new ChoiceListView ();
294+ $ view2 = new ChoiceListView ();
293295
294296 $ this ->decoratedFactory ->expects ($ this ->at (0 ))
295297 ->method ('createView ' )
@@ -308,7 +310,7 @@ public function testCreateViewSameLabelClosure()
308310 {
309311 $ labels = function () {};
310312 $ list = $ this ->getMockBuilder ('Symfony\Component\Form\ChoiceList\ChoiceListInterface ' )->getMock ();
311- $ view = new \ stdClass ();
313+ $ view = new ChoiceListView ();
312314
313315 $ this ->decoratedFactory ->expects ($ this ->once ())
314316 ->method ('createView ' )
@@ -324,8 +326,8 @@ public function testCreateViewDifferentLabelClosure()
324326 $ labels1 = function () {};
325327 $ labels2 = function () {};
326328 $ list = $ this ->getMockBuilder ('Symfony\Component\Form\ChoiceList\ChoiceListInterface ' )->getMock ();
327- $ view1 = new \ stdClass ();
328- $ view2 = new \ stdClass ();
329+ $ view1 = new ChoiceListView ();
330+ $ view2 = new ChoiceListView ();
329331
330332 $ this ->decoratedFactory ->expects ($ this ->at (0 ))
331333 ->method ('createView ' )
@@ -344,7 +346,7 @@ public function testCreateViewSameIndexClosure()
344346 {
345347 $ index = function () {};
346348 $ list = $ this ->getMockBuilder ('Symfony\Component\Form\ChoiceList\ChoiceListInterface ' )->getMock ();
347- $ view = new \ stdClass ();
349+ $ view = new ChoiceListView ();
348350
349351 $ this ->decoratedFactory ->expects ($ this ->once ())
350352 ->method ('createView ' )
@@ -360,8 +362,8 @@ public function testCreateViewDifferentIndexClosure()
360362 $ index1 = function () {};
361363 $ index2 = function () {};
362364 $ list = $ this ->getMockBuilder ('Symfony\Component\Form\ChoiceList\ChoiceListInterface ' )->getMock ();
363- $ view1 = new \ stdClass ();
364- $ view2 = new \ stdClass ();
365+ $ view1 = new ChoiceListView ();
366+ $ view2 = new ChoiceListView ();
365367
366368 $ this ->decoratedFactory ->expects ($ this ->at (0 ))
367369 ->method ('createView ' )
@@ -380,7 +382,7 @@ public function testCreateViewSameGroupByClosure()
380382 {
381383 $ groupBy = function () {};
382384 $ list = $ this ->getMockBuilder ('Symfony\Component\Form\ChoiceList\ChoiceListInterface ' )->getMock ();
383- $ view = new \ stdClass ();
385+ $ view = new ChoiceListView ();
384386
385387 $ this ->decoratedFactory ->expects ($ this ->once ())
386388 ->method ('createView ' )
@@ -396,8 +398,8 @@ public function testCreateViewDifferentGroupByClosure()
396398 $ groupBy1 = function () {};
397399 $ groupBy2 = function () {};
398400 $ list = $ this ->getMockBuilder ('Symfony\Component\Form\ChoiceList\ChoiceListInterface ' )->getMock ();
399- $ view1 = new \ stdClass ();
400- $ view2 = new \ stdClass ();
401+ $ view1 = new ChoiceListView ();
402+ $ view2 = new ChoiceListView ();
401403
402404 $ this ->decoratedFactory ->expects ($ this ->at (0 ))
403405 ->method ('createView ' )
@@ -416,7 +418,7 @@ public function testCreateViewSameAttributes()
416418 {
417419 $ attr = ['class ' => 'foobar ' ];
418420 $ list = $ this ->getMockBuilder ('Symfony\Component\Form\ChoiceList\ChoiceListInterface ' )->getMock ();
419- $ view = new \ stdClass ();
421+ $ view = new ChoiceListView ();
420422
421423 $ this ->decoratedFactory ->expects ($ this ->once ())
422424 ->method ('createView ' )
@@ -432,8 +434,8 @@ public function testCreateViewDifferentAttributes()
432434 $ attr1 = ['class ' => 'foobar1 ' ];
433435 $ attr2 = ['class ' => 'foobar2 ' ];
434436 $ list = $ this ->getMockBuilder ('Symfony\Component\Form\ChoiceList\ChoiceListInterface ' )->getMock ();
435- $ view1 = new \ stdClass ();
436- $ view2 = new \ stdClass ();
437+ $ view1 = new ChoiceListView ();
438+ $ view2 = new ChoiceListView ();
437439
438440 $ this ->decoratedFactory ->expects ($ this ->at (0 ))
439441 ->method ('createView ' )
@@ -452,7 +454,7 @@ public function testCreateViewSameAttributesClosure()
452454 {
453455 $ attr = function () {};
454456 $ list = $ this ->getMockBuilder ('Symfony\Component\Form\ChoiceList\ChoiceListInterface ' )->getMock ();
455- $ view = new \ stdClass ();
457+ $ view = new ChoiceListView ();
456458
457459 $ this ->decoratedFactory ->expects ($ this ->once ())
458460 ->method ('createView ' )
@@ -468,8 +470,8 @@ public function testCreateViewDifferentAttributesClosure()
468470 $ attr1 = function () {};
469471 $ attr2 = function () {};
470472 $ list = $ this ->getMockBuilder ('Symfony\Component\Form\ChoiceList\ChoiceListInterface ' )->getMock ();
471- $ view1 = new \ stdClass ();
472- $ view2 = new \ stdClass ();
473+ $ view1 = new ChoiceListView ();
474+ $ view2 = new ChoiceListView ();
473475
474476 $ this ->decoratedFactory ->expects ($ this ->at (0 ))
475477 ->method ('createView ' )
0 commit comments