Skip to content

Commit a5d28a4

Browse files
Recommending against grab() methods for Symfony users
Info is taken from Codeception/module-doctrine2#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
1 parent 2bbd498 commit a5d28a4

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/Codeception/Module/Doctrine2.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,24 @@
8888
* purge_mode: 1 # 1: DELETE (=default), 2: TRUNCATE
8989
* ```
9090
*
91+
* ## Grabbing Entities with Symfony
92+
*
93+
* For Symfony users, the recommended way to query for entities is not to use this module's `grab...()` methods, but rather
94+
* "inject" Doctrine's repository:
95+
*
96+
* ```php
97+
* public function _before(FunctionalTester $I): void
98+
* {
99+
* $this->fooRepository = $I->grabService(FooRepository::class);
100+
* }
101+
* ```
102+
*
103+
* Now you have access to all your familiar repository methods in your tests, e.g.:
104+
*
105+
* ```php
106+
* $greenFoo = $this->fooRepository->findOneBy(['color' => 'green']);
107+
* ```
108+
*
91109
* ## Status
92110
*
93111
* * Maintainer: **davert**

0 commit comments

Comments
 (0)