44
55namespace Chubbyphp \Tests \Serialization \Unit \Mapping ;
66
7- use Chubbyphp \Mock \Call ;
8- use Chubbyphp \Mock \MockByCallsTrait ;
7+ use Chubbyphp \Mock \MockMethod \ WithReturn ;
8+ use Chubbyphp \Mock \MockObjectBuilder ;
99use Chubbyphp \Serialization \Mapping \CallableNormalizationObjectMapping ;
1010use Chubbyphp \Serialization \Mapping \NormalizationFieldMappingInterface ;
1111use Chubbyphp \Serialization \Mapping \NormalizationLinkMappingInterface ;
1919 */
2020final class CallableNormalizationObjectMappingTest extends TestCase
2121{
22- use MockByCallsTrait;
23-
2422 public function testGetClass (): void
2523 {
2624 $ mapping = new CallableNormalizationObjectMapping (\stdClass::class, static function (): void {});
@@ -30,42 +28,62 @@ public function testGetClass(): void
3028
3129 public function testGetNormalizationType (): void
3230 {
33- $ mapping = new CallableNormalizationObjectMapping (\stdClass::class, fn () => $ this ->getMockByCalls (NormalizationObjectMappingInterface::class, [
34- Call::create ('getNormalizationType ' )->with ()->willReturn ('type ' ),
35- ]));
31+ $ builder = new MockObjectBuilder ();
32+
33+ /** @var NormalizationObjectMappingInterface $normalizationObjectMapping */
34+ $ normalizationObjectMapping = $ builder ->create (NormalizationObjectMappingInterface::class, [
35+ new WithReturn ('getNormalizationType ' , [], 'type ' ),
36+ ]);
37+
38+ $ mapping = new CallableNormalizationObjectMapping (\stdClass::class, static fn () => $ normalizationObjectMapping );
3639
3740 self ::assertSame ('type ' , $ mapping ->getNormalizationType ());
3841 }
3942
4043 public function testGetNormalizationFieldMappings (): void
4144 {
42- $ fieldMapping = $ this ->getMockByCalls (NormalizationFieldMappingInterface::class);
45+ $ builder = new MockObjectBuilder ();
46+
47+ /** @var NormalizationFieldMappingInterface $fieldMapping */
48+ $ fieldMapping = $ builder ->create (NormalizationFieldMappingInterface::class, []);
49+
50+ $ normalizationObjectMapping = $ builder ->create (NormalizationObjectMappingInterface::class, [
51+ new WithReturn ('getNormalizationFieldMappings ' , ['path ' ], [$ fieldMapping ]),
52+ ]);
4353
44- $ mapping = new CallableNormalizationObjectMapping (\stdClass::class, fn () => $ this ->getMockByCalls (NormalizationObjectMappingInterface::class, [
45- Call::create ('getNormalizationFieldMappings ' )->with ('path ' )->willReturn ([$ fieldMapping ]),
46- ]));
54+ $ mapping = new CallableNormalizationObjectMapping (\stdClass::class, static fn () => $ normalizationObjectMapping );
4755
4856 self ::assertSame ($ fieldMapping , $ mapping ->getNormalizationFieldMappings ('path ' )[0 ]);
4957 }
5058
5159 public function testGetNormalizationEmbeddedFieldMappings (): void
5260 {
53- $ fieldMapping = $ this -> getMockByCalls (NormalizationFieldMappingInterface::class );
61+ $ builder = new MockObjectBuilder ( );
5462
55- $ mapping = new CallableNormalizationObjectMapping (\stdClass::class, fn () => $ this ->getMockByCalls (NormalizationObjectMappingInterface::class, [
56- Call::create ('getNormalizationEmbeddedFieldMappings ' )->with ('path ' )->willReturn ([$ fieldMapping ]),
57- ]));
63+ /** @var NormalizationFieldMappingInterface $fieldMapping */
64+ $ fieldMapping = $ builder ->create (NormalizationFieldMappingInterface::class, []);
65+
66+ $ normalizationObjectMapping = $ builder ->create (NormalizationObjectMappingInterface::class, [
67+ new WithReturn ('getNormalizationEmbeddedFieldMappings ' , ['path ' ], [$ fieldMapping ]),
68+ ]);
69+
70+ $ mapping = new CallableNormalizationObjectMapping (\stdClass::class, static fn () => $ normalizationObjectMapping );
5871
5972 self ::assertSame ($ fieldMapping , $ mapping ->getNormalizationEmbeddedFieldMappings ('path ' )[0 ]);
6073 }
6174
6275 public function testGetNormalizationLinkMappings (): void
6376 {
64- $ linkMapping = $ this ->getMockByCalls (NormalizationLinkMappingInterface::class);
77+ $ builder = new MockObjectBuilder ();
78+
79+ /** @var NormalizationLinkMappingInterface $linkMapping */
80+ $ linkMapping = $ builder ->create (NormalizationLinkMappingInterface::class, []);
81+
82+ $ normalizationObjectMapping = $ builder ->create (NormalizationObjectMappingInterface::class, [
83+ new WithReturn ('getNormalizationLinkMappings ' , ['path ' ], [$ linkMapping ]),
84+ ]);
6585
66- $ mapping = new CallableNormalizationObjectMapping (\stdClass::class, fn () => $ this ->getMockByCalls (NormalizationObjectMappingInterface::class, [
67- Call::create ('getNormalizationLinkMappings ' )->with ('path ' )->willReturn ([$ linkMapping ]),
68- ]));
86+ $ mapping = new CallableNormalizationObjectMapping (\stdClass::class, static fn () => $ normalizationObjectMapping );
6987
7088 self ::assertSame ($ linkMapping , $ mapping ->getNormalizationLinkMappings ('path ' )[0 ]);
7189 }
0 commit comments