From 3fd40f79f681806cf5447d922f300cb89bb69acd Mon Sep 17 00:00:00 2001 From: Nicolas PHILIPPE Date: Mon, 6 Jan 2025 09:02:47 +0100 Subject: [PATCH] test: assert updates are implicitly persisted --- .../EntityFactoryRelationshipTestCase.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/Integration/ORM/EntityRelationship/EntityFactoryRelationshipTestCase.php b/tests/Integration/ORM/EntityRelationship/EntityFactoryRelationshipTestCase.php index 4d004dba..ca25b45e 100644 --- a/tests/Integration/ORM/EntityRelationship/EntityFactoryRelationshipTestCase.php +++ b/tests/Integration/ORM/EntityRelationship/EntityFactoryRelationshipTestCase.php @@ -31,6 +31,7 @@ use Zenstruck\Foundry\Tests\Fixture\Entity\Contact; use Zenstruck\Foundry\Tests\Fixture\Entity\Tag; +use function Zenstruck\Foundry\Persistence\refresh; use function Zenstruck\Foundry\Persistence\unproxy; /** @@ -361,6 +362,22 @@ public function ensure_one_to_many_relations_are_not_pre_persisted(): void } } + /** + * @test + */ + public function assert_updates_are_implicitly_persisted(): void + { + $category = static::categoryFactory()->create(); + $address = static::addressFactory()->create(); + + $category->setName('new name'); + + static::contactFactory()->create(['category' => $category, 'address' => $address]); + + refresh($category); + self::assertSame('new name', $category->getName()); + } + /** @return PersistentObjectFactory */ protected static function contactFactoryWithoutCategory(): PersistentObjectFactory {