2222use Symfony \Component \Form \ChoiceList \Loader \FilterChoiceLoaderDecorator ;
2323use Symfony \Component \Form \ChoiceList \View \ChoiceListView ;
2424use Symfony \Component \Form \Extension \Core \Type \FormType ;
25+ use Symfony \Component \Form \Tests \ChoiceList \ChoiceListAssertionTrait ;
2526use Symfony \Component \Form \Tests \Fixtures \ArrayChoiceLoader ;
2627
2728/**
2829 * @author Bernhard Schussek <bschussek@gmail.com>
2930 */
3031class CachingFactoryDecoratorTest extends TestCase
3132{
33+ use ChoiceListAssertionTrait;
34+
3235 private CachingFactoryDecorator $ factory ;
3336
3437 protected function setUp (): void
@@ -42,8 +45,8 @@ public function testCreateFromChoicesEmpty()
4245 $ list2 = $ this ->factory ->createListFromChoices ([]);
4346
4447 $ this ->assertSame ($ list1 , $ list2 );
45- $ this -> assertEquals (new ArrayChoiceList ([]), $ list1 );
46- $ this -> assertEquals (new ArrayChoiceList ([]), $ list2 );
48+ self :: assertEqualsArrayChoiceList (new ArrayChoiceList ([]), $ list1 );
49+ self :: assertEqualsArrayChoiceList (new ArrayChoiceList ([]), $ list2 );
4750 }
4851
4952 public function testCreateFromChoicesComparesTraversableChoicesAsArray ()
@@ -56,8 +59,8 @@ public function testCreateFromChoicesComparesTraversableChoicesAsArray()
5659 $ list2 = $ this ->factory ->createListFromChoices ($ choices2 );
5760
5861 $ this ->assertSame ($ list1 , $ list2 );
59- $ this -> assertEquals (new ArrayChoiceList (['A ' => 'a ' ]), $ list1 );
60- $ this -> assertEquals (new ArrayChoiceList (['A ' => 'a ' ]), $ list2 );
62+ self :: assertEqualsArrayChoiceList (new ArrayChoiceList (['A ' => 'a ' ]), $ list1 );
63+ self :: assertEqualsArrayChoiceList (new ArrayChoiceList (['A ' => 'a ' ]), $ list2 );
6164 }
6265
6366 public function testCreateFromChoicesGroupedChoices ()
@@ -68,8 +71,8 @@ public function testCreateFromChoicesGroupedChoices()
6871 $ list2 = $ this ->factory ->createListFromChoices ($ choices2 );
6972
7073 $ this ->assertNotSame ($ list1 , $ list2 );
71- $ this -> assertEquals (new ArrayChoiceList (['key ' => ['A ' => 'a ' ]]), $ list1 );
72- $ this -> assertEquals (new ArrayChoiceList (['A ' => 'a ' ]), $ list2 );
74+ self :: assertEqualsArrayChoiceList (new ArrayChoiceList (['key ' => ['A ' => 'a ' ]]), $ list1 );
75+ self :: assertEqualsArrayChoiceList (new ArrayChoiceList (['A ' => 'a ' ]), $ list2 );
7376 }
7477
7578 #[DataProvider('provideSameChoices ' )]
@@ -79,8 +82,8 @@ public function testCreateFromChoicesSameChoices($choice1, $choice2)
7982 $ list2 = $ this ->factory ->createListFromChoices ([$ choice2 ]);
8083
8184 $ this ->assertSame ($ list1 , $ list2 );
82- $ this -> assertEquals (new ArrayChoiceList ([$ choice1 ]), $ list1 );
83- $ this -> assertEquals (new ArrayChoiceList ([$ choice2 ]), $ list2 );
85+ self :: assertEqualsArrayChoiceList (new ArrayChoiceList ([$ choice1 ]), $ list1 );
86+ self :: assertEqualsArrayChoiceList (new ArrayChoiceList ([$ choice2 ]), $ list2 );
8487 }
8588
8689 #[DataProvider('provideDistinguishedChoices ' )]
@@ -90,8 +93,8 @@ public function testCreateFromChoicesDifferentChoices($choice1, $choice2)
9093 $ list2 = $ this ->factory ->createListFromChoices ([$ choice2 ]);
9194
9295 $ this ->assertNotSame ($ list1 , $ list2 );
93- $ this -> assertEquals (new ArrayChoiceList ([$ choice1 ]), $ list1 );
94- $ this -> assertEquals (new ArrayChoiceList ([$ choice2 ]), $ list2 );
96+ self :: assertEqualsArrayChoiceList (new ArrayChoiceList ([$ choice1 ]), $ list1 );
97+ self :: assertEqualsArrayChoiceList (new ArrayChoiceList ([$ choice2 ]), $ list2 );
9598 }
9699
97100 public function testCreateFromChoicesSameValueClosure ()
@@ -103,8 +106,8 @@ public function testCreateFromChoicesSameValueClosure()
103106 $ list2 = $ this ->factory ->createListFromChoices ($ choices , $ closure );
104107
105108 $ this ->assertNotSame ($ list1 , $ list2 );
106- $ this -> assertEquals (new ArrayChoiceList ($ choices , $ closure ), $ list1 );
107- $ this -> assertEquals (new ArrayChoiceList ($ choices , $ closure ), $ list2 );
109+ self :: assertEqualsArrayChoiceList (new ArrayChoiceList ($ choices , $ closure ), $ list1 );
110+ self :: assertEqualsArrayChoiceList (new ArrayChoiceList ($ choices , $ closure ), $ list2 );
108111 }
109112
110113 public function testCreateFromChoicesSameValueClosureUseCache ()
@@ -117,8 +120,8 @@ public function testCreateFromChoicesSameValueClosureUseCache()
117120 $ list2 = $ this ->factory ->createListFromChoices ($ choices , ChoiceList::value ($ formType , function () {}));
118121
119122 $ this ->assertSame ($ list1 , $ list2 );
120- $ this -> assertEquals (new ArrayChoiceList ($ choices , $ valueCallback ), $ list1 );
121- $ this -> assertEquals (new ArrayChoiceList ($ choices , function () {}), $ list2 );
123+ self :: assertEqualsArrayChoiceList (new ArrayChoiceList ($ choices , $ valueCallback ), $ list1 );
124+ self :: assertEqualsArrayChoiceList (new ArrayChoiceList ($ choices , function () {}), $ list2 );
122125 }
123126
124127 public function testCreateFromChoicesDifferentValueClosure ()
@@ -130,8 +133,8 @@ public function testCreateFromChoicesDifferentValueClosure()
130133 $ list2 = $ this ->factory ->createListFromChoices ($ choices , $ closure2 );
131134
132135 $ this ->assertNotSame ($ list1 , $ list2 );
133- $ this -> assertEquals (new ArrayChoiceList ($ choices , $ closure1 ), $ list1 );
134- $ this -> assertEquals (new ArrayChoiceList ($ choices , $ closure2 ), $ list2 );
136+ self :: assertEqualsArrayChoiceList (new ArrayChoiceList ($ choices , $ closure1 ), $ list1 );
137+ self :: assertEqualsArrayChoiceList (new ArrayChoiceList ($ choices , $ closure2 ), $ list2 );
135138 }
136139
137140 public function testCreateFromChoicesSameFilterClosure ()
@@ -143,8 +146,8 @@ public function testCreateFromChoicesSameFilterClosure()
143146 $ lazyChoiceList = new LazyChoiceList (new FilterChoiceLoaderDecorator (new CallbackChoiceLoader (static fn () => $ choices ), $ filter ), null );
144147
145148 $ this ->assertNotSame ($ list1 , $ list2 );
146- $ this -> assertEquals ($ lazyChoiceList , $ list1 );
147- $ this -> assertEquals ($ lazyChoiceList , $ list2 );
149+ self :: assertEqualsLazyChoiceList ($ lazyChoiceList , $ list1 );
150+ self :: assertEqualsLazyChoiceList ($ lazyChoiceList , $ list2 );
148151 }
149152
150153 public function testCreateFromChoicesSameFilterClosureUseCache ()
@@ -157,8 +160,8 @@ public function testCreateFromChoicesSameFilterClosureUseCache()
157160 $ lazyChoiceList = new LazyChoiceList (new FilterChoiceLoaderDecorator (new CallbackChoiceLoader (static fn () => $ choices ), function () {}), null );
158161
159162 $ this ->assertSame ($ list1 , $ list2 );
160- $ this -> assertEquals ($ lazyChoiceList , $ list1 );
161- $ this -> assertEquals ($ lazyChoiceList , $ list2 );
163+ self :: assertEqualsLazyChoiceList ($ lazyChoiceList , $ list1 );
164+ self :: assertEqualsLazyChoiceList ($ lazyChoiceList , $ list2 );
162165 }
163166
164167 public function testCreateFromChoicesDifferentFilterClosure ()
@@ -171,8 +174,8 @@ public function testCreateFromChoicesDifferentFilterClosure()
171174 $ lazyChoiceList = new LazyChoiceList (new FilterChoiceLoaderDecorator (new CallbackChoiceLoader (static fn () => $ choices ), function () {}), null );
172175
173176 $ this ->assertNotSame ($ list1 , $ list2 );
174- $ this -> assertEquals ($ lazyChoiceList , $ list1 );
175- $ this -> assertEquals ($ lazyChoiceList , $ list2 );
177+ self :: assertEqualsLazyChoiceList ($ lazyChoiceList , $ list1 );
178+ self :: assertEqualsLazyChoiceList ($ lazyChoiceList , $ list2 );
176179 }
177180
178181 public function testCreateFromLoaderSameLoader ()
@@ -182,8 +185,8 @@ public function testCreateFromLoaderSameLoader()
182185 $ list2 = $ this ->factory ->createListFromLoader ($ loader );
183186
184187 $ this ->assertNotSame ($ list1 , $ list2 );
185- $ this -> assertEquals (new LazyChoiceList ($ loader ), $ list1 );
186- $ this -> assertEquals (new LazyChoiceList ($ loader ), $ list2 );
188+ self :: assertEqualsLazyChoiceList (new LazyChoiceList ($ loader ), $ list1 );
189+ self :: assertEqualsLazyChoiceList (new LazyChoiceList ($ loader ), $ list2 );
187190 }
188191
189192 public function testCreateFromLoaderSameLoaderUseCache ()
@@ -193,8 +196,8 @@ public function testCreateFromLoaderSameLoaderUseCache()
193196 $ list2 = $ this ->factory ->createListFromLoader (ChoiceList::loader ($ type , new ArrayChoiceLoader ()));
194197
195198 $ this ->assertSame ($ list1 , $ list2 );
196- $ this -> assertEquals (new LazyChoiceList (new ArrayChoiceLoader (), null ), $ list1 );
197- $ this -> assertEquals (new LazyChoiceList (new ArrayChoiceLoader (), null ), $ list2 );
199+ self :: assertEqualsLazyChoiceList (new LazyChoiceList (new ArrayChoiceLoader (), null ), $ list1 );
200+ self :: assertEqualsLazyChoiceList (new LazyChoiceList (new ArrayChoiceLoader (), null ), $ list2 );
198201 }
199202
200203 public function testCreateFromLoaderDifferentLoader ()
@@ -210,8 +213,8 @@ public function testCreateFromLoaderSameValueClosure()
210213 $ list2 = $ this ->factory ->createListFromLoader ($ loader , $ closure );
211214
212215 $ this ->assertNotSame ($ list1 , $ list2 );
213- $ this -> assertEquals (new LazyChoiceList ($ loader , $ closure ), $ list1 );
214- $ this -> assertEquals (new LazyChoiceList ($ loader , $ closure ), $ list2 );
216+ self :: assertEqualsLazyChoiceList (new LazyChoiceList ($ loader , $ closure ), $ list1 );
217+ self :: assertEqualsLazyChoiceList (new LazyChoiceList ($ loader , $ closure ), $ list2 );
215218 }
216219
217220 public function testCreateFromLoaderSameValueClosureUseCache ()
@@ -223,8 +226,8 @@ public function testCreateFromLoaderSameValueClosureUseCache()
223226 $ list2 = $ this ->factory ->createListFromLoader (ChoiceList::loader ($ type , new ArrayChoiceLoader ()), ChoiceList::value ($ type , function () {}));
224227
225228 $ this ->assertSame ($ list1 , $ list2 );
226- $ this -> assertEquals (new LazyChoiceList ($ loader , $ closure ), $ list1 );
227- $ this -> assertEquals (new LazyChoiceList (new ArrayChoiceLoader (), function () {}), $ list2 );
229+ self :: assertEqualsLazyChoiceList (new LazyChoiceList ($ loader , $ closure ), $ list1 );
230+ self :: assertEqualsLazyChoiceList (new LazyChoiceList (new ArrayChoiceLoader (), function () {}), $ list2 );
228231 }
229232
230233 public function testCreateFromLoaderDifferentValueClosure ()
@@ -246,8 +249,8 @@ public function testCreateFromLoaderSameFilterClosure()
246249 $ list2 = $ this ->factory ->createListFromLoader (ChoiceList::loader ($ type , new ArrayChoiceLoader ()), null , $ closure );
247250
248251 $ this ->assertNotSame ($ list1 , $ list2 );
249- $ this -> assertEquals (new LazyChoiceList (new FilterChoiceLoaderDecorator ($ loader , $ closure )), $ list1 );
250- $ this -> assertEquals (new LazyChoiceList (new FilterChoiceLoaderDecorator (new ArrayChoiceLoader (), $ closure )), $ list2 );
252+ self :: assertEqualsLazyChoiceList (new LazyChoiceList (new FilterChoiceLoaderDecorator ($ loader , $ closure )), $ list1 );
253+ self :: assertEqualsLazyChoiceList (new LazyChoiceList (new FilterChoiceLoaderDecorator (new ArrayChoiceLoader (), $ closure )), $ list2 );
251254 }
252255
253256 public function testCreateFromLoaderSameFilterClosureUseCache ()
@@ -258,8 +261,8 @@ public function testCreateFromLoaderSameFilterClosureUseCache()
258261 $ list2 = $ this ->factory ->createListFromLoader (ChoiceList::loader ($ type , new ArrayChoiceLoader ()), null , $ choiceFilter );
259262
260263 $ this ->assertSame ($ list1 , $ list2 );
261- $ this -> assertEquals (new LazyChoiceList (new FilterChoiceLoaderDecorator (new ArrayChoiceLoader (), function () {})), $ list1 );
262- $ this -> assertEquals (new LazyChoiceList (new FilterChoiceLoaderDecorator (new ArrayChoiceLoader (), function () {})), $ list2 );
264+ self :: assertEqualsLazyChoiceList (new LazyChoiceList (new FilterChoiceLoaderDecorator (new ArrayChoiceLoader (), function () {})), $ list1 );
265+ self :: assertEqualsLazyChoiceList (new LazyChoiceList (new FilterChoiceLoaderDecorator (new ArrayChoiceLoader (), function () {})), $ list2 );
263266 }
264267
265268 public function testCreateFromLoaderDifferentFilterClosure ()
@@ -271,8 +274,8 @@ public function testCreateFromLoaderDifferentFilterClosure()
271274 $ list2 = $ this ->factory ->createListFromLoader (ChoiceList::loader ($ type , new ArrayChoiceLoader ()), null , $ closure2 );
272275
273276 $ this ->assertNotSame ($ list1 , $ list2 );
274- $ this -> assertEquals (new LazyChoiceList (new FilterChoiceLoaderDecorator (new ArrayChoiceLoader (), $ closure1 ), null ), $ list1 );
275- $ this -> assertEquals (new LazyChoiceList (new FilterChoiceLoaderDecorator (new ArrayChoiceLoader (), $ closure2 ), null ), $ list2 );
277+ self :: assertEqualsLazyChoiceList (new LazyChoiceList (new FilterChoiceLoaderDecorator (new ArrayChoiceLoader (), $ closure1 ), null ), $ list1 );
278+ self :: assertEqualsLazyChoiceList (new LazyChoiceList (new FilterChoiceLoaderDecorator (new ArrayChoiceLoader (), $ closure2 ), null ), $ list2 );
276279 }
277280
278281 public function testCreateViewSamePreferredChoices ()
0 commit comments