开发者

Where to place common library for unit test functions in Cakephp?

开发者 https://www.devze.com 2022-12-15 07:05 出处:网络
Currently several of my unit tests need common functions such as logging in a specific user fro开发者_StackOverflowm the mock objects or making sure that no one is logged in.I currently have those fun

Currently several of my unit tests need common functions such as logging in a specific user fro开发者_StackOverflowm 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?


/app/app_controller.php

0

精彩评论

暂无评论...
验证码 换一张
取 消