Skip to content

Recommending against grab() methods for Symfony users #68

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

Merged
merged 2 commits into from
Mar 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/Codeception/Module/Doctrine2.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,24 @@
* purge_mode: 1 # 1: DELETE (=default), 2: TRUNCATE
* ```
*
* ## Grabbing Entities with Symfony
*
* For Symfony users, the recommended way to query for entities is not to use this module's `grab...()` methods, but rather
* "inject" Doctrine's repository:
*
* ```php
* public function _before(FunctionalTester $I): void
* {
* $this->fooRepository = $I->grabService(FooRepository::class);
* }
* ```
*
* Now you have access to all your familiar repository methods in your tests, e.g.:
*
* ```php
* $greenFoo = $this->fooRepository->findOneBy(['color' => 'green']);
* ```
*
* ## Public Properties
*
* * `em` - Entity Manager
Expand Down