2)App \ Test \ TestCase \ Controller \ UsersControllerTest :: testLogin " Auth.User"的会话内容不同。 null与预期类型不匹配" array"。
这是我的代码
function testLogin()
{
$this->enableCsrfToken();
$this->enableSecurityToken();
$this->post('/users/login', [
'username' => 'username@test.test',
'password' => 'password'
]);
$expected = [
'username' => 'username@test.test',
'password' => 'password'
];
$this->assertSession($expected, 'Auth.User');
$expected = [
'controller' => 'Index',
'action' => 'index'
];
$this->assertRedirect($expected);
}
我正在使用cakephp3.0和IntegrationTestCase。在我看来,我无法登录?为什么Auth.User有空值? PhpUnit和会话之间有什么关系?我不明白这一点。 我究竟做错了什么 ? 不是'Auth.User'在会话中写的是什么?我是测试的初学者。