|
26 | 26 | use Zenstruck\Foundry\Tests\Fixture\DoctrineCascadeRelationship\ChangesEntityRelationshipCascadePersist; |
27 | 27 | use Zenstruck\Foundry\Tests\Fixture\DoctrineCascadeRelationship\UsingRelationships; |
28 | 28 | use Zenstruck\Foundry\Tests\Fixture\Entity\Contact; |
| 29 | +use Zenstruck\Foundry\Tests\Fixture\Entity\EdgeCases\EntityWithCloneMethod; |
29 | 30 | use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\Address\AddressFactory; |
30 | 31 | use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\Category\CategoryFactory; |
31 | 32 | use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\Contact\ContactFactory; |
32 | 33 | use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\GenericEntityFactory; |
33 | 34 | use Zenstruck\Foundry\Tests\Integration\Persistence\AutoRefreshTestCase; |
34 | 35 | use Zenstruck\Foundry\Tests\Integration\RequiresORM; |
35 | 36 |
|
| 37 | +use function Zenstruck\Foundry\Persistence\persistent_factory; |
36 | 38 | use function Zenstruck\Foundry\Persistence\refresh_all; |
37 | 39 |
|
38 | 40 | /** |
@@ -123,7 +125,6 @@ public function it_can_refresh_objects_with_relationships(): void |
123 | 125 | } |
124 | 126 |
|
125 | 127 | #[Test] |
126 | | - #[IgnorePhpunitWarnings(EdgeCasesRelationshipTest::DATA_PROVIDER_WARNING_REGEX)] |
127 | 128 | public function it_can_refresh_with_doctrine_proxies(): void |
128 | 129 | { |
129 | 130 | $contact = ContactFactory::createOne(); |
@@ -151,6 +152,22 @@ public function it_can_refresh_with_doctrine_proxies(): void |
151 | 152 | self::assertSame('foo', $category->getName()); |
152 | 153 | } |
153 | 154 |
|
| 155 | + #[Test] |
| 156 | + public function it_can_refresh_entity_which_removes_its_id_in_clone(): void |
| 157 | + { |
| 158 | + $entity = persistent_factory(EntityWithCloneMethod::class)->create(); |
| 159 | + $entityId = $entity->id; |
| 160 | + |
| 161 | + $this->objectManager()->getConnection()->executeQuery('UPDATE entity_with_clone_method SET prop = \'foo\' WHERE id = ?', [$entity->id]); |
| 162 | + |
| 163 | + self::ensureKernelShutdown(); |
| 164 | + |
| 165 | + self::assertTrue((new \ReflectionClass($entity))->isUninitializedLazyObject($entity)); |
| 166 | + |
| 167 | + self::assertSame('foo', $entity->prop); |
| 168 | + self::assertSame($entityId, $entity->id); |
| 169 | + } |
| 170 | + |
154 | 171 | protected static function factory(): PersistentObjectFactory |
155 | 172 | { |
156 | 173 | return GenericEntityFactory::new(); |
|
0 commit comments