Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions tests/Tests/UnitOfWorkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Documents\ForumStar;
use Documents\ForumUser;
use Documents\Functional\NotSaved;
use Documents\Group;
use Documents\User;
use MongoDB\BSON\ObjectId;
use MongoDB\Collection as MongoDBCollection;
Expand Down Expand Up @@ -489,6 +490,25 @@ public function testEmbeddedDocumentChangeSets(): void
self::assertEquals('Nashville', $changeSet['city'][1]);
}

public function testDirtyReferenceManyCollectionIsDetectedAsChanged(): void
{
$group = new Group('Admins');
$user = new User();
$this->uow->persist($group);
$this->uow->persist($user);
$this->uow->commit();

// Add a reference to the same PersistentCollection instance (orgValue === actualValue, but dirty).
// ReferenceMany collections are not processed through the association changeset loop,
// so their detection relies solely on the dirty flag in computeOrRecomputeChangeSet().
$user->addGroup($group);

$this->uow->computeChangeSets();
$changeSet = $this->uow->getDocumentChangeSet($user);

self::assertArrayHasKey('groups', $changeSet);
}

public function testRecomputeChangesetForUninitializedProxyDoesNotCreateChangeset(): void
{
$user = new ForumUser();
Expand Down