@@ -120,4 +120,54 @@ public static function provideActionLabels(): iterable
120120 }];
121121 yield [t ('Edit ' )];
122122 }
123+
124+ public function testGetAsConfigObjectPreservesLinkToUrl (): void
125+ {
126+ $ action = Action::new ('my_action ' )
127+ ->linkToUrl ('https://example.com ' );
128+
129+ $ dto = $ action ->getAsDto ();
130+ $ restoredAction = $ dto ->getAsConfigObject ();
131+ $ restoredDto = $ restoredAction ->getAsDto ();
132+
133+ $ this ->assertSame ('https://example.com ' , $ restoredDto ->getUrl ());
134+ }
135+
136+ public function testGetAsConfigObjectPreservesCallableUrl (): void
137+ {
138+ $ callable = fn () => 'https://dynamic.example.com ' ;
139+ $ action = Action::new ('my_action ' )
140+ ->linkToUrl ($ callable );
141+
142+ $ dto = $ action ->getAsDto ();
143+ $ restoredAction = $ dto ->getAsConfigObject ();
144+ $ restoredDto = $ restoredAction ->getAsDto ();
145+
146+ $ this ->assertSame ($ callable , $ restoredDto ->getUrl ());
147+ }
148+
149+ public function testGetAsConfigObjectPreservesLinkToRoute (): void
150+ {
151+ $ action = Action::new ('my_action ' )
152+ ->linkToRoute ('my_route ' , ['param1 ' => 'value1 ' ]);
153+
154+ $ dto = $ action ->getAsDto ();
155+ $ restoredAction = $ dto ->getAsConfigObject ();
156+ $ restoredDto = $ restoredAction ->getAsDto ();
157+
158+ $ this ->assertSame ('my_route ' , $ restoredDto ->getRouteName ());
159+ $ this ->assertSame (['param1 ' => 'value1 ' ], $ restoredDto ->getRouteParameters ());
160+ }
161+
162+ public function testGetAsConfigObjectPreservesLinkToCrudAction (): void
163+ {
164+ $ action = Action::new ('my_action ' )
165+ ->linkToCrudAction ('edit ' );
166+
167+ $ dto = $ action ->getAsDto ();
168+ $ restoredAction = $ dto ->getAsConfigObject ();
169+ $ restoredDto = $ restoredAction ->getAsDto ();
170+
171+ $ this ->assertSame ('edit ' , $ restoredDto ->getCrudActionName ());
172+ }
123173}
0 commit comments