Cakephp 中单元测试功能的通用库放在哪里?
目前,我的几个单元测试需要通用功能,例如从模拟对象登录特定用户或确保没有人登录。我目前在一个文件中包含这些函数,我通过常规的旧 include 语句包含该文件。这对我来说似乎不太蛋糕。我也不想在每次测试时都继续输入 include 语句,因此我想在较高的级别上进行操作,并使其可用于我的所有测试,当然,无需修改核心 cakephp 文件。
因此,我需要寻找一个位置来放置 mustbeLoggedIn('usertype');
类型的函数,这将有助于保持我的测试干燥,但更适合对象。到目前为止,我还没有成功地通过 cake 使用的常见行为、助手或供应商来扩展测试对象。有什么最佳实践吗?
Currently several of my unit tests need common functions such as logging in a specific user from the mock objects or making sure that no one is logged in. I currently have those functions in a file which I include via a regular old include statement. That doesn't seem very cakey to me. I also don't want to keep typing the include statement at every test, so I'd like to do it a high level and have it available to all my tests and do so, of course, without modifying the core cakephp files.
So I'm left looking for a place to put the mustbeLoggedIn('usertype');
-type functions that will help keep my testing DRY, but fit better in the objects. So far I havent been successful extending the test object via the usual behaviors, helpers, or vendors that cake uses. Any best practices?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
/app/app_controller.php
/app/app_controller.php