Skip to content

Commit

Permalink
test: assert updates are implicitly persisted
Browse files Browse the repository at this point in the history
  • Loading branch information
nikophil committed Jan 6, 2025
1 parent 3e9650a commit 3fd40f7
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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<Contact> */
protected static function contactFactoryWithoutCategory(): PersistentObjectFactory
{
Expand Down

0 comments on commit 3fd40f7

Please sign in to comment.