Skip to content

Commit

Permalink
Merge pull request #68 from ThomasLandauer/patch-2
Browse files Browse the repository at this point in the history
Recommending against `grab()` methods for Symfony users
  • Loading branch information
Naktibalda committed Mar 18, 2023
2 parents be8228d + 3c414e3 commit 18dd720
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Codeception/Module/Doctrine2.php
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

0 comments on commit 18dd720

Please sign in to comment.