@@ -106,7 +106,7 @@ public function provideDataWithFieldValueToSerialize(): iterable
106106 ];
107107 }
108108
109- public function testSerializeFieldValueWithProcessor ()
109+ public function testSerializeFieldValueWithProcessor (): void
110110 {
111111 $ serializer = $ this ->getFieldTypeSerializer ();
112112
@@ -154,19 +154,15 @@ static function () use ($fieldTypeMock) {
154154 );
155155 }
156156
157- public function testSerializeFieldDefaultValue ()
157+ public function testSerializeFieldDefaultValue (): void
158158 {
159159 $ serializer = $ this ->getFieldTypeSerializer ();
160160
161161 $ fieldTypeMock = $ this ->getFieldTypeMock ();
162- $ this ->getFieldTypeServiceMock ()->expects ($ this ->once ())
163- ->method ('getFieldType ' )
164- ->with ($ this ->equalTo ('myFancyFieldType ' ))
165- ->willReturnCallback (
166- static function () use ($ fieldTypeMock ) {
167- return $ fieldTypeMock ;
168- }
169- );
162+ $ this ->mockFieldTypeServiceGetFieldType (
163+ 'myFancyFieldType ' ,
164+ $ fieldTypeMock
165+ );
170166
171167 $ fieldTypeMock ->expects ($ this ->once ())
172168 ->method ('toHash ' )
@@ -183,19 +179,15 @@ static function () use ($fieldTypeMock) {
183179 );
184180 }
185181
186- public function testSerializeFieldSettings ()
182+ public function testSerializeFieldSettings (): void
187183 {
188184 $ serializer = $ this ->getFieldTypeSerializer ();
189185
190186 $ fieldTypeMock = $ this ->getFieldTypeMock ();
191- $ this ->getFieldTypeServiceMock ()->expects ($ this ->once ())
192- ->method ('getFieldType ' )
193- ->with ($ this ->equalTo ('myFancyFieldType ' ))
194- ->willReturnCallback (
195- static function () use ($ fieldTypeMock ) {
196- return $ fieldTypeMock ;
197- }
198- );
187+ $ this ->mockFieldTypeServiceGetFieldType (
188+ 'myFancyFieldType ' ,
189+ $ fieldTypeMock
190+ );
199191
200192 $ fieldTypeMock ->expects ($ this ->once ())
201193 ->method ('fieldSettingsToHash ' )
@@ -212,7 +204,7 @@ static function () use ($fieldTypeMock) {
212204 );
213205 }
214206
215- public function testSerializeFieldSettingsWithPostProcessing ()
207+ public function testSerializeFieldSettingsWithPostProcessing (): void
216208 {
217209 $ serializer = $ this ->getFieldTypeSerializer ();
218210 $ fieldTypeMock = $ this ->getFieldTypeMock ();
@@ -237,14 +229,10 @@ static function () use ($processorMock) {
237229 ->with ($ this ->equalTo (['foo ' => 'bar ' ]))
238230 ->willReturn (['post-processed ' ]);
239231
240- $ this ->getFieldTypeServiceMock ()->expects ($ this ->once ())
241- ->method ('getFieldType ' )
242- ->with ($ this ->equalTo ('myFancyFieldType ' ))
243- ->willReturnCallback (
244- static function () use ($ fieldTypeMock ) {
245- return $ fieldTypeMock ;
246- }
247- );
232+ $ this ->mockFieldTypeServiceGetFieldType (
233+ 'myFancyFieldType ' ,
234+ $ fieldTypeMock
235+ );
248236
249237 $ fieldTypeMock ->expects ($ this ->once ())
250238 ->method ('fieldSettingsToHash ' )
@@ -261,19 +249,15 @@ static function () use ($fieldTypeMock) {
261249 );
262250 }
263251
264- public function testSerializeValidatorConfiguration ()
252+ public function testSerializeValidatorConfiguration (): void
265253 {
266254 $ serializer = $ this ->getFieldTypeSerializer ();
267255
268256 $ fieldTypeMock = $ this ->getFieldTypeMock ();
269- $ this ->getFieldTypeServiceMock ()->expects ($ this ->once ())
270- ->method ('getFieldType ' )
271- ->with ($ this ->equalTo ('myFancyFieldType ' ))
272- ->willReturnCallback (
273- static function () use ($ fieldTypeMock ) {
274- return $ fieldTypeMock ;
275- }
276- );
257+ $ this ->mockFieldTypeServiceGetFieldType (
258+ 'myFancyFieldType ' ,
259+ $ fieldTypeMock
260+ );
277261
278262 $ fieldTypeMock ->expects ($ this ->once ())
279263 ->method ('validatorConfigurationToHash ' )
@@ -290,7 +274,7 @@ static function () use ($fieldTypeMock) {
290274 );
291275 }
292276
293- public function testSerializeValidatorConfigurationWithPostProcessing ()
277+ public function testSerializeValidatorConfigurationWithPostProcessing (): void
294278 {
295279 $ serializer = $ this ->getFieldTypeSerializer ();
296280 $ fieldTypeMock = $ this ->getFieldTypeMock ();
@@ -316,23 +300,10 @@ static function () use ($processorMock) {
316300 ->willReturn (['post-processed ' ]);
317301
318302 $ fieldTypeMock = $ this ->getFieldTypeMock ();
319- $ this ->getFieldTypeServiceMock ()->expects ($ this ->once ())
320- ->method ('getFieldType ' )
321- ->with ($ this ->equalTo ('myFancyFieldType ' ))
322- ->willReturnCallback (
323- static function () use ($ fieldTypeMock ) {
324- return $ fieldTypeMock ;
325- }
326- );
327-
328- $ this ->getFieldTypeServiceMock ()->expects ($ this ->once ())
329- ->method ('getFieldType ' )
330- ->with ($ this ->equalTo ('myFancyFieldType ' ))
331- ->willReturnCallback (
332- static function () use ($ fieldTypeMock ) {
333- return $ fieldTypeMock ;
334- }
335- );
303+ $ this ->mockFieldTypeServiceGetFieldType (
304+ 'myFancyFieldType ' ,
305+ $ fieldTypeMock
306+ );
336307
337308 $ fieldTypeMock ->expects ($ this ->once ())
338309 ->method ('validatorConfigurationToHash ' )
@@ -349,7 +320,7 @@ static function () use ($fieldTypeMock) {
349320 );
350321 }
351322
352- protected function getFieldTypeSerializer ()
323+ protected function getFieldTypeSerializer (): FieldTypeSerializer
353324 {
354325 return new FieldTypeSerializer (
355326 $ this ->getFieldTypeServiceMock (),
@@ -402,15 +373,6 @@ protected function getFieldTypeMock()
402373 return $ this ->fieldTypeMock ;
403374 }
404375
405- protected function getGeneratorMock ()
406- {
407- if (!isset ($ this ->generatorMock )) {
408- $ this ->generatorMock = $ this ->createMock (Generator::class);
409- }
410-
411- return $ this ->generatorMock ;
412- }
413-
414376 /**
415377 * @param mixed $value
416378 */
@@ -465,6 +427,16 @@ private function createFieldTypeMock(
465427
466428 return $ fieldTypeMock ;
467429 }
430+
431+ private function mockFieldTypeServiceGetFieldType (
432+ string $ identifier ,
433+ APIFieldType $ fieldType
434+ ): void {
435+ $ this ->getFieldTypeServiceMock ()
436+ ->method ('getFieldType ' )
437+ ->with ($ identifier )
438+ ->willReturn ($ fieldType );
439+ }
468440}
469441
470442class_alias (FieldTypeSerializerTest::class, 'EzSystems\EzPlatformRest\Tests\Output\FieldTypeSerializerTest ' );
0 commit comments