|
12 | 12 | use AutoMapper\Symfony\Bundle\CacheWarmup\CacheWarmer; |
13 | 13 | use AutoMapper\Symfony\Bundle\DataCollector\MetadataCollector; |
14 | 14 | use AutoMapper\Tests\Bundle\Resources\App\AppKernel; |
| 15 | +use AutoMapper\Tests\Bundle\Resources\App\Entity\Address; |
15 | 16 | use AutoMapper\Tests\Bundle\Resources\App\Entity\AddressDTO; |
16 | 17 | use AutoMapper\Tests\Bundle\Resources\App\Entity\ClassWithMapToContextAttribute; |
17 | 18 | use AutoMapper\Tests\Bundle\Resources\App\Entity\ClassWithPrivateProperty; |
@@ -156,7 +157,7 @@ public function testMapFromClassWithPrivateProperty(array $kernelOptions, array |
156 | 157 | public static function mapFromClassWithPrivatePropertyProvider(): iterable |
157 | 158 | { |
158 | 159 | yield 'disallow private properties' => [[], []]; |
159 | | - yield 'allow private properties' => [['additionalConfigFile' => __DIR__ . '/Resources/config/with-private-properties.yml'], ['foo' => 'foo', 'bar' => 'bar']]; |
| 160 | + yield 'allow private properties' => [['additionalConfigFile' => __DIR__ . '/Resources/config/with-private-properties.yml'], ['foo' => 'foo', 'bar' => 'bar', 'addresses' => []]]; |
160 | 161 | } |
161 | 162 |
|
162 | 163 | /** |
@@ -324,4 +325,19 @@ public static function mapProvider(): iterable |
324 | 325 | $b->relationNotMapped = $d; |
325 | 326 | yield [$b, [$a]]; |
326 | 327 | } |
| 328 | + |
| 329 | + public function testMapFromClassWithPrivatePropertyPhpstan(): void |
| 330 | + { |
| 331 | + static::bootKernel([ |
| 332 | + 'additionalConfigFile' => __DIR__ . '/Resources/config/with-private-properties.yml', |
| 333 | + ]); |
| 334 | + $autoMapper = self::getContainer()->get(AutoMapperInterface::class); |
| 335 | + $address = new Address(); |
| 336 | + $address->setCity('Toulon'); |
| 337 | + |
| 338 | + self::assertEquals( |
| 339 | + ['foo' => 'foo', 'bar' => 'bar', 'addresses' => [['city' => 'Toulon']]], |
| 340 | + $autoMapper->map(new ClassWithPrivateProperty('foo', [$address]), 'array') |
| 341 | + ); |
| 342 | + } |
327 | 343 | } |
0 commit comments