Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is the entity manager not released from memory after each unit test? #10

Open
ThomasLandauer opened this issue Jan 22, 2021 · 2 comments

Comments

@ThomasLandauer
Copy link
Member

When running my entire unit test suite, I'm getting one of these two errors

In UnaryOperator.php line 17:
Error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 140142348222464 bytes)

In UnaryOperator.php line 84:
Compile Error: Declaration of PHPUnit\Framework\Constraint\UnaryOperator::failureDescription($other): string must be compatible with PHPUnit\Framework\Constraint\Constraint::failureDescription($joinAssociationDeclaration):

... always on the same tests. The only thing they have in common is that they fetch stuff from the database.

But when I run the affected test files alone, everything's fine.

This makes me suspect that something with memory management is wrong. Is the entity manager being kept in memory between test runs?

@Naktibalda
Copy link
Member

Naktibalda commented Jan 22, 2021

That error doesn't look like memory leak, PHP tries to allocate 140 terabytes in one go.

@ThomasLandauer
Copy link
Member Author

ThomasLandauer commented Jan 23, 2021

140 TB? Well, maybe I should go and buy more RAM then... ;-)

I now moved the first of the affected tests to functional suite, and the entire suite runs smoothly there. How can that be?? What's the difference between unit and functional runner?

It probably has something to do with a change I made in the app in an entity: Some setter is now doing a change in a related entity, something like:

function setOk(bool $ok)
{
    $this->ok = $ok;
    $this->getFoo()->setOk($ok); // <= `Foo` = related entity
}

Cause when I remove this line again, unit suite works too (i.e. fails, but doesn't crash).

@TavoNiievez TavoNiievez transferred this issue from Codeception/module-doctrine2 Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants