|
5 | 5 | namespace Tests\Tempest\Integration\Mapper; |
6 | 6 |
|
7 | 7 | use Tempest\Mapper\Exceptions\MissingValuesException; |
8 | | -use Tempest\Mapper\MapTo; |
9 | 8 | use Tempest\Validation\Exceptions\ValidationException; |
10 | 9 | use Tests\Tempest\Fixtures\Modules\Books\Models\Author; |
11 | 10 | use Tests\Tempest\Fixtures\Modules\Books\Models\Book; |
|
16 | 15 | use Tests\Tempest\Integration\Mapper\Fixtures\ObjectWithFloatProp; |
17 | 16 | use Tests\Tempest\Integration\Mapper\Fixtures\ObjectWithIntProp; |
18 | 17 | use Tests\Tempest\Integration\Mapper\Fixtures\ObjectWithMapFromAttribute; |
19 | | -use Tests\Tempest\Integration\Mapper\Fixtures\ObjectWithMappedVariousPropertyScope; |
20 | 18 | use Tests\Tempest\Integration\Mapper\Fixtures\ObjectWithMapToAttribute; |
21 | 19 | use Tests\Tempest\Integration\Mapper\Fixtures\ObjectWithMapToCollisions; |
22 | 20 | use Tests\Tempest\Integration\Mapper\Fixtures\ObjectWithMapToCollisionsJsonSerializable; |
23 | 21 | use Tests\Tempest\Integration\Mapper\Fixtures\ObjectWithStrictOnClass; |
24 | 22 | use Tests\Tempest\Integration\Mapper\Fixtures\ObjectWithStrictProperty; |
| 23 | +use Tests\Tempest\Integration\Mapper\Fixtures\Person; |
25 | 24 | use function Tempest\make; |
26 | 25 | use function Tempest\map; |
27 | 26 |
|
@@ -225,4 +224,18 @@ public function test_map_to_handle_name_collisions_with_json_serializable(): voi |
225 | 224 | 'full_name' => 'my name', |
226 | 225 | ], $array); |
227 | 226 | } |
| 227 | + public function test_nested_value_object_mapping(): void |
| 228 | + { |
| 229 | + $data = [ |
| 230 | + 'name' => [ |
| 231 | + 'first' => 'Brent', |
| 232 | + 'last' => 'Roose', |
| 233 | + ] |
| 234 | + ]; |
| 235 | + |
| 236 | + $person = map($data)->to(Person::class); |
| 237 | + |
| 238 | + $this->assertSame('Brent', $person->name->first); |
| 239 | + $this->assertSame('Roose', $person->name->last); |
| 240 | + } |
228 | 241 | } |
0 commit comments