2020use Symfony \UX \LiveComponent \Tests \Fixtures \Entity \Entity1 ;
2121use Symfony \UX \TwigComponent \ComponentAttributes ;
2222use Symfony \UX \TwigComponent \ComponentFactory ;
23- use Symfony \UX \TwigComponent \ComponentMetadata ;
2423use Symfony \UX \TwigComponent \MountedComponent ;
2524use function Zenstruck \Foundry \create ;
2625use Zenstruck \Foundry \Test \Factories ;
@@ -67,7 +66,7 @@ public function testCanDehydrateAndHydrateLiveComponent(): void
6766
6867 $ component = $ factory ->get ('component1 ' );
6968
70- $ hydrator ->hydrate ($ component , $ dehydrated , $ mounted ->getMetadata ());
69+ $ hydrator ->hydrate ($ component , $ dehydrated , $ mounted ->getName ());
7170
7271 $ this ->assertSame ($ prop1 ->id , $ component ->prop1 ->id );
7372 $ this ->assertSame ($ prop2 ->format ('c ' ), $ component ->prop2 ->format ('c ' ));
@@ -94,7 +93,7 @@ public function testCanModifyWritableProps(): void
9493
9594 $ component = $ factory ->get ('component1 ' );
9695
97- $ hydrator ->hydrate ($ component , $ dehydrated , $ mounted ->getMetadata ());
96+ $ hydrator ->hydrate ($ component , $ dehydrated , $ mounted ->getName ());
9897
9998 $ this ->assertSame ('new value ' , $ component ->prop3 );
10099 }
@@ -119,7 +118,7 @@ public function testCannotModifyReadonlyProps(): void
119118 $ component = $ factory ->get ('component1 ' );
120119
121120 $ this ->expectException (\RuntimeException::class);
122- $ hydrator ->hydrate ($ component , $ dehydrated , $ mounted ->getMetadata ());
121+ $ hydrator ->hydrate ($ component , $ dehydrated , $ mounted ->getName ());
123122 }
124123
125124 public function testHydrationFailsIfChecksumMissing (): void
@@ -131,7 +130,7 @@ public function testHydrationFailsIfChecksumMissing(): void
131130 $ factory = self ::getContainer ()->get ('ux.twig_component.component_factory ' );
132131
133132 $ this ->expectException (\RuntimeException::class);
134- $ hydrator ->hydrate ($ factory ->get ('component1 ' ), [], $ factory -> metadataFor ( 'component1 ' ) );
133+ $ hydrator ->hydrate ($ factory ->get ('component1 ' ), [], 'component1 ' );
135134 }
136135
137136 public function testHydrationFailsOnChecksumMismatch (): void
@@ -143,7 +142,7 @@ public function testHydrationFailsOnChecksumMismatch(): void
143142 $ factory = self ::getContainer ()->get ('ux.twig_component.component_factory ' );
144143
145144 $ this ->expectException (\RuntimeException::class);
146- $ hydrator ->hydrate ($ factory ->get ('component1 ' ), ['_checksum ' => 'invalid ' ], $ factory -> metadataFor ( 'component1 ' ) );
145+ $ hydrator ->hydrate ($ factory ->get ('component1 ' ), ['_checksum ' => 'invalid ' ], 'component1 ' );
147146 }
148147
149148 public function testPreDehydrateAndPostHydrateHooksCalled (): void
@@ -173,7 +172,7 @@ public function testPreDehydrateAndPostHydrateHooksCalled(): void
173172 $ this ->assertFalse ($ component ->preDehydrateCalled );
174173 $ this ->assertFalse ($ component ->postHydrateCalled );
175174
176- $ hydrator ->hydrate ($ component , $ data , $ mounted ->getMetadata ());
175+ $ hydrator ->hydrate ($ component , $ data , $ mounted ->getName ());
177176
178177 $ this ->assertFalse ($ component ->preDehydrateCalled );
179178 $ this ->assertTrue ($ component ->postHydrateCalled );
@@ -208,7 +207,7 @@ public function testDeletingEntityBetweenDehydrationAndHydrationSetsItToNull():
208207 /** @var Component1 $component */
209208 $ component = $ factory ->get ('component1 ' );
210209
211- $ mounted = $ hydrator ->hydrate ($ component , $ data , $ mounted ->getMetadata ());
210+ $ mounted = $ hydrator ->hydrate ($ component , $ data , $ mounted ->getName ());
212211
213212 $ this ->assertNull ($ component ->prop1 );
214213
@@ -242,7 +241,7 @@ public function testCorrectlyUsesCustomFrontendNameInDehydrateAndHydrate(): void
242241 /** @var Component3 $component */
243242 $ component = $ factory ->get ('component3 ' );
244243
245- $ hydrator ->hydrate ($ component , $ dehydrated , $ mounted ->getMetadata ());
244+ $ hydrator ->hydrate ($ component , $ dehydrated , $ mounted ->getName ());
246245
247246 $ this ->assertSame ('value1 ' , $ component ->prop1 );
248247 $ this ->assertSame ('value2 ' , $ component ->prop2 );
@@ -261,14 +260,14 @@ public function testCanDehydrateAndHydrateArrays(): void
261260 $ instance = clone $ component ;
262261 $ instance ->prop = ['some ' , 'array ' ];
263262
264- $ dehydrated = $ hydrator ->dehydrate (new MountedComponent ($ instance , new ComponentAttributes ([]), new ComponentMetadata ([])));
263+ $ dehydrated = $ hydrator ->dehydrate (new MountedComponent (' my_component ' , $ instance , new ComponentAttributes ([])));
265264
266265 $ this ->assertArrayHasKey ('prop ' , $ dehydrated );
267266 $ this ->assertSame ($ instance ->prop , $ dehydrated ['prop ' ]);
268267
269268 $ this ->assertFalse (isset ($ component ->prop ));
270269
271- $ hydrator ->hydrate ($ component , $ dehydrated , new ComponentMetadata ([]) );
270+ $ hydrator ->hydrate ($ component , $ dehydrated , ' my_component ' );
272271
273272 $ this ->assertSame ($ instance ->prop , $ component ->prop );
274273 }
@@ -290,7 +289,7 @@ public function testCanDehydrateAndHydrateComponentsWithAttributes(): void
290289 $ this ->assertArrayHasKey ('_attributes ' , $ dehydrated );
291290 $ this ->assertSame ($ attributes , $ dehydrated ['_attributes ' ]);
292291
293- $ mounted = $ hydrator ->hydrate ($ factory ->get ('with_attributes ' ), $ dehydrated , $ mounted ->getMetadata ());
292+ $ mounted = $ hydrator ->hydrate ($ factory ->get ('with_attributes ' ), $ dehydrated , $ mounted ->getName ());
294293
295294 $ this ->assertSame ($ attributes , $ mounted ->getAttributes ()->all ());
296295 }
@@ -311,7 +310,7 @@ public function testCanDehydrateAndHydrateComponentsWithEmptyAttributes(): void
311310
312311 $ this ->assertArrayNotHasKey ('_attributes ' , $ dehydrated );
313312
314- $ mounted = $ hydrator ->hydrate ($ factory ->get ('with_attributes ' ), $ dehydrated , $ mounted ->getMetadata ());
313+ $ mounted = $ hydrator ->hydrate ($ factory ->get ('with_attributes ' ), $ dehydrated , $ mounted ->getName ());
315314
316315 $ this ->assertSame ([], $ mounted ->getAttributes ()->all ());
317316 }
0 commit comments