Hi,

I've also had to deal with testing controllers that use Auth
lately.    Auth has improved heaps since 1.3 but it still seems to be
coupled with various bits and pieces of the core, and hence you might
get different behaviours between the website and testing.

I recommend mocking out Auth and getting it to return the value you
expect, in this case if your logged in user is 1, you can use
something like this :
$Users->Auth->expects($this->once())->method('user')
       -> with( 'id' )
        ->will($this->returnValue(1));

Check out
- 
http://book.cakephp.org/2.0/en/development/testing.html#using-mocks-with-testaction
and if you need more info on phpunit :
- 
http://www.phpunit.de/manual/current/en/test-doubles.html#test-doubles.mock-objects

The new move to phpunit in Cake 2, was a great idea.  It's quite
powerful and allows you to do almost everything you need while unit
testing.

Hope this helps,
Shuku

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to