Codeception / Codeception/module-doctrine

Recommend to load fixtures in `function _before()` and set `cleanup: false`?

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

描述

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?

贡献指南

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

调研方向

首先阅读 https://codeception.com/docs/modules/Doctrine 上的 Doctrine 模块文档,以及 issue 中使用 cleanup、_before()、runShellCommand() 和 doctrine:fixtures:load 的示例。复现 cleanup 事务是否会使外部命令无法看到测试更改,然后确定文档是否应建议使用 cleanup: false,并在每次测试之前加载 fixture。

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

评估

技术栈
php
领域
documentation
Issue 类型
文档
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
30/100

把新 issue 发到你的邮箱

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