I want to test the login function, if it works, and allows only valid and active users.
My custom fixture contains:
array( 'password' => '*emptyPasswordHash*', // empty password 'username' => 'Lorem', 'balance' => 0, 'currency' => 'USD', 'id' => 1, 'user_group_id' => 3, //Customer 'active' => 1, 'hash' => 'LoremHash' ),
My test function looks like this:
function testLogin() { //test valid login $result = $this->testAction('/users/login', array( 'data' => array( 'User' => array( 'username' => 'Lorem', 'pass' => '', 'remember' => true )), 'method' => 'post', 'return' => 'view' )); debug($result);
}
The login form has 3 inputs: username , password and remember
I set $this->Auth->autoRedirect = false; in UsersController::beforeFilter and I do some cookie settings
when i debug($this->data); in UsersController::login() , it shows the same data when testing and when normalizing the log. But when checking the login, the crash fails, and I get the message $this->Auth->loginError instead of logging in.
How can I check the login action?
Elwhis
source share