Commit 0db7d92
authored
Add functional tests for grabEntityManager(), resetDoctrineManager() and grabContainer() (#76)
* Add functional test for grabEntityManager()
Cover grabEntityManager(), added in codeception/module-symfony: assert it returns
an open EntityManagerInterface, and that it is the very instance the application
uses rather than a copy, by comparing it against the
doctrine.orm.default_entity_manager service.
No app fixtures are needed: the existing User entity and its fixture cover it.
The test is identical on every branch, since the method behaves the same on all
supported Symfony versions.
* Add functional test for resetDoctrineManager()
Cover resetDoctrineManager(), added in codeception/module-symfony. Assert both
halves of its contract: an open manager is only cleared, so a previously managed
entity is no longer in the identity map, and a closed manager is reopened. The
seeNumRecords() call at the end proves the transaction the Doctrine module opened
for the test survived the reset.
No app fixtures are needed: the test closes the manager itself rather than
provoking a failed flush, which keeps it deterministic under settings.shuffle.
The test is identical on every branch. The module recovers through Doctrine's
registry where the entity manager service is lazy and by rebooting the kernel
where it is not, but both paths are observable only as a reopened manager.
* Add functional test for grabContainer()
Cover grabContainer(), added in codeception/module-symfony: assert it returns the
container for the test environment, and that it is the test container rather than
the kernel's own. The last two assertions are the point of the method: the test
container resolves a private service that the kernel container cannot see, which
is what made the widespread grabService('kernel')->getContainer() workaround
subtly wrong.
No app fixtures are needed: EntityManagerInterface is registered as a private
autowiring alias by doctrine-bundle on every branch.
The test is identical on every branch.1 parent 41e29e2 commit 0db7d92
2 files changed
Lines changed: 39 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
14 | 24 | | |
15 | 25 | | |
16 | 26 | | |
| |||
39 | 49 | | |
40 | 50 | | |
41 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
42 | 68 | | |
43 | 69 | | |
44 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
13 | 26 | | |
14 | 27 | | |
15 | 28 | | |
| |||
0 commit comments