13
13
14
14
use PHPUnit \Framework \MockObject \MockObject ;
15
15
use PHPUnit \Framework \TestCase ;
16
+ use Symfony \Component \Form \ChoiceList \ArrayChoiceList ;
16
17
use Symfony \Component \Form \ChoiceList \Factory \CachingFactoryDecorator ;
18
+ use Symfony \Component \Form \ChoiceList \View \ChoiceListView ;
17
19
18
20
/**
19
21
* @author Bernhard Schussek <bschussek@gmail.com>
@@ -38,7 +40,7 @@ protected function setUp()
38
40
39
41
public function testCreateFromChoicesEmpty ()
40
42
{
41
- $ list = new \ stdClass ( );
43
+ $ list = new ArrayChoiceList ([] );
42
44
43
45
$ this ->decoratedFactory ->expects ($ this ->once ())
44
46
->method ('createListFromChoices ' )
@@ -54,7 +56,7 @@ public function testCreateFromChoicesComparesTraversableChoicesAsArray()
54
56
// The top-most traversable is converted to an array
55
57
$ choices1 = new \ArrayIterator (['A ' => 'a ' ]);
56
58
$ choices2 = ['A ' => 'a ' ];
57
- $ list = new \ stdClass ( );
59
+ $ list = new ArrayChoiceList ([] );
58
60
59
61
$ this ->decoratedFactory ->expects ($ this ->once ())
60
62
->method ('createListFromChoices ' )
@@ -69,8 +71,8 @@ public function testCreateFromChoicesGroupedChoices()
69
71
{
70
72
$ choices1 = ['key ' => ['A ' => 'a ' ]];
71
73
$ choices2 = ['A ' => 'a ' ];
72
- $ list1 = new \ stdClass ( );
73
- $ list2 = new \ stdClass ( );
74
+ $ list1 = new ArrayChoiceList ([] );
75
+ $ list2 = new ArrayChoiceList ([] );
74
76
75
77
$ this ->decoratedFactory ->expects ($ this ->at (0 ))
76
78
->method ('createListFromChoices ' )
@@ -92,7 +94,7 @@ public function testCreateFromChoicesSameChoices($choice1, $choice2)
92
94
{
93
95
$ choices1 = [$ choice1 ];
94
96
$ choices2 = [$ choice2 ];
95
- $ list = new \ stdClass ( );
97
+ $ list = new ArrayChoiceList ([] );
96
98
97
99
$ this ->decoratedFactory ->expects ($ this ->once ())
98
100
->method ('createListFromChoices ' )
@@ -110,8 +112,8 @@ public function testCreateFromChoicesDifferentChoices($choice1, $choice2)
110
112
{
111
113
$ choices1 = [$ choice1 ];
112
114
$ choices2 = [$ choice2 ];
113
- $ list1 = new \ stdClass ( );
114
- $ list2 = new \ stdClass ( );
115
+ $ list1 = new ArrayChoiceList ([] );
116
+ $ list2 = new ArrayChoiceList ([] );
115
117
116
118
$ this ->decoratedFactory ->expects ($ this ->at (0 ))
117
119
->method ('createListFromChoices ' )
@@ -129,7 +131,7 @@ public function testCreateFromChoicesDifferentChoices($choice1, $choice2)
129
131
public function testCreateFromChoicesSameValueClosure ()
130
132
{
131
133
$ choices = [1 ];
132
- $ list = new \ stdClass ( );
134
+ $ list = new ArrayChoiceList ([] );
133
135
$ closure = function () {};
134
136
135
137
$ this ->decoratedFactory ->expects ($ this ->once ())
@@ -144,8 +146,8 @@ public function testCreateFromChoicesSameValueClosure()
144
146
public function testCreateFromChoicesDifferentValueClosure ()
145
147
{
146
148
$ choices = [1 ];
147
- $ list1 = new \ stdClass ( );
148
- $ list2 = new \ stdClass ( );
149
+ $ list1 = new ArrayChoiceList ([] );
150
+ $ list2 = new ArrayChoiceList ([] );
149
151
$ closure1 = function () {};
150
152
$ closure2 = function () {};
151
153
@@ -165,7 +167,7 @@ public function testCreateFromChoicesDifferentValueClosure()
165
167
public function testCreateFromLoaderSameLoader ()
166
168
{
167
169
$ loader = $ this ->getMockBuilder ('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface ' )->getMock ();
168
- $ list = new \ stdClass ( );
170
+ $ list = new ArrayChoiceList ([] );
169
171
170
172
$ this ->decoratedFactory ->expects ($ this ->once ())
171
173
->method ('createListFromLoader ' )
@@ -180,8 +182,8 @@ public function testCreateFromLoaderDifferentLoader()
180
182
{
181
183
$ loader1 = $ this ->getMockBuilder ('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface ' )->getMock ();
182
184
$ 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 ([] );
185
187
186
188
$ this ->decoratedFactory ->expects ($ this ->at (0 ))
187
189
->method ('createListFromLoader ' )
@@ -199,7 +201,7 @@ public function testCreateFromLoaderDifferentLoader()
199
201
public function testCreateFromLoaderSameValueClosure ()
200
202
{
201
203
$ loader = $ this ->getMockBuilder ('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface ' )->getMock ();
202
- $ list = new \ stdClass ( );
204
+ $ list = new ArrayChoiceList ([] );
203
205
$ closure = function () {};
204
206
205
207
$ this ->decoratedFactory ->expects ($ this ->once ())
@@ -214,8 +216,8 @@ public function testCreateFromLoaderSameValueClosure()
214
216
public function testCreateFromLoaderDifferentValueClosure ()
215
217
{
216
218
$ 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 ([] );
219
221
$ closure1 = function () {};
220
222
$ closure2 = function () {};
221
223
@@ -236,7 +238,7 @@ public function testCreateViewSamePreferredChoices()
236
238
{
237
239
$ preferred = ['a ' ];
238
240
$ list = $ this ->getMockBuilder ('Symfony\Component\Form\ChoiceList\ChoiceListInterface ' )->getMock ();
239
- $ view = new \ stdClass ();
241
+ $ view = new ChoiceListView ();
240
242
241
243
$ this ->decoratedFactory ->expects ($ this ->once ())
242
244
->method ('createView ' )
@@ -252,8 +254,8 @@ public function testCreateViewDifferentPreferredChoices()
252
254
$ preferred1 = ['a ' ];
253
255
$ preferred2 = ['b ' ];
254
256
$ 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 ();
257
259
258
260
$ this ->decoratedFactory ->expects ($ this ->at (0 ))
259
261
->method ('createView ' )
@@ -272,7 +274,7 @@ public function testCreateViewSamePreferredChoicesClosure()
272
274
{
273
275
$ preferred = function () {};
274
276
$ list = $ this ->getMockBuilder ('Symfony\Component\Form\ChoiceList\ChoiceListInterface ' )->getMock ();
275
- $ view = new \ stdClass ();
277
+ $ view = new ChoiceListView ();
276
278
277
279
$ this ->decoratedFactory ->expects ($ this ->once ())
278
280
->method ('createView ' )
@@ -288,8 +290,8 @@ public function testCreateViewDifferentPreferredChoicesClosure()
288
290
$ preferred1 = function () {};
289
291
$ preferred2 = function () {};
290
292
$ 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 ();
293
295
<
48DA
/code>
294
296
$ this ->decoratedFactory ->expects ($ this ->at (0 ))
295
297
->method ('createView ' )
@@ -308,7 +310,7 @@ public function testCreateViewSameLabelClosure()
308
310
{
309
311
$ labels = function () {};
310
312
$ list = $ this ->getMockBuilder ('Symfony\Component\Form\ChoiceList\ChoiceListInterface ' )->getMock ();
311
- $ view = new \ stdClass ();
313
+ $ view = new ChoiceListView ();
312
314
313
315
$ this ->decoratedFactory ->expects ($ this ->once ())
314
316
->method ('createView ' )
@@ -324,8 +326,8 @@ public function testCreateViewDifferentLabelClosure()
324
326
$ labels1 = function () {};
325
327
$ labels2 = function () {};
326
328
$ 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 ();
329
331
330
332
$ this ->decoratedFactory ->expects ($ this ->at (0 ))
331
333
->method ('createView ' )
@@ -344,7 +346,7 @@ public function testCreateViewSameIndexClosure()
344
346
{
345
347
$ index = function () {};
346
348
$ list = $ this ->getMockBuilder ('Symfony\Component\Form\ChoiceList\ChoiceListInterface ' )->getMock ();
347
- $ view = new \ stdClass ();
349
+ $ view = new ChoiceListView ();
348
350
349
351
$ this ->decoratedFactory ->expects ($ this ->once ())
350
352
->method ('createView ' )
@@ -360,8 +362,8 @@ public function testCreateViewDifferentIndexClosure()
360
362
$ index1 = function () {};
361
363
$ index2 = function () {};
362
364
$ 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 ();
365
367
366
368
$ this ->decoratedFactory ->expects ($ this ->at (0 ))
367
369
->method ('createView ' )
@@ -380,7 +382,7 @@ public function testCreateViewSameGroupByClosure()
380
382
{
381
383
$ groupBy = function () {};
382
384
$ list = $ this ->getMockBuilder ('Symfony\Component\Form\ChoiceList\ChoiceListInterface ' )->getMock ();
383
- $ view = new \ stdClass ();
385
+ $ view = new ChoiceListView ();
384
386
385
387
$ this ->decoratedFactory ->expects ($ this ->once ())
386
388
->method ('createView ' )
@@ -396,8 +398,8 @@ public function testCreateViewDifferentGroupByClosure()
396
398
$ groupBy1 = function () {};
397
399
$ groupBy2 = function () {};
398
400
$ 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 ();
401
403
402
404
$ this ->decoratedFactory ->expects ($ this ->at (0 ))
403
405
->method ('createView ' )
@@ -416,7 +418,7 @@ public function testCreateViewSameAttributes()
416
418
{
417
419
$ attr = ['class ' => 'foobar ' ];
418
420
$ list = $ this ->getMockBuilder ('Symfony\Component\Form\ChoiceList\ChoiceListInterface ' )->getMock ();
419
- $ view = new \ stdClass ();
421
+ $ view = new ChoiceListView ();
420
422
421
423
$ this ->decoratedFactory ->expects ($ this ->once ())
422
424
->method ('createView ' )
@@ -432,8 +434,8 @@ public function testCreateViewDifferentAttributes()
432
434
$ attr1 = ['class ' => 'foobar1 ' ];
433
435
$ attr2 = ['class ' => 'foobar2 ' ];
434
436
$ 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 ();
437
439
438
440
$ this ->decoratedFactory ->expects ($ this ->at (0 ))
439
441
->method ('createView ' )
@@ -452,7 +454,7 @@ public function testCreateViewSameAttributesClosure()
452
454
{
453
455
$ attr = function () {};
454
456
$ list = $ this ->getMockBuilder ('Symfony\Component\Form\ChoiceList\ChoiceListInterface ' )->getMock ();
455
- $ view = new \ stdClass ();
457
+ $ view = new ChoiceListView ();
456
458
457
459
$ this ->decoratedFactory ->expects ($ this ->once ())
458
460
->method ('createView ' )
@@ -468,8 +470,8 @@ public function testCreateViewDifferentAttributesClosure()
468
470
$ attr1 = function () {};
469
471
$ attr2 = function () {};
470
472
$ 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 ();
473
475
474
476
$ this ->decoratedFactory ->expects ($ this ->at (0 ))
475
477
->method ('createView ' )
0 commit comments