diff --git a/CHANGELOG.md b/CHANGELOG.md index e2f9b9e6..6c71df9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * fix: Typo in `RemoveOptionalDefinitionPass` * feat: Supports dynamic properties (including `stdClass`) on the target side. * fix(`Mapper`): Fix typehint. +* test: test array cast to object mapping ## 1.0.0 diff --git a/tests/IntegrationTest/DynamicPropertyTest.php b/tests/IntegrationTest/DynamicPropertyTest.php index 547cc5d4..6085de7a 100644 --- a/tests/IntegrationTest/DynamicPropertyTest.php +++ b/tests/IntegrationTest/DynamicPropertyTest.php @@ -57,6 +57,24 @@ public function testObjectExtendingStdClassToObject(): void $this->assertSame(1.1, $target->d); } + public function testArrayCastToObjectToObject(): void + { + $source = [ + 'a' => 1, + 'b' => 'string', + 'c' => true, + 'd' => 1.1, + ]; + + $target = $this->mapper->map((object) $source, ObjectWithScalarPropertiesDto::class); + + $this->assertInstanceOf(ObjectWithScalarPropertiesDto::class, $target); + $this->assertSame(1, $target->a); + $this->assertSame('string', $target->b); + $this->assertTrue($target->c); + $this->assertSame(1.1, $target->d); + } + public function testStdClassWithoutPropertiesToObject(): void { $source = new \stdClass();