webfactory / doctrine-orm-test-infrastructure

Provides utils to create a test infrastructure for Doctrine ORM entities.
MIT License
20 stars 5 forks source link

Add a way to assert no further queries are executed #25

Closed mpdude closed 7 years ago

mpdude commented 7 years ago

In a test, I'd like to make sure that associations have been loaded eagerly.

I could probably use reflection to access the entity field containing the association from my test class, asserting that it contains an initialized collection – but that seems really ugly.

Another way of asserting the desired behavior would be to fetch the entity, then tell the ORMInfrastructure that I do not expect any further database queries and then invoke some method on the entity that would trigger loading the collection.

Thoughts?

mpdude commented 7 years ago

Disregard.

Using ORMInfrastructure::getQueries, you can already access the queries executed after the setup phase. Just add assertions on the count of queries.