Description
My question is: What's the benefit of doing
$greenFoo = $I->grabEntityFromRepository(Foo::class, ['color' => 'green']);
over doing
$greenFoo = $this->fooRepository->findOneBy(['color' => 'green']);
(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:
- Doctrine2 Module: Is
flush()
before checking the database so necessary? - Doctrine2:
grabEntityFromRepository()
causes invalid entity to be persisted - Flush from the seeInRepository method
- Why flush is necesary on methods like grabFromRepository?
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?