views:

110

answers:

1

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?

A: 

/app/app_controller.php

Aziz
Mixing production code and code only used for testing purposes in a single class is a bad practice in my opinion, hence the downvote.
dhofstet