20
20
use Symfony \UX \LiveComponent \Tests \Fixtures \Entity \Entity1 ;
21
21
use Symfony \UX \TwigComponent \ComponentAttributes ;
22
22
use Symfony \UX \TwigComponent \ComponentFactory ;
23
- use Symfony \UX \TwigComponent \ComponentMetadata ;
24
23
use Symfony \UX \TwigComponent \MountedComponent ;
25
24
use function Zenstruck \Foundry \create ;
26
25
use Zenstruck \Foundry \Test \Factories ;
@@ -67,7 +66,7 @@ public function testCanDehydrateAndHydrateLiveComponent(): void
67
66
68
67
$ component = $ factory ->get ('component1 ' );
69
68
70
- $ hydrator ->hydrate ($ component , $ dehydrated , $ mounted ->getMetadata ());
69
+ $ hydrator ->hydrate ($ component , $ dehydrated , $ mounted ->getName ());
71
70
72
71
$ this ->assertSame ($ prop1 ->id , $ component ->prop1 ->id );
73
72
$ this ->assertSame ($ prop2 ->format ('c ' ), $ component ->prop2 ->format ('c ' ));
@@ -94,7 +93,7 @@ public function testCanModifyWritableProps(): void
94
93
95
94
$ component = $ factory ->get ('component1 ' );
96
95
97
- $ hydrator ->hydrate ($ component , $ dehydrated , $ mounted ->getMetadata ());
96
+ $ hydrator ->hydrate ($ component , $ dehydrated , $ mounted ->getName ());
98
97
99
98
$ this ->assertSame ('new value ' , $ component ->prop3 );
100
99
}
@@ -119,7 +118,7 @@ public function testCannotModifyReadonlyProps(): void
119
118
$ component = $ factory ->get ('component1 ' );
120
119
121
120
$ this ->expectException (\RuntimeException::class);
122
- $ hydrator ->hydrate ($ component , $ dehydrated , $ mounted ->getMetadata ());
121
+ $ hydrator ->hydrate ($ component , $ dehydrated , $ mounted ->getName ());
123
122
}
124
123
125
124
public function testHydrationFailsIfChecksumMissing (): void
@@ -131,7 +130,7 @@ public function testHydrationFailsIfChecksumMissing(): void
131
130
$ factory = self ::getContainer ()->get ('ux.twig_component.component_factory ' );
132
131
133
132
$ this ->expectException (\RuntimeException::class);
134
- $ hydrator ->hydrate ($ factory ->get ('component1 ' ), [], $ factory -> metadataFor ( 'component1 ' ) );
133
+ $ hydrator ->hydrate ($ factory ->get ('component1 ' ), [], 'component1 ' );
135
134
}
136
135
137
136
public function testHydrationFailsOnChecksumMismatch (): void
@@ -143,7 +142,7 @@ public function testHydrationFailsOnChecksumMismatch(): void
143
142
$ factory = self ::getContainer ()->get ('ux.twig_component.component_factory ' );
144
143
145
144
$ this ->expectException (\RuntimeException::class);
146
- $ hydrator ->hydrate ($ factory ->get ('component1 ' ), ['_checksum ' => 'invalid ' ], $ factory -> metadataFor ( 'component1 ' ) );
145
+ $ hydrator ->hydrate ($ factory ->get ('component1 ' ), ['_checksum ' => 'invalid ' ], 'component1 ' );
147
146
}
148
147
149
148
public function testPreDehydrateAndPostHydrateHooksCalled (): void
@@ -173,7 +172,7 @@ public function testPreDehydrateAndPostHydrateHooksCalled(): void
173
172
$ this ->assertFalse ($ component ->preDehydrateCalled );
174
173
$ this ->assertFalse ($ component ->postHydrateCalled );
175
174
176
- $ hydrator ->hydrate ($ component , $ data , $ mounted ->getMetadata ());
175
+ $ hydrator ->hydrate ($ component , $ data , $ mounted ->getName ());
177
176
178
177
$ this ->assertFalse ($ component ->preDehydrateCalled );
179
178
$ this ->assertTrue ($ component ->postHydrateCalled );
@@ -208,7 +207,7 @@ public function testDeletingEntityBetweenDehydrationAndHydrationSetsItToNull():
208
207
/** @var Component1 $component */
209
208
$ component = $ factory ->get ('component1 ' );
210
209
211
- $ mounted = $ hydrator ->hydrate ($ component , $ data , $ mounted ->getMetadata ());
210
+ $ mounted = $ hydrator ->hydrate ($ component , $ data , $ mounted ->getName ());
212
211
213
212
$ this ->assertNull ($ component ->prop1 );
214
213
@@ -242,7 +241,7 @@ public function testCorrectlyUsesCustomFrontendNameInDehydrateAndHydrate(): void
242
241
/** @var Component3 $component */
243
242
$ component = $ factory ->get ('component3 ' );
244
243
245
- $ hydrator ->hydrate ($ component , $ dehydrated , $ mounted ->getMetadata ());
244
+ $ hydrator ->hydrate ($ component , $ dehydrated , $ mounted ->getName ());
246
245
247
246
$ this ->assertSame ('value1 ' , $ component ->prop1 );
248
247
$ this ->assertSame ('value2 ' , $ component ->prop2 );
@@ -261,14 +260,14 @@ public function testCanDehydrateAndHydrateArrays(): void
261
260
$ instance = clone $ component ;
262
261
$ instance ->prop = ['some ' , 'array ' ];
263
262
264
- $ dehydrated = $ hydrator ->dehydrate (new MountedComponent ($ instance , new ComponentAttributes ([]), new ComponentMetadata ([])));
263
+ $ dehydrated = $ hydrator ->dehydrate (new MountedComponent (' my_component ' , $ instance , new ComponentAttributes ([])));
265
264
266
265
$ this ->assertArrayHasKey ('prop ' , $ dehydrated );
267
266
$ this ->assertSame ($ instance ->prop , $ dehydrated ['prop ' ]);
268
267
269
268
$ this ->assertFalse (isset ($ component ->prop ));
270
269
271
- $ hydrator ->hydrate ($ component , $ dehydrated , new ComponentMetadata ([]) );
270
+ $ hydrator ->hydrate ($ component , $ dehydrated , ' my_component ' );
272
271
273
272
$ this ->assertSame ($ instance ->prop , $ component ->prop );
274
273
}
@@ -290,7 +289,7 @@ public function testCanDehydrateAndHydrateComponentsWithAttributes(): void
290
289
$ this ->assertArrayHasKey ('_attributes ' , $ dehydrated );
291
290
$ this ->assertSame ($ attributes , $ dehydrated ['_attributes ' ]);
292
291
293
- $ mounted = $ hydrator ->hydrate ($ factory ->get ('with_attributes ' ), $ dehydrated , $ mounted ->getMetadata ());
292
+ $ mounted = $ hydrator ->hydrate ($ factory ->get ('with_attributes ' ), $ dehydrated , $ mounted ->getName ());
294
293
295
294
$ this ->assertSame ($ attributes , $ mounted ->getAttributes ()->all ());
296
295
}
@@ -311,7 +310,7 @@ public function testCanDehydrateAndHydrateComponentsWithEmptyAttributes(): void
311
310
312
311
$ this ->assertArrayNotHasKey ('_attributes ' , $ dehydrated );
313
312
314
- $ mounted = $ hydrator ->hydrate ($ factory ->get ('with_attributes ' ), $ dehydrated , $ mounted ->getMetadata ());
313
+ $ mounted = $ hydrator ->hydrate ($ factory ->get ('with_attributes ' ), $ dehydrated , $ mounted ->getName ());
315
314
316
315
$ this ->assertSame ([], $ mounted ->getAttributes ()->all ());
317
316
}
0 commit comments