@@ -36,6 +36,10 @@ public function setUp(): void
3636 $ this ->faker = \Faker \Factory::create ();
3737 }
3838
39+ /**
40+ * @return UserModel
41+ * @throws Exception
42+ */
3943 protected function createUser (): UserModel
4044 {
4145 $ user = new UserModel ;
@@ -48,58 +52,67 @@ protected function createUser(): UserModel
4852 return $ user ;
4953 }
5054
55+ /**
56+ * @throws Exception
57+ */
5158 public function testFillModelRefModel (): void
5259 {
5360 $ model = new UserModel ;
54- $ this ->dataTransformer ->fillModel ([
61+ $ this ->dataTransformer ->fillModel ($ model , [
5562 'id ' => 1 ,
5663 'name ' => 'Alex ' ,
5764 'refModel ' => [
5865 'id ' => 2 ,
59- 'creAt ' => new \ DateTime ,
66+ 'creAt ' => new DateTime ,
6067 'name ' => 'Alex2 ' ,
6168 'active ' => true ,
6269 ]
63- ], $ model , 'withRefs.map ' );
70+ ], 'withRefs.map ' );
6471
6572 $ this ->assertInstanceOf (UserModel::class, $ model );
6673 $ this ->assertInstanceOf (UserModel::class, $ model ->refModel );
6774 $ this ->assertEquals (2 , $ model ->refModel ->getId ());
6875 }
6976
77+ /**
78+ * @throws Exception
79+ */
7080 public function testFillModelRefModelWithExtraFields (): void
7181 {
7282 $ model = new UserModel ;
73- $ this ->dataTransformer ->fillModel ([
83+ $ this ->dataTransformer ->fillModel ($ model , [
7484 'id ' => 1 ,
7585 'name ' => 'Alex ' ,
7686 'extraFieldWithoutDeclarateTransform ' => 3 ,
7787 'refModel ' => [
7888 'id ' => 2 ,
79- 'creAt ' => new \ DateTime ,
89+ 'creAt ' => new DateTime ,
8090 'name ' => 'Alex2 ' ,
8191 'active ' => true ,
8292 ]
83- ], $ model , 'withRefs.map ' );
93+ ], 'withRefs.map ' );
8494
8595 $ this ->assertInstanceOf (UserModel::class, $ model );
8696 $ this ->assertInstanceOf (UserModel::class, $ model ->refModel );
8797 $ this ->assertEquals (2 , $ model ->refModel ->getId ());
8898 }
8999
100+ /**
101+ * @throws Exception
102+ */
90103 public function testToModelRefModel (): void
91104 {
92105 /** @var UserModel $model */
93- $ model = $ this ->dataTransformer ->toModel ([
106+ $ model = $ this ->dataTransformer ->toModel (UserModel::class, [
94107 'id ' => 1 ,
95108 'name ' => 'Alex ' ,
96109 'refModel ' => [
97110 'id ' => 2 ,
98- 'creAt ' => new \ DateTime ,
111+ 'creAt ' => new DateTime ,
99112 'name ' => 'Alex2 ' ,
100113 'active ' => true ,
101114 ]
102- ], UserModel::class, 'withRefs.map ' );
115+ ], 'withRefs.map ' );
103116
104117 $ this ->assertInstanceOf (UserModel::class, $ model );
105118 $ this ->assertInstanceOf (UserModel::class, $ model ->refModel );
@@ -109,7 +122,7 @@ public function testToModelRefModel(): void
109122 public function testToModelRefModels (): void
110123 {
111124 /** @var UserModel $model */
112- $ model = $ this ->dataTransformer ->toModel ([
125+ $ model = $ this ->dataTransformer ->toModel (UserModel::class, [
113126 'id ' => 1 ,
114127 'name ' => 'Alex ' ,
115128 'refModels ' => [
@@ -122,7 +135,7 @@ public function testToModelRefModels(): void
122135 'name ' => 'Alex3 ' ,
123136 ]
124137 ]
125- ], UserModel::class, 'withRefs.map ' );
138+ ], 'withRefs.map ' );
126139
127140 $ this ->assertCount (2 , $ model ->refModels );
128141 $ this ->assertInstanceOf (UserModel::class, $ model ->refModels [0 ]);
@@ -131,7 +144,10 @@ public function testToModelRefModels(): void
131144 $ this ->assertEquals (3 , $ model ->refModels [1 ]->getId ());
132145 }
133146
134- public function testToDtoRefModel ()
147+ /**
148+ * @throws Exception
149+ */
150+ public function testToDtoRefModel (): void
135151 {
136152 $ model = $ this ->createUser ();
137153 $ model2 = $ this ->createUser ();
@@ -149,7 +165,10 @@ public function testToDtoRefModel()
149165 ]);
150166 }
151167
152- public function testToDtoRefModels ()
168+ /**
169+ * @throws Exception
170+ */
171+ public function testToDtoRefModels (): void
153172 {
154173 $ model = $ this ->createUser ();
155174 $ model2 = $ this ->createUser ();
@@ -178,4 +197,4 @@ public function testToDtoRefModels()
178197 ]
179198 ]);
180199 }
181- }
200+ }
0 commit comments