Skip to content

Suggestion: Deprecate grabEntityFromRepository() and grabEntitiesFromRepository() #22

Closed
@ThomasLandauer

Description

@ThomasLandauer

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:

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions