Proposal: haveInRepository returns the created entity instead of the primary key
还没有人认领这个 Issue。
评估
调研方向
从 src/Codeception/Module/Doctrine2.php 中链接的 haveInRepository 实现开始,位置大约在第 504-530 行,并将其与 grabEntityFromRepository 进行比较。在决定契约之前,检查现有的返回值行为和相关用法;完成意味着该提案已通过经过测试并记录在案的 haveInRepository 返回值得到解决。
由索引模型根据 Issue 内容生成。
描述
In many tests i have come across situations like this:
$I->haveInRepository(User::class, [
'name' => 'Jane',
'email' => '[email protected]',
'password' => '123456',
'enabled' => true
]);
$user = $I->grabEntityFromRepository(User::class, [
'email' => '[email protected]'
]);
// do assertions with the $user
Use haveInRepository, and then be forced to use grabEntityFromRepository to get the entity i just persisted. If i want to check that an entity listener is working, for example, i always have to execute those two statements.
My point is that this would be more useful:
$user = $I->haveInRepository(User::class, [
'name' => 'Jane',
'email' => '[email protected]',
'password' => '123456',
'enabled' => true
]);
// do assertions with the $user
if i wanted to know the primary key of that entity, i would simply write:
$user->getId();
In this context, the ORM is useful for its ability to abstract the details of the persistence process and leave it to me as a programmer to worry more about the data i am working with.
I'm not saying that getting the primary key is not useful, i am saying that it is much more useful to get the entity, where there is more information to work with in my tests, including the persistence identifier.
Please let me know your opinions about it.
- 主要语言
- PHP
- 星标
- 4
- 派生
- 2
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Codeception/module-doctrine 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 38/100
-
难度 4/5 3-5 天 新手友好度 30/100
-
难度 4/5 3-5 天 新手友好度 35/100
Codeception/module-doctrine#2 · 1 条评论 · 1 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 42/100
-
难度 3/5 1-2 天 新手友好度 64/100
Codeception/module-doctrine#6 · 1 条评论 ·
查看 Codeception/module-doctrine 的全部 Issue
相似的 Issue
-
Python 3.15 support可能已有人在做 @amnesiaof 今天认领。 未关闭L: python L: python:uv
难度 2/5 1-3 小时 新手友好度 72/100
dependabot/dependabot-core#16524 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
crazy-goat/rabbit-stream#830 ·
维护者通常 1 天内回复
-
sync-en
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
sync-en
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 4 天内回复
-
Перевод устарел
难度 2/5 1-3 小时 新手友好度 70/100