You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(To be fair, in the second sample, I omitted the boilerplate code inside _before(): $this->fooRepository = $I->grabService(FooRepository::class);.)
Shouldn't Codeception concentrate on providing handy methods that make otherwise complicated stuff easier, rather than "copying" methods which are already easy?
Even worse, in this case, using Codeception's methods actually makes it harder for many people, since they have unintended side-effects that are (a) undocumented and (b) counter-intuitive. So just stopping people from using them, would immediately resolve at least 4 issues:
So wouldn't it be easier for everybody to just deprecate those methods? And instead of making people learn something new (which eventually doesn't work as they expect), just show them how easy it is to go with Doctrine's built-in repository methods which they already know?
The text was updated successfully, but these errors were encountered:
I personally agree that in Symfony, the process is simplified to grab an actual repository. But the doctrine2 module can be used without Symfony. In that use-case you'd need to construct your own instances of EntityRepository which always needs the entity manager and all of its dependencies. So these helper functions are actually more-or-less what a user would have to do without Symfony.
Another big difference is that those working in Symfony would 9/10 use ServiceEntityRepository instead of just EntityRepository. So providing a simple API to query entities can be helpful for those who want quick tests.
Perhaps just modify the documentation to highlight that usage of actual repositories to grab entities is preferred over using the helper grabbers?
ThomasLandauer
added a commit
to ThomasLandauer/module-doctrine2
that referenced
this issue
Mar 13, 2023
Info is taken from Codeception#22 (comment)
In case of merge conflict: This is meant to go between "Description" and "Public Properties"
TODO after this is merged: Add a link from the three `grab` methods to this section
My question is: What's the benefit of doing
over doing
(To be fair, in the second sample, I omitted the boilerplate code inside
_before()
:$this->fooRepository = $I->grabService(FooRepository::class);
.)Shouldn't Codeception concentrate on providing handy methods that make otherwise complicated stuff easier, rather than "copying" methods which are already easy?
Even worse, in this case, using Codeception's methods actually makes it harder for many people, since they have unintended side-effects that are (a) undocumented and (b) counter-intuitive. So just stopping people from using them, would immediately resolve at least 4 issues:
flush()
before checking the database so necessary?grabEntityFromRepository()
causes invalid entity to be persistedSo wouldn't it be easier for everybody to just deprecate those methods? And instead of making people learn something new (which eventually doesn't work as they expect), just show them how easy it is to go with Doctrine's built-in repository methods which they already know?
The text was updated successfully, but these errors were encountered: