The title pretty much says it all. I would like to test e.g. UsersController::admin_index()
action, but it's required for the user to be authorized to access this location, therefore when I run the test it sends me to the login page and even when I log in manully, no tests are done.
So how can I force cake to skip authorization without editing the actual authorization code?
btw, in case it helps, my testAdminIndex()
code looks like this:
function testAdminIndex() {
$result = $this->testAction('/admin/users/index');
debug($result);
}
There's an article that covers the subject here ...
http://mark-story.com/posts/view/testing-cakephp-controllers-the-hard-way
The recommendation is to bypass "testAction" completely and manually perform the request, after adding session values for the authenticated user. The example is as follows ...