@@ -36,13 +36,30 @@ public function testFromObjectCache(): void
36
36
$ objectCache = $ this ->createObjectCache ();
37
37
38
38
$ source = new ObjectWithScalarProperties ();
39
- $ targetType = TypeFactory::objectOfClass (ObjectWithScalarProperties ::class);
39
+ $ targetType = TypeFactory::objectOfClass (ObjectWithScalarPropertiesDto ::class);
40
40
$ target = new ObjectWithScalarPropertiesDto ();
41
41
42
42
$ objectCache ->saveTarget ($ source , $ targetType , $ target );
43
43
44
44
$ presetMapping = PresetMappingFactory::fromObjectCache ($ objectCache );
45
45
46
+ $ result = $ presetMapping ->findResult ($ source , ObjectWithScalarPropertiesDto::class);
47
+
48
+ $ this ->assertSame ($ target , $ result );
49
+ }
50
+
51
+ public function testFromObjectCacheReversed (): void
52
+ {
53
+ $ objectCache = $ this ->createObjectCache ();
54
+
55
+ $ source = new ObjectWithScalarProperties ();
56
+ $ targetType = TypeFactory::objectOfClass (ObjectWithScalarProperties::class);
57
+ $ target = new ObjectWithScalarPropertiesDto ();
58
+
59
+ $ objectCache ->saveTarget ($ source , $ targetType , $ target );
60
+
61
+ $ presetMapping = PresetMappingFactory::fromObjectCacheReversed ($ objectCache );
62
+
46
63
$ result = $ presetMapping ->findResult ($ target , $ source ::class);
47
64
48
65
$ this ->assertSame ($ source , $ result );
@@ -58,15 +75,15 @@ public function testMerge(): void
58
75
59
76
$ objectCache ->saveTarget ($ source , $ targetType , $ target );
60
77
61
- $ presetMapping = PresetMappingFactory::fromObjectCache ($ objectCache );
78
+ $ presetMapping = PresetMappingFactory::fromObjectCacheReversed ($ objectCache );
62
79
63
80
$ source2 = new ObjectWithScalarProperties ();
64
81
$ targetType2 = TypeFactory::objectOfClass (ObjectWithScalarProperties::class);
65
82
$ target2 = new ObjectWithScalarPropertiesDto ();
66
83
67
84
$ objectCache ->saveTarget ($ source2 , $ targetType2 , $ target2 );
68
85
69
- $ presetMapping2 = PresetMappingFactory::fromObjectCache ($ objectCache );
86
+ $ presetMapping2 = PresetMappingFactory::fromObjectCacheReversed ($ objectCache );
70
87
71
88
$ presetMapping ->mergeFrom ($ presetMapping2 );
72
89
0 commit comments