Codeception / Codeception/module-doctrine

After Symfony Kernel reboot - Doctrine EventManager keep old Container

Đang mở
#24 2 bình luận 1 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
PHP
Star
4
Fork
2
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

#### 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.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
php, symfony
Lĩnh vực
backend, testing-qa
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.