I am using the following code to test the login action in UsersController-

public function testLogin() {
    $data = array('User' => array(
                'username' => 'hello',
                'password' => '411'
                    )
            );
    $this->Users = $this->generate('Users',array('components'=> 
array('Auth','Session')));
    $this->Users->Auth->staticExpects($this->once())
                        ->method('user')
                        ->with('id');
    $this->testAction('/users/login', array('data' => $data, 'method' => 
'post'));
}

and the fixture is-
class UserFixture extends CakeTestFixture { public $import = array('model' 
=> 'User', 'records' => true, 'connection' => 'fixture'); 

}


and action is- 


public function login() {
    
            if($this->request->is('post')) {
                if($this->Auth->login()) {
                    $this->redirect($this->Auth->redirect());
                } else {
                    return false;
                    $this->Session->setFlash(__('Wrong Username Or 
Password,Please Try Again'));
                }
            }
        }


It always showing

Expectation failed for method name is equal to when invoked 1 time(s). 
Method was expected to be called 1 times, actually called 0 times. 

What is the problem?Cant find any solution,and the reason also.Please help.



-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to