Codeception / Codeception/module-doctrine
Recommend to load fixtures in `function _before()` and set `cleanup: false`?
- 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ả
I'm observing that with `cleanup: true`, running external commands with `$I->runShellCommand('php bin/console ...');` isn't working. I'm guessing this is due to the transaction, which prevents external processes to "see" the database contents created/modified by the test. Can you confirm this?
If so, I would suggest to change the recommendation at https://codeception.com/docs/modules/Doctrine to `cleanup: false`, and show people how to load their fixtures in `function _before()`:
```php
$I->runShellCommand('php bin/console doctrine:fixtures:load --no-interaction --env=test');
```
IMO the currently recommended way to cleanup after each test doesn't work out, since for *some tests* it's necessary to disable the transaction (see above) - which ultimately leads to a mess.
So I'm figuring the best approach would be to just reload the fixtures before each test.
What do you think? How do you handle that?
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
Start by reading the Doctrine module documentation at https://codeception.com/docs/modules/Doctrine and the issue's examples using cleanup, _before(), runShellCommand(), and doctrine:fixtures:load. Reproduce whether cleanup transactions hide test changes from external commands, then determine whether the documentation should recommend cleanup: false and fixture loading before each test.
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
- Lĩnh vực
- documentation
- Loại issue
- Tài liệu
- Độ 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
- 30/100