Skip to content

Commit

Permalink
Remove test for invalid functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
alcaeus committed May 10, 2024
1 parent a1aae66 commit 1b59ce8
Showing 1 changed file with 0 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Doctrine\ODM\MongoDB\Event\LifecycleEventArgs;
use Doctrine\ODM\MongoDB\Events;
use Doctrine\ODM\MongoDB\LockException;
use Doctrine\ODM\MongoDB\PersistentCollection\PersistentCollectionInterface;
use Doctrine\ODM\MongoDB\Tests\BaseTestCase;
use Documents\Phonebook;
use Documents\Phonenumber;
Expand Down Expand Up @@ -87,41 +86,6 @@ public function testCollectionsAreUpdatedJustAfterOwningDocument(): void
self::assertEquals('87654321', $phonenumbers[1]->getPhonenumber());
}

/**
* This test checks few things:
* - if collections were updated after post* events, our changes would be saved
* - if collection snapshot would be taken after post* events, collection
* wouldn't be dirty and wouldn't be updated in next flush
*/
public function testChangingCollectionInPostEventsHasNoIllEffects(): void
{
$this->dm->getEventManager()->addEventSubscriber(new PhonenumberMachine());

$user = new VersionedUser();
$user->setUsername('malarzm');
$this->dm->persist($user);
$this->dm->flush();

$phoneNumbers = $user->getPhonenumbers();
self::assertCount(1, $phoneNumbers); // so we got a number on postPersist
self::assertInstanceOf(PersistentCollectionInterface::class, $phoneNumbers); // so we got a number on postPersist
self::assertTrue($phoneNumbers->isDirty()); // but they should be dirty

$collection = $this->dm->getDocumentCollection($user::class);
$inDb = $collection->findOne();
self::assertArrayNotHasKey('phonenumbers', $inDb, 'Collection modified in postPersist should not be in database without recomputing change set');

$this->dm->flush();

$phoneNumbers = $user->getPhonenumbers();
self::assertInstanceOf(PersistentCollectionInterface::class, $phoneNumbers);
self::assertCount(2, $phoneNumbers); // so we got a number on postUpdate
self::assertTrue($phoneNumbers->isDirty()); // but they should be dirty

$inDb = $collection->findOne();
self::assertCount(1, $inDb['phonenumbers'], 'Collection changes from postUpdate should not be in database');
}

public function testSchedulingCollectionDeletionAfterSchedulingForUpdate(): void
{
$user = new User();
Expand Down

0 comments on commit 1b59ce8

Please sign in to comment.