Codeception / Codeception/module-doctrine

After Symfony Kernel reboot - Doctrine EventManager keep old Container

オープン
#24 コメント 2 件 リアクション 1 件 担当者 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.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。