11
11
* that was distributed with this source code.
12
12
*/
13
13
14
- namespace Rekalogika \Mapper \Tests \IntegrationTest ;
14
+ namespace Rekalogika \Mapper \Tests \IntegrationTest \ ScalarToScalar ;
15
15
16
16
use Rekalogika \Mapper \Tests \Common \AbstractFrameworkTest ;
17
17
use Rekalogika \Mapper \Tests \Fixtures \Scalar \ObjectWithScalarProperties ;
18
+ use Rekalogika \Mapper \Tests \Fixtures \Scalar \ObjectWithScalarPropertiesWithNullContents ;
18
19
use Rekalogika \Mapper \Tests \Fixtures \ScalarDto \ObjectWithBoolPropertiesDto ;
19
20
use Rekalogika \Mapper \Tests \Fixtures \ScalarDto \ObjectWithFloatPropertiesDto ;
20
21
use Rekalogika \Mapper \Tests \Fixtures \ScalarDto \ObjectWithIntPropertiesDto ;
22
+ use Rekalogika \Mapper \Tests \Fixtures \ScalarDto \ObjectWithScalarConstructorArgumentDto ;
21
23
use Rekalogika \Mapper \Tests \Fixtures \ScalarDto \ObjectWithScalarPropertiesDto ;
22
24
use Rekalogika \Mapper \Tests \Fixtures \ScalarDto \ObjectWithStringPropertiesDto ;
23
25
24
- class ScalarPropertiesMappingTest extends AbstractFrameworkTest
26
+ abstract class AbstractScalarPropertiesMappingTest extends AbstractFrameworkTest
25
27
{
26
28
public function testScalarIdentity (): void
27
29
{
@@ -34,6 +36,39 @@ public function testScalarIdentity(): void
34
36
$ this ->assertEquals ($ class ->d , $ dto ->d );
35
37
}
36
38
39
+ public function testScalarIdentityWithTargetConstructorArgument (): void
40
+ {
41
+ $ class = new ObjectWithScalarProperties ();
42
+ $ dto = $ this ->mapper ->map ($ class , ObjectWithScalarConstructorArgumentDto::class);
43
+
44
+ $ this ->assertEquals ($ class ->a , $ dto ->a );
45
+ $ this ->assertEquals ($ class ->b , $ dto ->b );
46
+ $ this ->assertEquals ($ class ->c , $ dto ->c );
47
+ $ this ->assertEquals ($ class ->d , $ dto ->d );
48
+ }
49
+
50
+ public function testNullSourcesToScalarNullableTargets (): void
51
+ {
52
+ $ class = new ObjectWithScalarPropertiesWithNullContents ();
53
+ $ dto = $ this ->mapper ->map ($ class , ObjectWithScalarPropertiesDto::class);
54
+
55
+ $ this ->assertNull ($ dto ->a );
56
+ $ this ->assertNull ($ dto ->b );
57
+ $ this ->assertNull ($ dto ->c );
58
+ $ this ->assertNull ($ dto ->d );
59
+ }
60
+
61
+ public function testNullSourcesToScalarNullableConstructorArgumentsTargets (): void
62
+ {
63
+ $ class = new ObjectWithScalarPropertiesWithNullContents ();
64
+ $ dto = $ this ->mapper ->map ($ class , ObjectWithScalarConstructorArgumentDto::class);
65
+
66
+ $ this ->assertEquals ($ class ->a , $ dto ->a );
67
+ $ this ->assertEquals ($ class ->b , $ dto ->b );
68
+ $ this ->assertEquals ($ class ->c , $ dto ->c );
69
+ $ this ->assertEquals ($ class ->d , $ dto ->d );
70
+ }
71
+
37
72
public function testScalarToInt (): void
38
73
{
39
74
$ class = new ObjectWithScalarProperties ();
0 commit comments