Skip to content

Commit

Permalink
fix: add failing test case for implicit save
Browse files Browse the repository at this point in the history
  • Loading branch information
nikophil committed Jan 6, 2025
1 parent 004b262 commit 88298fe
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Zenstruck\Foundry\Tests\Integration\ORM\EntityRelationship;

use DAMA\DoctrineTestBundle\Doctrine\DBAL\StaticDriver;
use Doctrine\ORM\EntityManagerInterface;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\RequiresPhpunit;
Expand All @@ -31,6 +32,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 @@ -391,6 +393,22 @@ public function it_can_add_multiple_not_persisted_item_to_one_to_many(): void
self::assertCount(2, $category->getContacts());
}

/**
* @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 88298fe

Please sign in to comment.