Closed OleksandrConstell closed 5 days ago
hello,
sorry for this late reply :sweat_smile:
I've just tested this with Foundry v2 (using rasmey/uid or symfony/uid as well) and I've never reproduced this.
I'm closing it, feel free to reopen the issue, if this problem still occur in foundry v2
Hello everyone.
I found an interesting bug with Zenstruck\Foundry\ModelFactory and Zenstruck\Foundry\Proxy. Use:
Entity Quote and QuoteFactor
Unit test
Method
$this->objectManager()->getUnitOfWork()->computeChangeSet($om->getClassMetadata($this->class), $this->object)
RETURNS:I figured out why. Looks like after these steps the \RuntimeException appears: FILE: https://github.com/zenstruck/foundry/blob/v1.36.1/src/Proxy.php 1) call Proxy->object()
2) Method "->object()" calls "->computeChangeSet()"(LINE 125) -> no changes -> CALL "$this->refresh()" (LINE 134); 3) Method "->refresh()" calls "$this->objectManager()->refresh($this->object);" (LINE 176)
4) Second call Proxy->object() calls "->computeChangeSet()"(LINE 125) -> some changes -> CALL "throw new \RuntimeException()" (LINE 130);
Looks like "refreshing entity" and calling "computeChangeSet" generates unsaved data and as a result exception.
Please take a look.