File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
tests/AutoMapperTest/ArrayNotNested Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ AutoMapper\Tests\AutoMapperTest\ArrayNested\UserEntity {
2
+ +"roles": [
3
+ "ROLE_USER"
4
+ ]
5
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace AutoMapper \Tests \AutoMapperTest \ArrayNested ;
6
+
7
+ use AutoMapper \Tests \AutoMapperBuilder ;
8
+
9
+ class UserApiResource
10
+ {
11
+ public array $ roles ; // ["ROLE_USER"]
12
+ }
13
+
14
+ class UserEntity
15
+ {
16
+ public function setRoles (array $ roles )
17
+ {
18
+ $ this ->roles = $ roles ; // [["ROLE_USER"]];
19
+ }
20
+ }
21
+
22
+ return (function () {
23
+ $ autoMapper = AutoMapperBuilder::buildAutoMapper ();
24
+
25
+ $ userApiResource = new UserApiResource ();
26
+ $ userApiResource ->roles = ['ROLE_USER ' ];
27
+
28
+ yield 'array ' => $ autoMapper ->map ($ userApiResource , UserEntity::class);
29
+ })();
You can’t perform that action at this time.
0 commit comments