Codeception / Codeception/module-doctrine

After Symfony Kernel reboot - Doctrine EventManager keep old Container

未关闭
#24 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
PHP
星标
4
派生
2
PR 合并指标
30 天内没有已合并 PR

描述

#### What are you trying to achieve?
I have case, when my service have some state, like MemoryStorage collect some data and I want to test what it collects. This MemoryStorage filled by some listeners, subscribed to Doctrine events.

#### What do you get instead?
My MemoryStorage empty.

Here is reproduce test https://github.com/ewgRa/symfony-standard/blob/codeception-bug-with-container/tests/functional/ContainerCest.php .

tryToTest failed, and tryToTestProof show the reason why it fail.
Problem that doctrine.orm.entity_manager is persistent service and it have EventManager, that actually ContainerAwareEventManager, that store container.
When Symfony module reboot kernel, it create new Container, but since doctrine is persistent, EventManager continue keep old container.
As a result Doctrine events work with its own container, while $I->grabService(...) work with another container.

Reproduce:
git clone git@github.com:ewgRa/symfony-standard.git
cd symfony-standard/
git checkout codeception-bug-with-container
composer install
vendor/bin/codecept run

So, is it feature? Or bug? Looks like 100% bug. Possible solution is update EventManager container also on kernel reboot. Or another solution - unpersist doctrine.

At least this must be mentioned somehow in documentation. Also some "I make service persistent, and it not works" issues can be related to this.

贡献指南

这个仓库没有索引到贡献指南

调研方向

Run the reproduction from tests/functional/ContainerCest.php using the documented git checkout, composer install, and vendor/bin/codecept run commands. Inspect the Symfony kernel reboot path, doctrine.orm.entity_manager persistence, and ContainerAwareEventManager to confirm why the old container remains referenced. Done means a regression test demonstrates consistent container use, or the limitation is documented if no fix is selected.

由索引模型根据 Issue 内容生成。

评估

技术栈
php, symfony
领域
backend, testing-qa
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。