99use PHPUnit \Framework \TestCase ;
1010use Symfony \Component \DependencyInjection \ServiceLocator ;
1111use Tests \Torr \SimpleNormalizer \Fixture \DummyVO ;
12+ use Tests \Torr \SimpleNormalizer \Fixture \DummyVONormalizer ;
1213use Torr \SimpleNormalizer \Exception \IncompleteNormalizationException ;
1314use Torr \SimpleNormalizer \Normalizer \SimpleNormalizer ;
14- use Torr \SimpleNormalizer \Normalizer \SimpleObjectNormalizerInterface ;
1515use Torr \SimpleNormalizer \Normalizer \Validator \ValidJsonVerifier ;
1616
1717/**
@@ -136,17 +136,7 @@ public function testWithoutEntityManager () : void
136136 $ locator ->expects (self ::once ())
137137 ->method ("get " )
138138 ->with (DummyVO::class)
139- ->willReturn (new readonly class implements SimpleObjectNormalizerInterface {
140- public function normalize (object $ value , array $ context , SimpleNormalizer $ normalizer ) : int
141- {
142- return 5 ;
143- }
144-
145- public static function getNormalizedType () : string
146- {
147- return DummyVO::class;
148- }
149- });
139+ ->willReturn (new DummyVONormalizer (5 ));
150140
151141 $ normalizer = new SimpleNormalizer (
152142 objectNormalizers: $ locator ,
@@ -176,17 +166,7 @@ public function testWithEntityManagerButNoMapping () : void
176166 $ locator ->expects (self ::once ())
177167 ->method ("get " )
178168 ->with (DummyVO::class)
179- ->willReturn (new readonly class implements SimpleObjectNormalizerInterface {
180- public function normalize (object $ value , array $ context , SimpleNormalizer $ normalizer ) : int
181- {
182- return 5 ;
183- }
184-
185- public static function getNormalizedType () : string
186- {
187- return DummyVO::class;
188- }
189- });
169+ ->willReturn (new DummyVONormalizer (5 ));
190170
191171 $ normalizer = new SimpleNormalizer (
192172 objectNormalizers: $ locator ,
@@ -225,17 +205,7 @@ public function testWithEntityManagerWithMapping () : void
225205 $ locator ->expects (self ::once ())
226206 ->method ("get " )
227207 ->with ("SomeClass " )
228- ->willReturn (new readonly class implements SimpleObjectNormalizerInterface {
229- public function normalize (object $ value , array $ context , SimpleNormalizer $ normalizer ) : int
230- {
231- return 5 ;
232- }
233-
234- public static function getNormalizedType () : string
235- {
236- return DummyVO::class;
237- }
238- });
208+ ->willReturn (new DummyVONormalizer (5 ));
239209
240210 $ normalizer = new SimpleNormalizer (
241211 objectNormalizers: $ locator ,
@@ -253,21 +223,7 @@ public static function getNormalizedType () : string
253223 private function createNormalizerObjectNormalizers (mixed $ returnValue ) : ServiceLocator
254224 {
255225 return new ServiceLocator ([
256- DummyVO::class => static fn () => new readonly class ($ returnValue ) implements SimpleObjectNormalizerInterface {
257- public function __construct (
258- private mixed $ returnValue ,
259- ) {}
260-
261- public function normalize (object $ value , array $ context , SimpleNormalizer $ normalizer ) : mixed
262- {
263- return $ this ->returnValue ;
264- }
265-
266- public static function getNormalizedType () : string
267- {
268- return DummyVO::class;
269- }
270- },
226+ DummyVO::class => static fn () => new DummyVONormalizer ($ returnValue ),
271227 ]);
272228 }
273229}
0 commit comments