Cakephp测试登录

我想测试登录功能,如果它正常工作,只允许有效和活跃的用户。 我的用户夹具包含:
array(
        'password' => '*emptyPasswordHash*', // empty password
        'username' => 'Lorem',
        'balance' => 0,
        'currency' => 'USD',
        'id' => 1,
        'user_group_id' => 3, //Customer
        'active' => 1,
        'hash' => 'LoremHash'
    ),
我的测试函数如下所示:
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);
} 登录表单有3个输入:
username
password
remember
我在ѭ6中设置了
$this->Auth->autoRedirect = false;
,我正在做一些cookie设置 当我在
UsersController::login()
debug($this->data);
时,它会在测试和正常记录时显示完全相同的数据。但是,在测试登录失败时,我收到了
$this->Auth->loginError
消息而不是登录。 如何正确测试登录操作?     
已邀请:
如果你使用蛋糕Auth组件,不要破解它你不需要...... https://github.com/cakephp/cakephp/blob/master/cake/tests/cases/libs/controller/components/auth.test.php#L545 如果你真的想,看看专业人士是怎么做的:)     
您是否也设置了自定义功能,如CakePHP手册中所述:   通常,AuthComponent会   尝试验证登录   您输入的凭据是   通过比较它们来准确   已存储在您的用户模型中。   但是,有时候你   可能想做一些额外的工作   在确定适当的凭证。通过   将此变量设置为其中一个   你可以做几个不同的价值观   不同的东西。     

要回复问题请先登录注册