|
20 | 20 | use AutoMapper\Tests\Fixtures\AddressDTOWithReadonlyPromotedProperty; |
21 | 21 | use AutoMapper\Tests\Fixtures\AddressType; |
22 | 22 | use AutoMapper\Tests\Fixtures\AddressWithEnum; |
| 23 | +use AutoMapper\Tests\Fixtures\Category; |
| 24 | +use AutoMapper\Tests\Fixtures\CategoryDTO; |
23 | 25 | use AutoMapper\Tests\Fixtures\ClassWithMapToContextAttribute; |
24 | 26 | use AutoMapper\Tests\Fixtures\ClassWithNullablePropertyInConstructor; |
25 | 27 | use AutoMapper\Tests\Fixtures\ClassWithPrivateProperty; |
|
40 | 42 | use AutoMapper\Tests\Fixtures\Order; |
41 | 43 | use AutoMapper\Tests\Fixtures\PetOwner; |
42 | 44 | use AutoMapper\Tests\Fixtures\PetOwnerWithConstructorArguments; |
| 45 | +use AutoMapper\Tests\Fixtures\Post; |
43 | 46 | use AutoMapper\Tests\Fixtures\SourceForConstructorWithDefaultValues; |
44 | 47 | use AutoMapper\Tests\Fixtures\Transformer\MoneyTransformerFactory; |
45 | 48 | use AutoMapper\Tests\Fixtures\Uninitialized; |
@@ -1376,6 +1379,19 @@ public function testAutoMapperFixtures(string $mapFile, string $directory): void |
1376 | 1379 | } |
1377 | 1380 | } |
1378 | 1381 |
|
| 1382 | + public function testCircularReferenceForPromotedProperties(): void |
| 1383 | + { |
| 1384 | + $category = new Category('Category'); |
| 1385 | + $category->posts[] = new Post('Example', $category); |
| 1386 | + |
| 1387 | + $categoryDTO = $this->autoMapper->map($category, CategoryDTO::class); |
| 1388 | + |
| 1389 | + self::assertEquals('Category', $categoryDTO->name); |
| 1390 | + self::assertCount(1, $categoryDTO->posts); |
| 1391 | + self::assertEquals('Example', $categoryDTO->posts[0]->name); |
| 1392 | + self::assertEquals($categoryDTO, $categoryDTO->posts[0]->category); |
| 1393 | + } |
| 1394 | + |
1379 | 1395 | public static function provideAutoMapperFixturesTests(): iterable |
1380 | 1396 | { |
1381 | 1397 | $directories = (new Finder()) |
|
0 commit comments